Exosite Evaluation Example on LPC1768 mbed Application Board

Dependencies:   C12832_lcd EthernetInterface HTTPClient LM75B MMA7660 RGBLed mbed-rtos mbed

Fork of exosite_http_example by Patrick Barrett

Revision:
5:04490f27f83f
Parent:
4:d6e87aea518f
--- a/main.cpp	Tue Jan 20 23:38:51 2015 +0000
+++ b/main.cpp	Wed Jan 21 08:24:54 2015 +0000
@@ -4,12 +4,18 @@
 #include "C12832_lcd.h"
 #include <FileSystemLike.h>
 #include <FileHandle.h>
+#include "LM75B.h"
 
+/* known issues:
+1. CIK becomes corrupted after updating bin files on mbed device -or- resets
+2. Does not read led1 yet to control LED1 on/off
+
+*/
 const char VENDOR[] = "exosite";
 const char MODEL[] = "mbed_lpc1768_appbrdv1";
 
 #define WRITE_ALIAS "temp"
-#define READ_ALIASES "?screen"
+#define READ_ALIASES "?screen&led1"
 
 char EXO_CIK_HDR[] = "X-Exosite-CIK: 0000000000000000000000000000000000000000\r\n";
 const char EXO_CIK_HDR_FMT[] = "X-Exosite-CIK: %s\r\n";
@@ -31,9 +37,16 @@
 LocalFileSystem localfs("local");
 
 static C12832_LCD lcd;
+LM75B tmp(p28,p27);
+
+AnalogIn   Pot1(p19);
+AnalogIn   Pot2(p20);
+DigitalOut Led1Out(LED1);
 
 int main()
 {
+    int uptime = 0;
+    
     run_time.start();
     send_timer.start();
 
@@ -106,11 +119,41 @@
         char *key, *value;
         char incomming_buffer[BUFFSIZE];
         char scratch[32];
+        char tmp_str[8]={0};
+        char uptime_str[8]={0};
+        char pot1_str[8]={0};
+        char pot2_str[8]={0};
+        
         HTTPMap read_map = HTTPMap(incomming_buffer, BUFFSIZE);
         HTTPMap write_map = HTTPMap();
         
-        write_map.put("tempa", "127");
-        write_map.put("uptime", "5");
+        if(tmp.open())
+        {
+            snprintf(tmp_str, 16, "%.2f", (float)tmp);
+            printf("[%f] temp: %s C\r\n", run_time.read(), tmp_str);
+            write_map.put("tempc", tmp_str);
+        }
+        else {
+            error("Temp Sensor not detected!\n");
+        }
+        
+        snprintf(pot1_str, 16, "%3.3f", Pot1.read()*100.0f);
+        printf("[%f] Pot1: %s %%\r\n", run_time.read(), pot1_str);
+        write_map.put("pot1", pot1_str);
+        
+        snprintf(pot2_str, 16, "%3.3f", Pot2.read()*100.0f);
+        printf("[%f] Pot2: %s %%\r\n", run_time.read(), pot2_str);
+        write_map.put("pot2", pot2_str);
+        
+        /*if(Pot1 > 0.3f) {
+            Led1Out = 1;
+        } else {
+            Led1Out = 0;
+        }*/
+        
+        snprintf(uptime_str, 16, "%d", uptime);
+        printf("[%f] Uptimer Counter: %s\r\n", run_time.read(), uptime_str);
+        write_map.put("uptime", uptime_str);
     
         http.setHeader(0,EXO_CIK_HDR);
         http.setHeader(1,EXO_ACCEPT_HDR);
@@ -145,7 +188,7 @@
         }
         
         printf("[%f] Completed in %f seconds.\r\n", run_time.read(), connection_timer.read());
-        
+        uptime++;
         wait(5);
     }