Axeda AMMMP sample code for the mbed NXP LPC1768 Prototyping Board

Dependencies:   EthernetInterface mbed-rtos mbed

Dependents:   AxedaGo-mbed_WIZnetInterface

Revision:
3:359e019da3b9
Parent:
2:3402e0dbab6b
Child:
4:22d6467147a5
--- a/main.cpp	Tue Oct 29 16:51:32 2013 +0000
+++ b/main.cpp	Mon Jun 23 20:08:09 2014 +0000
@@ -15,13 +15,15 @@
 {
     
     char *MODEL = "mbed";
-    char *SERIAL_NUM = "abc-123"; 
+    char *SERIAL_NUM = "nlr__jrogers_axeda_com___6239433"; 
     float DEADBAND = 0.015;
     
     char* ip;
     
-    char http_cmd[300];   
-    char buffer[300];  
+    int http_cmd_sz=800;
+    char http_cmd[http_cmd_sz];
+    int buffer_sz=300;  
+    char buffer[buffer_sz];  
     int returnCode = 0;
     
     led1 = 1;
@@ -52,26 +54,26 @@
     led3 = strlen(ip)<4 ? 1: 0;
     printf("  -  IP address:%s\r\n", ip);
     
-    float potVal = 0.0;
+    float oil_level = 0.0;
     float oldPotVal = -2.0;
     
     while(1) {
     
-        potVal = pot1.read();
+        oil_level = pot1.read();
         
-        if ( abs(potVal - oldPotVal) < DEADBAND)
+        if ( abs(oil_level - oldPotVal) < DEADBAND)
         {
             continue;   
         }
         else
         {
             led4 = 1;
-            oldPotVal = potVal;
-            printf("Sending Value  %.2f\n\r", potVal);
-            sock.connect("dev6-connect.axeda.com", 52689);
+            oldPotVal = oil_level;
+            printf("Sending Value  %.2f\n\r", oil_level);
+            sock.connect("toolbox-stage-connect.axeda.com", 80);
  
-            sprintf(http_cmd,  "POST /ammp/data/1/%s!%s HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 47\r\n\r\n{\"data\":[{\"di\":{\"bar\":\"camp\",\"pot1\":%.2f}}]}\r\n\r\n", MODEL, SERIAL_NUM,potVal);
-            sock.send_all(http_cmd, sizeof(http_cmd)-1);
+            snprintf(http_cmd, http_cmd_sz,  "POST /ammp/data/1/%s!%s HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 47\r\n\r\n{\"data\":[{\"di\":{\"oil_level\":%.2f}}]}\r\n\r\n", MODEL, SERIAL_NUM, oil_level);
+            sock.send_all(http_cmd, strlen(http_cmd)-1);
     
             while ( (returnCode = sock.receive(buffer, sizeof(buffer)-1)) > 0)
             {