Websocket Test Program for W5500 (WIZ550io) FRDM-KL25Z WIZ550io Ethernet Board.

Dependencies:   W5500Interface WebSocketClient mbed

Fork of Websocket_Ethernet_W5500 by W5500-Ethernet-Interface Makers

Websocket example using Ethernet component of WIZ550io (W5500). FRDM-KL25Z is used.

Revision:
3:4c02f6287752
Parent:
2:d6eb2ce07362
Child:
4:8b4aacaab1f1
--- a/main.cpp	Tue Jul 08 08:37:08 2014 +0000
+++ b/main.cpp	Tue Jul 08 23:58:21 2014 +0000
@@ -59,19 +59,27 @@
 
     char str[100];
     char sensorBuf[25];
+
     uint8_t result;
     uint8_t sensor_cnt;
+
+    //Before using this sensor, should called sensor.count() once.
     sensor_cnt = sensor.count();
 
     for(int i=0; i<0x10; ++i) {
         // string with a message
-        result = sensor.startReading(true);     // start sensor readings and wait
-        if (result == DS18X20_OK) {
-            sensor.getReading(sensorBuf, 0);         // get result into buf
-            sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : Current Temperature is %s", i, sensorBuf);
+        if (sensor_cnt) {
+            result = sensor.startReading(true);     // start sensor readings and wait
+            if (result == DS18X20_OK) {
+                sensor.getReading(sensorBuf, 0);         // get result into buf
+                sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : Current Temperature is %s", i, sensorBuf);
+            } else {
+                sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet", i);
+            }
         } else {
-            sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet", i);
+            sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : No Sensor", i);
         }
+
         ws.send(str);
 
         // clear the buffer and wait a sec...