Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Diff: Light.cpp
- Revision:
- 9:90fadae5489a
- Parent:
- 5:c1c4d511b589
- Child:
- 16:fda7dbb8b47a
diff -r d7ea38b0e131 -r 90fadae5489a Light.cpp --- a/Light.cpp Mon Feb 24 22:25:18 2014 +0000 +++ b/Light.cpp Tue Feb 25 05:27:29 2014 +0000 @@ -19,6 +19,10 @@ #include "Light.h" #include "MBEDEndpoint.h" + // include the relevant action support + #include "LightDimmerAction.h" + #include "LightSwitchAction.h" + // default constructor Light::Light(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) { this->m_error_handler = error_handler; @@ -30,16 +34,28 @@ } sprintf(this->m_name,LIGHT_NAME,instance); this->resources()->createResources(this->getName()); - + // DEBUG this->logger()->log("Light name:%s\n", this->getName()); } - // default destructor - Light::~Light() { - + // destructor + Light::~Light() { + if (this->m_resources != NULL) delete this->m_resources; } + // set the dimmer action + void Light::setDimmerAction(void *dimmer_action) { this->m_dimmer_action = dimmer_action; } + + // set the switch actino + void Light::setSwitchAction(void *switch_action) {this->m_switch_action = switch_action; } + + // get the dimmer action + void *Light::getDimmerAction() { return this->m_dimmer_action; } + + // get the switch action + void *Light::getSwitchAction() { return this->m_switch_action; } + // get the requested transport Transport *Light::getTransport(int index) { return this->m_transports[index]; } @@ -52,5 +68,14 @@ // get the resources factory ResourceFactory *Light::resources() { return this->m_resources; } + // turn ON (base class does nothing) + void Light::on() { ; } + + // turn OFF (base class does nothing) + void Light::off() { ; } + + // dim (base class does nothing) + void Light::dim(int value) { ; } + \ No newline at end of file