yet another 18B20 Temperature sensor. variable number of sensors working in parasite mode, serial 16x2 display with diagnostic output and post to a rest web service

Dependencies:   EthernetInterface HTTPClient NTPClient mbed-rtos mbed

Revision:
0:53f05303850a
Child:
1:9e88b2508768
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/collector_proxy.cpp	Mon Dec 31 12:08:24 2012 +0000
@@ -0,0 +1,34 @@
+#include "collector_proxy.h"
+#include "HTTPClient.h"
+
+#include <cstring>
+
+CollectorProxy::CollectorProxy(char *url) :base_url(url) {
+}
+
+int CollectorProxy::send_measure(char *path_part, int value) {
+    HTTPClient http;
+    HTTPMap data;
+    char str[512];
+    HTTPText in_text(str, 512);
+    
+    char url[200];
+    strcpy(url, base_url);
+    strcat(url, "/");
+    strcat(url, path_part);
+
+    char value_buffer[10];
+    sprintf(value_buffer, "%d", value);
+    data.put("value", value_buffer);
+
+    int ret = http.post(url, data, &in_text);
+
+    if (!ret) {
+        // printf("Executed POST successfully - read %d characters\n", strlen(str));
+        // printf("Result: %s\n", str);
+        return 1;
+    } else {
+        // printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+        return 0;
+    }
+}