-

Dependencies:   EthernetInterfaceWithHostname HygroClip2-LPC mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Revision:
20:526d6c8c2c8d
Parent:
19:d49dacbf64de
Child:
21:b3676a4fcf2b
--- a/main.cpp	Tue May 03 08:47:35 2016 +0000
+++ b/main.cpp	Wed May 11 09:23:19 2016 +0000
@@ -30,12 +30,16 @@
             TCPSocketConnection sock;
             int connected = sock.connect("192.168.100.100", 1337);
             if (connected == 0)
-            {
+            {                
                 const size_t bufferLenght = 300;
                 char transmissionBuffer[bufferLenght];
                 int lenght = snprintf(transmissionBuffer, bufferLenght, "GET /relay?temperature=%.2f&humidity=%.2f&dewpoint=%.2f&id=1 HTTP/1.0\n\n", data->temperature, data->humidity,data->dewpoint);
                 printf(transmissionBuffer);
-                sock.send_all(transmissionBuffer, lenght);                
+                sock.send_all(transmissionBuffer, lenght);
+            }
+            else
+            {
+                printf("Failed to connect\n");
             }
             sock.close();
             
@@ -95,15 +99,22 @@
         led4 = 1;        
         if (sensor.isDataValid())
         {
-            SensorData * data = sensorMailBox.alloc();
-            data->temperature = sensor.getTemperature();
-            data->humidity = sensor.getHumidity();
-            data->dewpoint = sensor.getDewPoint();
-            sensorMailBox.put(data);
+            SensorData * data = sensorMailBox.alloc(1000);
+            if (data != NULL)
+            {
+                data->temperature = sensor.getTemperature();
+                data->humidity = sensor.getHumidity();
+                data->dewpoint = sensor.getDewPoint();
+                sensorMailBox.put(data);
+            }
+            else
+            {
+                printf("Mail is full");
+            }
         }
         sensor.update();
         Thread::wait(50);
         led4 = 0;
-        Thread::wait(9950);
+        Thread::wait(19950);
     }
 }