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:
2:90a84a216c58
Parent:
0:ae2a45502448
Child:
3:3db076b9d380
diff -r 2d81aac640bc -r 90a84a216c58 MQTTTransport.cpp
--- a/MQTTTransport.cpp	Tue Feb 25 17:12:46 2014 +0000
+++ b/MQTTTransport.cpp	Tue Feb 25 18:09:29 2014 +0000
@@ -64,20 +64,33 @@
      vector<string> data = str_payload.split(':');
      
      // format of the MQTT message:   message_type:name:verb|Parameter_X:value|keyword:optional_data
+     /*
      if (data.size() > 0) message_type = data[0];
      if (data.size() > 1) message_name = data[1];
      if (data.size() > 2) message_verb = data[2];
      if (data.size() > 3) message_value = data[3];
      if (data.size() > 4) message_opt = data[4];
+     */
+     
+     // XXX FIXUP until MQTT messages have endpoint_names in them
+     string tmp_name(endpoint->getEndpointName());
+     if (data.size() > 0) message_type = data[0];
+     if (data.size() > 1) message_name = tmp_name;
+     if (data.size() > 2) message_verb = data[2];
+     if (data.size() > 3) message_value = data[3];
+     if (data.size() > 4) message_opt = data[4];
+     
+     // DEBUG
+     this->logger()->log("Type: %s Name: %s Verb: %s Value: %s Opt: %s",message_type.c_str(),message_name.c_str(),message_verb.c_str(),message_value.c_str(),message_opt.c_str());
      
      // load endpoints
-     if (strcmp(message_type.c_str(),"endpoint") == 0) {
+     if (strcmp(message_type.c_str(),"Endpoint") == 0) {
          if (strcmp(message_name.c_str(),"all") == 0) {
              if (strcmp(message_verb.c_str(),"load") == 0) {
                  // load up our endpoint
                  endpoint->loadEndpoint();
              }
-             if (strcmp(message_verb.c_str(),"update") == 0) {
+             if (strcmp(message_verb.c_str(),"Update") == 0) {
                  // update our endpoint
                  endpoint->updateEndpoint();
              }
@@ -86,7 +99,7 @@
              // destined for our lights?
              int index = endpoint->indexOfLight((char *)message_name.c_str());
              if (index >= 0) {
-                 if (strcmp(message_verb.c_str(),"update") == 0) {
+                 if (strcmp(message_verb.c_str(),"Update") == 0) {
                      // update our endpoint
                      endpoint->updateEndpoint();
                  }
@@ -95,7 +108,7 @@
      }
      
      // change a resource value
-     if (strcmp(message_type.c_str(),"change") == 0) {
+     if (strcmp(message_type.c_str(),"Change") == 0) {
          // destined for our lights?
          int index = endpoint->indexOfLight((char *)message_name.c_str());
          if (index >= 0) {
@@ -109,7 +122,7 @@
      }
      
      // get a resource value
-     if (strcmp(message_type.c_str(),"get") == 0) {
+     if (strcmp(message_type.c_str(),"Get") == 0) {
          // destined for our lights?
          int index = endpoint->indexOfLight((char *)message_name.c_str());
          if (index >= 0) {