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: IOCEndpoint.cpp
- Revision:
- 7:8a4a61202b36
- Parent:
- 6:2db2c7e75ad9
- Child:
- 11:9ae0fe4517c1
--- a/IOCEndpoint.cpp Thu Mar 27 18:14:05 2014 +0000 +++ b/IOCEndpoint.cpp Fri Mar 28 16:24:22 2014 +0000 @@ -21,7 +21,7 @@ // MBED instance support #include "MBEDEndpoint.h" - + // default constructor IOCEndpoint::IOCEndpoint(ErrorHandler *error_handler,void *endpoint) { this->m_error_handler = error_handler; @@ -33,7 +33,7 @@ } // build out the IOC Payload - char *IOCEndpoint::buildPayload(char *data,int data_length,Light *light) { + char *IOCEndpoint::buildLightPayload(char *data,int data_length,Light *light) { char tmp[TEMP_BUFFER_LEN+1]; // MBED Endpoint @@ -69,8 +69,8 @@ // Handle /dev/addldata char *dev_addldata = endpoint->getMap()->endpointNameToIOCName("/dev/addldata"); - if (dev_addldata != NULL && strcmp(name,dev_addldata) == 0 && light != NULL && light->getIOCID() > 0) { - char buf[IOC_IOC_ID_LEN+1]; memset(buf,0,IOC_IOC_ID_LEN+1); sprintf(buf,"%d",light->getIOCID()); + if (dev_addldata != NULL && strcmp(name,dev_addldata) == 0 && light != NULL && light->getExternalID() > 0) { + char buf[IOC_IOC_ID_LEN+1]; memset(buf,0,IOC_IOC_ID_LEN+1); sprintf(buf,"%d",light->getExternalID()); sprintf(tmp,"\"%s\":\"id:%s\",",name,buf); strcat(data,tmp); } @@ -101,8 +101,8 @@ return data; } - // save the IOC ID for a Light node - void IOCEndpoint::saveLightID(Light *light,char *json) { + // save the IOC ID for our Personality + void IOCEndpoint::saveExternalID(Personality *instance,char *json) { if (json != NULL) { //this->logger()->log("RESULT: %s",json); @@ -126,7 +126,7 @@ sscanf(str_ioc_id,"%d",&ioc_id); // save the IOC ID - if (ioc_id > 0) light->setIOCID(ioc_id); + if (ioc_id > 0) instance->setExternalID(ioc_id); } else { // cannot find the ID tag in the result JSON