Temperature dashboard assignment

Dependencies:   EthernetInterface LM75B mbed-rtos mbed

Fork of temperature-dashboard-start by Sille Van Landschoot

Revision:
16:58c33ec28b2a
Parent:
11:59dcefdda506
Child:
17:c8a4886ba688
diff -r 69e41cbbc8ac -r 58c33ec28b2a main.cpp
--- a/main.cpp	Sun Sep 21 05:55:13 2014 +0000
+++ b/main.cpp	Fri Nov 07 14:37:02 2014 +0000
@@ -1,31 +1,33 @@
 #include "mbed.h"
-#include "EthernetInterface.h"
+#include "TempDashSocketConnection.h"
+#include "TemperatureSensor.h"
+#include <string.h>
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+std::string key = "";
+std::string name = "mbed";
+static const char SERVER[] = "labict.be";
+static const int PORT = 45678;
 
 int main() {
+    pc.baud(115200);
     EthernetInterface eth;
     eth.init(); //Use DHCP
     eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
+    pc.printf("IP Address is %s\r\n", eth.getIPAddress());
     
-    TCPSocketConnection sock;
-    sock.connect("mbed.org", 80);
+    TemperatureSensor sensor(p28, p27, key, name);
     
-    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
-    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+    TempDashSocketConnection sock;
     
-    char buffer[300];
-    int ret;
-    while (true) {
-        ret = sock.receive(buffer, sizeof(buffer)-1);
-        if (ret <= 0)
-            break;
-        buffer[ret] = '\0';
-        printf("Received %d chars from server:\n%s\n", ret, buffer);
+    while(1) {
+        if (sensor.open()) {
+            sock.connect(SERVER, PORT);
+            sock.sendSensorData(sensor.getDataPacket());            
+            sock.close();
+            wait(1.0);
+        }
     }
-      
-    sock.close();
-    
     eth.disconnect();
-    
-    while(1) {}
 }