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:
- 11:9ae0fe4517c1
- Parent:
- 10:d96c57c19611
- Child:
- 12:0114a6493457
--- a/MBEDEndpoint.cpp Fri Mar 28 16:50:02 2014 +0000 +++ b/MBEDEndpoint.cpp Fri Mar 28 17:49:19 2014 +0000 @@ -37,16 +37,14 @@ extern void closedown(int code); // default constructor - MBEDEndpoint::MBEDEndpoint(ErrorHandler *error_handler,EthernetInterface *ethernet) { + MBEDEndpoint::MBEDEndpoint(ErrorHandler *error_handler,EthernetInterface *ethernet) : BaseClass(error_handler,new IOCEndpoint(error_handler,(void *)this)) { bool success = true; this->m_instance_id = 0; this->m_preferences = NULL; memset(this->m_lcd_status,0,TEMP_BUFFER_LEN+1); memset(this->m_gw_address,0,PREFERENCE_VALUE_LEN+1); for(int i=0;i<NUM_TRANSPORTS;++i) this->m_transports[i] = NULL; - this->m_error_handler = error_handler; - this->m_ioc_endpoint = new IOCEndpoint(error_handler,(void *)this); - this->m_error_handler->setEndpoint((void *)this); + this->logger()->setEndpoint((void *)this); if (success) this->initPreferences(); if (success) this->initEndpointName(); if (success) this->logger()->turnLEDBlue(); @@ -266,7 +264,7 @@ // build the personality payload char *data = NULL; #ifdef LIGHT_PERSONALITY - data = this->iocEndpoint()->buildLightPayload(payload,IOC_PAYLOAD_LEN,(Light *)instance); + data = ((IOCEndpoint *)this->getEndpoint())->buildLightPayload(payload,IOC_PAYLOAD_LEN,(Light *)instance); #endif // issue the request @@ -282,7 +280,7 @@ //if (success) this->logger()->log("Saving IOC ID for Light: %s...",light->getName()); // update the External ID if found - if (success) this->iocEndpoint()->saveExternalID(instance,result); + if (success) ((IOCEndpoint *)this->getEndpoint())->saveExternalID(instance,result); // DEBUG if (success) this->logger()->log("Personality(%s): %s IOC ID=%d sent successfully",instance->getType(),instance->getName(),instance->getExternalID()); @@ -324,7 +322,7 @@ char *data = NULL; #ifdef LIGHT_PERSONALITY - data = this->iocEndpoint()->buildLightPayload(payload,IOC_PAYLOAD_LEN,(Light *)instance); + data = ((IOCEndpoint *)this->getEndpoint())->buildLightPayload(payload,IOC_PAYLOAD_LEN,(Light *)instance); #endif // issue the request @@ -389,13 +387,7 @@ if (value1 < value2) return value1; return value2; } - - // get our error handler - ErrorHandler *MBEDEndpoint::logger() { return this->m_error_handler; } - - // get our IOC endpoint - IOCEndpoint *MBEDEndpoint::iocEndpoint() { return this->m_ioc_endpoint; } - + // main running loop void MBEDEndpoint::run() { this->logger()->log("Endpoint Main Loop");