MBED_DEMOS / Mbed 2 deprecated mbed_mqtt_endpoint_ublox_ethernet

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

Revision:
11:59ee476fda24
Parent:
10:748fc7052e61
Child:
12:952dce085876
--- a/HTTPTransport.cpp	Wed Feb 26 22:27:04 2014 +0000
+++ b/HTTPTransport.cpp	Thu Feb 27 00:14:58 2014 +0000
@@ -37,74 +37,19 @@
  HTTPTransport::~HTTPTransport() {
  }
  
- // build out the Payload
- char *HTTPTransport::buildIOCPayload() {
-     MBEDEndpoint *endpoint = (MBEDEndpoint *)this->getEndpoint();
-     memset(this->m_payload_buffer,0,IOC_PAYLOAD_LEN+1);
-     
-     // construct the payload for Load/Updates
-     
-     // return the payload
-     return this->m_payload_buffer;
- }
- 
- // save the IOC ID
- void HTTPTransport::saveIOCID(char *data) {
-     MBEDEndpoint *endpoint = (MBEDEndpoint *)this->getEndpoint();
-     int ioc_id = -1;
-     
-     // parse the IOC ID from the data result
-     
-     // save the IOC ID
-     if (ioc_id > 0) endpoint->setIOCID(ioc_id);
- }
- 
  // Load up our endpoint into the IOC
- bool HTTPTransport::loadEndpoint() {
-     bool success = false;
-     
-     // create the URL
-     char *url = this->createIOCLoadURL();
-     
-     // build the payload
-     char *data = this->buildIOCPayload();
-     
-     // issue the POST
-     memset(this->m_result_buffer,0,IOC_RESULT_LEN+1);
-     success = this->httpPost(url,data,strlen(data),(char *)this->m_result_buffer,IOC_RESULT_LEN);
-     
-     // update the IOC ID if found
-     if (success) this->saveIOCID(this->m_result_buffer);
-     
-     // return our status
-     return success;
- }
+ bool HTTPTransport::loadEndpoint(char *data,int data_length,char *result,int result_length) { return this->httpPost(url,data,strlen(data),result,result_length); }
  
  // update our endpoint with the IOC
- bool HTTPTransport::updateEndpoint() {
-     bool success = false;
-     
-     // create the URL
-     char *url = this->createIOCUpdateURL(endpoint->getIOCID());
-     
-     // build the payload
-     char *data = this->buildIOCPayload();
-     
-     // issue the PUT
-     memset(this->m_result_buffer,0,IOC_RESULT_LEN+1);
-     success = this->httpPut(url,data,strlen(data),(char *)this->m_result_buffer,IOC_RESULT_LEN);
-     
-     // return our status
-     return success;
- }   
+ bool HTTPTransport::updateEndpoint(char *data,int data_length,char *result,int result_length) { return this->httpPut(url,data,strlen(data),result,result_length); }
  
  // create the IOC load URL
  char *HTTPTransport::createIOCLoadURL() { return this->createIOCUpdateURL(0); }
  
  // create the IOC update URL
  char *HTTPTransport::createIOCUpdateURL(int ioc_id) {
-     char ioc_id_str[16];
-     memset(ioc_id_str,0,16);
+     char ioc_id_str[IOC_IOC_ID_LEN+1];
+     memset(ioc_id_str,0,IOC_IOC_ID_LEN+1);
      if (ioc_id > 0) sprintf(ioc_id_str,"/%d",ioc_id);
      memset(this->m_url_buffer,0,IOC_REST_URL_LEN+1);
      sprintf(this->m_url_buffer,IOC_REST_URL,IOC_HOST_NAME,IOC_DATASOURCE_ID,ioc_id_str);