Axeda AMMMP sample code for the mbed NXP LPC1768 Prototyping Board

Dependencies:   EthernetInterface mbed-rtos mbed

Dependents:   AxedaGo-mbed_WIZnetInterface

Revision:
4:22d6467147a5
Parent:
3:359e019da3b9
Child:
5:1b8ad120cf29
--- a/main.cpp	Mon Jun 23 20:08:09 2014 +0000
+++ b/main.cpp	Tue Jun 24 15:40:21 2014 +0000
@@ -4,6 +4,7 @@
 EthernetInterface eth;
  
 AnalogIn pot1(p19);
+AnalogIn pot2(p20);
 TCPSocketConnection sock;
  
 DigitalOut led1(LED1);
@@ -15,7 +16,7 @@
 {
     
     char *MODEL = "mbed";
-    char *SERIAL_NUM = "nlr__jrogers_axeda_com___6239433"; 
+    char *SERIAL_NUM = "SerialNumber"; 
     float DEADBAND = 0.015;
     
     char* ip;
@@ -55,13 +56,16 @@
     printf("  -  IP address:%s\r\n", ip);
     
     float oil_level = 0.0;
+    float oil_level2= 0.0;
     float oldPotVal = -2.0;
+    float oldPotVal2 = -2.0;
     
     while(1) {
     
         oil_level = pot1.read();
+        oil_level2=pot2.read();
         
-        if ( abs(oil_level - oldPotVal) < DEADBAND)
+        if ( abs(oil_level - oldPotVal) < DEADBAND && abs(oil_level2 - oldPotVal2) < DEADBAND)
         {
             continue;   
         }
@@ -69,10 +73,12 @@
         {
             led4 = 1;
             oldPotVal = oil_level;
-            printf("Sending Value  %.2f\n\r", oil_level);
+            oldPotVal2 = oil_level2;
+            printf("Sending Value for well1 %.2f\n\r", oil_level);
+            printf("Sending Value for well2 %.2f\n\r", oil_level2);
             sock.connect("toolbox-stage-connect.axeda.com", 80);
  
-            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);
+            snprintf(http_cmd, http_cmd_sz,  "POST /ammp/data/1/%s!%s HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 65\r\n\r\n{\"data\":[{\"di\":{\"oil_level\":%.2f, \"oil_level2\":%.2f}}]}\r\n\r\n", MODEL, SERIAL_NUM, oil_level, oil_level2);
             sock.send_all(http_cmd, strlen(http_cmd)-1);
     
             while ( (returnCode = sock.receive(buffer, sizeof(buffer)-1)) > 0)