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:
- 51:15c81f725ba2
- Parent:
- 47:b775f5453b5d
- Child:
- 52:8b95544920af
--- a/MBEDEndpoint.cpp Fri Jul 25 21:21:40 2014 +0000 +++ b/MBEDEndpoint.cpp Thu Aug 28 20:56:49 2014 +0000 @@ -29,6 +29,11 @@ #include "EmulatedLightDimmerAction.h" #include "EmulatedLightSwitchAction.h" + // Salesforce Status Reporting (if enabled) + #if SF_STATUS_REPORTING + #include "StatusReporter.h" + #endif + // string support #include <stdlib.h> #include <string.h> @@ -37,10 +42,11 @@ extern void closedown(int code); // default constructor - MBEDEndpoint::MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *extra) : BaseClass(error_handler,NULL) { + MBEDEndpoint::MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *status_reporter,void *extra) : BaseClass(error_handler,NULL) { bool success = true; this->m_instance_id = 0; this->m_preferences = NULL; + this->m_status_reporter = status_reporter; 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; @@ -473,6 +479,20 @@ // check for exit //this->logger()->log("Checking for exit..."); this->logger()->checkForExit(); + + // do any extra event loop activities + this->extraEventLoopWork(); } -} + } + + // do any extra work from within the event loop + void MBEDEndpoint::extraEventLoopWork() { + // check and send status reporting if enabled + #if SF_STATUS_REPORTING + if (this->m_status_reporter != NULL) { + StatusReporter *status_reporter = (StatusReporter *)this->m_status_reporter; + status_reporter->checkAndReportOnStatus(); + } + #endif + } \ No newline at end of file