Wifi Pressure Sensor

Dependencies:   HTTPClient MPL3115A2 NTPClient TMP102 USBDevice cc3000_hostdriver_mbedsocket mbed

Revision:
12:41ecc717406f
Parent:
11:8a3bc0e3255d
Child:
13:cc381bd02ba1
--- a/tcpTests.cpp	Wed Jun 18 04:33:59 2014 +0000
+++ b/tcpTests.cpp	Wed Jun 18 06:18:16 2014 +0000
@@ -4,7 +4,7 @@
 
 #include "TCPSocketConnection.h"
 #include "TCPSocketServer.h"
-//#include "HTTPClient.h"
+#include "HTTPClient.h"
 //#include "Websocket.h"
 #include "TMP102.h"
 
@@ -13,7 +13,7 @@
 extern cc3000 wifi;
 extern USBSerial pc;
 
-//HTTPClient http;
+HTTPClient http;
 
 // NOTE : Change SolderSplashLabs to anything else for your own channel
 // Goto the viewier page here : http://sockets.mbed.org/SolderSplashLabs/viewer to see the websocket writes
@@ -52,13 +52,44 @@
 void TempTest (void)
 {
 float tempt = 0;
-
+float random = 0; 
 while (1) 
     {
-    tempt = temperature.read();
-    printf( "%05d\r\nTEMP, %.1f\r\n\0", tempt);
-    wait_ms(1000);
+       // tempt = temperature.read();
+       // pc.printf( "%05d\r\nTEMP, %.1f\r\n\0", tempt);
+       // HTTP POST Test
+       
+        random +=1;
+        HTTPMap map;
+        HTTPText inText(tmpBuffer, 512);
+       
+        char buffer[50];
+        sprintf (buffer, "%.1f", random);
+    
+        map.put("Temperature", buffer);
+        //map.put("test", "1234");
+        pc.printf(" \r\nTrying to post data.. %0.1f \r\n", random);
+        int ret = http.post("http://192.168.190.40:3000/readings", map, &inText);
+        if (!ret)
+        {
+          pc.printf("Executed POST successfully - read %d characters \r\n", strlen(tmpBuffer));
+          pc.printf("Result: %s \r\n", tmpBuffer);
+        }
+        else
+        {
+          pc.printf("Error - ret = %d - HTTP return code = %d \r\n", ret, http.getHTTPResponseCode());
+        }
+ 
+        wait_ms(1000);
+        if ( pc.readable() )
+        {
+            pc.printf("Ending Temp Posting \r\n");
+            pc.getc();
+            break;
+        }
     }
+    
+   
 }
 
 void XivelySimpleTest ( void )
@@ -159,7 +190,7 @@
 // ------------------------------------------------------------------------------------------------------------
 void HttpClientTest ( void )
 {
-/*
+
     //GET data
     pc.printf("\r\nTrying to fetch page... \r\n");
     int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", tmpBuffer, 128);
@@ -219,7 +250,6 @@
     {
       pc.printf("Error - ret = %d - HTTP return code = %d \r\n", ret, http.getHTTPResponseCode());
     }
-    */
 }
 
 // ------------------------------------------------------------------------------------------------------------