MBED_DEMOS / Mbed 2 deprecated mbed_mqtt_endpoint_nxp

Dependencies:   C12832_lcd EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed

Revision:
11:59ee476fda24
Parent:
10:748fc7052e61
Child:
12:952dce085876
--- a/MBEDEndpoint.cpp	Wed Feb 26 22:27:04 2014 +0000
+++ b/MBEDEndpoint.cpp	Thu Feb 27 00:14:58 2014 +0000
@@ -163,10 +163,71 @@
  }
  
  // load up our endpoint to the IOC
- bool MBEDEndpoint::loadEndpoint() { return this->m_transports[LOAD_TRANSPORT]->loadEndpoint(); }
+ bool MBEDEndpoint::loadEndpoint() { 
+     bool success = false;
+     char result[IOC_RESULT_LEN+1];
+     char payload[IOC_PAYLOAD_LEN+1];
+     
+     // initialize
+     memset(result,0,IOC_RESULT_LEN+1);
+     memset(this->m_payload_buffer,0,IOC_PAYLOAD_LEN+1);
+     
+     // create the URL
+     char *url = this->createIOCLoadURL();
+     
+     // build the payload
+     char *data = this->buildIOCPayload(data,IOC_PAYLOAD_LEN);
+     
+     // issue the request
+     success = this->m_transports[LOAD_TRANSPORT]->loadEndpoint(data,strlen(data),result,IOC_RESULT_LEN);
+     
+     // update the IOC ID if found
+     if (success) this->saveIOCID(result);
+     
+     // return our status
+     return success;
+ }
  
  // update our endpoint with the IOC
- bool MBEDEndpoint::updateEndpoint() { return this->m_transports[LOAD_TRANSPORT]->updateEndpoint(); } 
+ bool MBEDEndpoint::updateEndpoint() { 
+     bool success = false;
+     char result[IOC_RESULT_LEN+1];
+     char payload[IOC_PAYLOAD_LEN+1];
+     
+     // initialize
+     memset(result,0,IOC_RESULT_LEN+1);
+     memset(this->m_payload_buffer,0,IOC_PAYLOAD_LEN+1);
+     
+     // create the URL
+     char *url = this->createIOCUpdateURL(this->getIOCID());
+     
+     // build the payload
+     char *data = this->buildIOCPayload(data,IOC_PAYLOAD_LEN);
+     
+     // issue the request   
+     success = this->m_transports[LOAD_TRANSPORT]->updateEndpoint(data,strlen(data),result,IOC_RESULT_LEN);
+          
+     // return our status
+     return success; 
+ } 
+ 
+ // build out the Payload
+ char *MBEDEndpoint::buildIOCPayload(char *data,int data_length) {
+     // construct the payload for Load/Updates
+     
+     // return the payload
+     return buffer;
+ }
+  
+ // save the IOC ID
+ void MBEDEndpoint::saveIOCID(char *data) {
+     int ioc_id = -1;
+     
+     // parse the IOC ID from the data result
+     
+     // save the IOC ID
+     if (ioc_id > 0) this->setIOCID(ioc_id);
+ }
  
  // close down the Lights
  bool MBEDEndpoint::closeLights() {