mqtt specific components for the impact mbed endpoint library
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp
Diff: MBEDEndpoint.cpp
- Revision:
- 5:1ba6e68bf50e
- Parent:
- 0:a3fc1c6ef150
- Child:
- 6:2db2c7e75ad9
--- a/MBEDEndpoint.cpp Thu Mar 27 03:52:29 2014 +0000 +++ b/MBEDEndpoint.cpp Thu Mar 27 17:48:38 2014 +0000 @@ -22,10 +22,10 @@ // MBED Light support #include "MBEDLight.h" - // Emulated Resource Factory - #include "EmulatedResourceFactory.h" + // Light Personality: Emulated Light Resource Factory + #include "EmulatedLightResourceFactory.h" - // Emulated Actions we can act on + // Light Personality: Emulated Actions we can act on with the Light personalikty #include "EmulatedLightDimmerAction.h" #include "EmulatedLightSwitchAction.h" @@ -62,7 +62,7 @@ if (success) this->logger()->turnLEDYellow(); if (success)this->m_map = new MBEDToIOCResourceMap(error_handler); if (success) success = this->initializeTransports(); - if (success) success = this->initializeLights(); + if (success) success = this->initializePersonality(); if (success) this->logger()->turnLEDOrange(); this->logger()->lcdStatusOnly(true); if (!success) closedown(2); @@ -72,7 +72,7 @@ MBEDEndpoint::~MBEDEndpoint() { bool success = true; if (success) this->logger()->turnLEDYellow(); - if (success) success = this->closeLights(); + if (success) success = this->closePersonality(); if (success) success = this->closeTransports(); if (success) success = this->closeEthernet(); if (success) this->logger()->turnLEDBlue(); @@ -113,6 +113,15 @@ return this->m_lcd_status; } + // initialize our personality + bool MBEDEndpoint::initializeEndpointPersonality() { + #ifdef LIGHT_PERSONALITY + return this->initializeLights(); + #else + return NULL; + #endif + } + // initialize the Lights bool MBEDEndpoint::initializeLights() { int index = this->preferences()->getIntPreference("endpoint_id",LIGHT_NAME_INDEX); @@ -146,8 +155,17 @@ return NULL; } - // initialize our ResourceFactory - ResourceFactory *MBEDEndpoint::initResourceFactory() { return new EmulatedResourceFactory(this->logger(),(void *)this); } + // initialize the ResourceFactory to fit our personality + ResourceFactory *MBEDEndpoint::initResourceFactory() { + #ifdef LIGHT_PERSONALITY + return this->initLightResourceFactory(); + #else + return NULL; + #endif + } + + // initialize a Light Resource Factory + ResourceFactory *MBEDEndpoint::initLightResourceFactory() { return new EmulatedLightResourceFactory(this->logger(),(void *)this); } // Initialize the Endpoint Name - will be the first Light resource name (and there must be one...) void MBEDEndpoint::initEndpointName() { @@ -425,6 +443,15 @@ } } + // close down our endpoint personality + bool MBEDEndpoint::closeEndpointPersonality() { + #ifdef LIGHT_PERSONALITY + return this->closeLights(); + #else + return NULL; + #endif + } + // close down the Lights bool MBEDEndpoint::closeLights() { bool success = true;