mqtt specific components for the impact mbed endpoint library
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp
Revision 51:15c81f725ba2, committed 2014-08-28
- Comitter:
- ansond
- Date:
- Thu Aug 28 20:56:49 2014 +0000
- Parent:
- 50:38cd1b5f1cde
- Child:
- 52:8b95544920af
- Commit message:
- added support for status reporting
Changed in this revision
--- a/IOCEndpoint.cpp Fri Jul 25 21:21:40 2014 +0000 +++ b/IOCEndpoint.cpp Thu Aug 28 20:56:49 2014 +0000 @@ -138,4 +138,4 @@ this->logger()->log("JSON: %s",json); } } - } \ No newline at end of file + } \ No newline at end of file
--- 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
--- a/MBEDEndpoint.h Fri Jul 25 21:21:40 2014 +0000 +++ b/MBEDEndpoint.h Thu Aug 28 20:56:49 2014 +0000 @@ -68,9 +68,10 @@ char m_gw_address[PREFERENCE_VALUE_LEN+1]; // GW address buffer char m_gw_port[PREFERENCE_VALUE_LEN+1]; // GW port buffer int m_instance_id; // instance ID for this endpoint + void *m_status_reporter; // status reporter (optional) public: - MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *extra); + MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *status_reporter,void *extra); virtual ~MBEDEndpoint(); ResourceFactory *initResourceFactory(); void run(); @@ -94,6 +95,8 @@ Preferences *preferences(); + void extraEventLoopWork(); + protected: private: