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: LightSwitchAction.cpp
- Revision:
- 21:cfdaee0a2b50
- Parent:
- 9:90fadae5489a
- Child:
- 87:e9d77e9f9eae
diff -r f2dbbd852e08 -r cfdaee0a2b50 LightSwitchAction.cpp --- a/LightSwitchAction.cpp Wed Feb 26 18:59:01 2014 +0000 +++ b/LightSwitchAction.cpp Wed Feb 26 21:29:18 2014 +0000 @@ -27,6 +27,20 @@ LightSwitchAction::~LightSwitchAction() { } + // Toggle the Light Switch + void LightSwitchAction::toggle() { + ResourceFactory *resource = this->light()->getResourceFactory(); + char *value = resource->getResourceValue(SWITCH_RESOURCE); + if (value != NULL && strcmp(value,"1") == 0) { + this->logger()->log("Turning Light: %s ON",this->light()->getName()); + this->on(); + } + else { + this->logger()->log("Turning Light: %s OFF",this->light()->getName()); + this->off(); + } + } + // Light turned ON void LightSwitchAction::on() { this->light()->on(); }