Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Revision:
29:9a99f076129a
Parent:
28:52b7ca6aacd6
Child:
32:56a11a9a35a2
diff -r 52b7ca6aacd6 -r 9a99f076129a Light.cpp
--- a/Light.cpp	Fri Feb 28 03:10:53 2014 +0000
+++ b/Light.cpp	Fri Feb 28 04:56:16 2014 +0000
@@ -33,9 +33,14 @@
      memset(this->m_name,0,LIGHT_NAME_LEN+1);
      sprintf(this->m_name,LIGHT_NAME,instance);
      this->resources()->createResources(this->getName());
+     
+     // Setup Philips Light if enabled
+     if (PL_ENABLE) this->m_pl = new PhilipsLight(PL_LIGHT_ID,this->m_transports[HTTP_TRANSPORT],this->logger());
+     else this->m_pl = NULL;
           
      // DEBUG
-     this->logger()->log("Light name: %s", this->getName());     
+     if (PL_ENABLE) this->logger()->log("Light name: %s (Philips Light %d)",this->getName(),PL_LIGHT_ID);   
+     else this->logger()->log("Light name: %s", this->getName());  
  }
  
  // destructor
@@ -48,6 +53,9 @@
  // get the resource factory
  ResourceFactory *Light::getResourceFactory() { return this->m_resources; }
  
+ // get the Philips light
+ PhilipsLight *Light::pl() { return this->m_pl; }
+ 
  // set the dimmer action
  void Light::setDimmerAction(void *dimmer_action) { this->m_dimmer_action = dimmer_action; }
  
@@ -72,14 +80,14 @@
  // get the resources factory
  ResourceFactory *Light::resources() { return this->m_resources; }
  
- // turn ON (base class does nothing)
- void Light::on() { ; }
+ // turn ON 
+ void Light::on() { if (PL_ENABLE && this->pl() != NULL) this->pl()->on(); }
  
- // turn OFF (base class does nothing)
- void Light::off() { ; }
+ // turn OFF 
+ void Light::off() { if (PL_ENABLE && this->pl() != NULL) this->pl()->off(); }
  
- // dim (base class does nothing)
- void Light::dim(int value) { ; }
+ // dim 
+ void Light::dim(int value) { if (PL_ENABLE && this->pl() != NULL) this->pl()->dim(value);}
  
  // set the IOC ID
  void Light::setIOCID(int ioc_id) { this->m_ioc_id = ioc_id; }