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.

Files at this revision

API Documentation at this revision

Comitter:
Bongjun
Date:
Tue Jul 08 05:51:34 2014 +0000
Child:
1:22e5197655a9
Commit message:
Websocket test program for W5500 (from WIZnet H/W TCP/IP chip); use module type named WIZ550io & LPC11U68 Board.; ; can see the result from "http://sockets.mbed.org/demo/viewer"

Changed in this revision

EthernetInterfaceW5500.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterfaceW5500.lib	Tue Jul 08 05:51:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Bongjun/code/EthernetInterfaceW5500/#d714b7a94bff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Tue Jul 08 05:51:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jul 08 05:51:34 2014 +0000
@@ -0,0 +1,82 @@
+#include "mbed.h"
+#include "EthernetInterfaceW5500.h"
+#include "Websocket.h"
+
+DigitalOut myled(LED1);
+
+int main()
+{
+#if defined(TARGET_LPC1114)
+    SPI spi(dp2, dp1, dp6); // mosi, miso, sclk
+    EthernetInterfaceW5500 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
+
+#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
+    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
+    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
+    int ret = eth.init("222.98.173.212", "255.255.255.192", "222.98.173.254");
+    if (!ret) {
+        printf("Initialized, MAC: %s\n", eth.getMACAddress());
+        printf("Connected, IP: %s, MASK: %s, GW: %s\n",
+               eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+    } else {
+        printf("Error eth.init() - ret = %d\n", ret);
+        return -1;
+    }
+
+#endif
+
+//    Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo");
+//    ws.connect();
+
+    // this code from http://mbed.org/teams/mbed/code/Websocket_Ethernet_HelloWorld/file/bd0a76c1d9d0/main.cpp
+    // view @ http://sockets.mbed.org/demo/viewer
+    Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw");
+    ws.connect();
+
+    char str[100];
+
+    for(int i=0; i<0x10; ++i) {
+        // string with a message
+        sprintf(str, "%d WebSocket 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);
+        }
+    }
+    ws.close();
+    eth.disconnect();
+
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jul 08 05:51:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file