Websocket Test Program for W5500 or WIZ550io ( WIZnet, http://wizwiki.net ) LPC11U68 Xpresso v2 + WIZ550io Ethernet Board.

Dependencies:   W5500Interface WebSocketClient mbed

Fork of Websocket_Ethernet_W5500 by Bongjun Hur

Websocket example using Ethernet component of WIZ550io (W5500)

How to put W5500 on your mbed board?

It's tested on LPC11U68 Board.

Files at this revision

API Documentation at this revision

Comitter:
Bongjun
Date:
Wed Aug 27 02:25:59 2014 +0000
Parent:
4:9cd12222999c
Child:
6:f20b8a6b33f3
Commit message:
change Ethernet library to W5500Interface

Changed in this revision

DS18B20Sensor.lib Show diff for this revision Revisions of this file
EthernetInterfaceW5500.lib Show diff for this revision Revisions of this file
W5500Interface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DS18B20Sensor.lib	Thu Jul 17 07:39:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/Bongjun/code/DS18B20Sensor/#0bcc4e42fec0
--- a/EthernetInterfaceW5500.lib	Thu Jul 17 07:39:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/Bongjun/code/EthernetInterfaceW5500/#274fda7476d0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/W5500Interface.lib	Wed Aug 27 02:25:59 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/EthernetInterfaceW5500-makers/code/W5500Interface/#a5d99521e9cc
--- a/main.cpp	Thu Jul 17 07:39:35 2014 +0000
+++ b/main.cpp	Wed Aug 27 02:25:59 2014 +0000
@@ -1,53 +1,50 @@
 #include "mbed.h"
-#include "EthernetInterfaceW5500.h"
+#include "EthernetInterface.h"
 #include "Websocket.h"
-#include "DS18B20Sensor.h"
 
 DigitalOut myled(LED1);
-DS18B20Sensor sensor(P1_25);
 
 int main()
 {
+    printf("Start Websocket Demo. \r\n");
+    
 #if defined(TARGET_LPC1114)
     SPI spi(dp2, dp1, dp6); // mosi, miso, sclk
-    EthernetInterfaceW5500 eth(&spi, dp25, dp26); // spi, cs, reset
+    EthernetInterface eth(&spi, dp25, dp26); // spi, cs, reset
 
 #elif defined(TARGET_LPC1768)
     SPI spi(p11, p12, p13); // mosi, miso, sclk
-    EthernetInterfaceW5500 eth(&spi, p14, p15); // spi, cs, reset
+    EthernetInterface eth(&spi, p14, p15); // spi, cs, reset
 
 #elif defined(TARGET_LPC11U68)
     SPI spi(P0_9, P0_8, P1_29); // mosi, miso, sclk
 //WIZnetInterface eth(&spi, P0_2, P1_25); // spi, cs, reset
 //SPI spi(p5, p6, p7); // mosi, miso, sclk
-    EthernetInterfaceW5500 eth(&spi, P0_2, P1_28);//, nRESET(p9); // reset pin is dummy, don't affect any pin of WIZ550io
+    EthernetInterface eth(&spi, P0_2, P1_28);//, nRESET(p9); // reset pin is dummy, don't affect any pin of WIZ550io
     spi.format(8,0); // 8bit, mode 0
     spi.frequency(7000000); // 7MHz
     wait(1); // 1 second for stable state
 
 #endif
 
-#ifdef _DHCP
     eth.init(); //Use DHCP
+    printf("Initialized, MAC: %s\r\n", eth.getMACAddress());
     eth.connect();
     //printf("IP Address is %s\n\r", eth.getIPAddress());
-    printf("Initialized, MAC: %s\n", eth.getMACAddress());
-    printf("Connected, IP: %s, MASK: %s, GW: %s\n",
-           eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
-
-#else
+    printf("Connected, IP: %s, MASK: %s, GW: %s\r\n",eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+/*
     // as your env. change to real IP address and so on.
-    int ret = eth.init("222.98.173.212", "255.255.255.192", "222.98.173.254");
+    //int ret = eth.init(your IP, Subnet, Gateway);
+    int ret = eth.init("xxx.xxx.xxx.xxx", "255.255.255.0", "yyy.yyy.yyy.yyy");
     if (!ret) {
-        printf("Initialized, MAC: %s\n", eth.getMACAddress());
-        printf("Connected, IP: %s, MASK: %s, GW: %s\n",
+        printf("Initialized, MAC: %s\r\n", eth.getMACAddress());
+        printf("Connected, IP: %s, MASK: %s, GW: %s\r\n",
                eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
     } else {
-        printf("Error eth.init() - ret = %d\n", ret);
+        printf("Error eth.init() - ret = %d\r\n", ret);
         return -1;
     }
-
-#endif
+*/
 
 //    Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo");
 //    ws.connect();
@@ -58,37 +55,18 @@
     ws.connect();
 
     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
-        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 : No Sensor", i);
-        }
 
+        sprintf(str, "%dth WebSocket message for WIZnet W5500 Hello World over Ethernet.", i);
         ws.send(str);
-
         // clear the buffer and wait a sec...
         memset(str, 0, 100);
         wait(0.5f);
 
         // websocket server should echo whatever we sent it
         if (ws.read(str)) {
-            printf("rcv'd: %s\n", str);
+            printf("Recv : %s\r\n", str);
         }
     }
     ws.close();