Chat by using websocket on WIZwiki-W7500 platform. Recently WIZwiki-W7500 platform was announced by WIZnet. So I implemented a firmware of WIZwiki-W7500 by changing UART definition because I can handle a source code easily.
Dependencies: WIZnetInterface WebSocketClient mbed
Chat by using websocket on WIZwiki-W7500 platform
http://www.instructables.com/id/Chat-by-using-websocket-on-WIZwiki-W7500-platform/
Websocket Server example
https://github.com/bingdo/ChatDemoWithWebSocket
Revision 0:050ec445ef5a, committed 2015-08-06
- Comitter:
- bingdo
- Date:
- Thu Aug 06 05:55:03 2015 +0000
- Commit message:
- Chat by using websocket on WIZwiki-W7500 platform.
Changed in this revision
diff -r 000000000000 -r 050ec445ef5a WIZnetInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZnetInterface.lib Thu Aug 06 05:55:03 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#24a9f2df2145
diff -r 000000000000 -r 050ec445ef5a WebSocketClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebSocketClient.lib Thu Aug 06 05:55:03 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
diff -r 000000000000 -r 050ec445ef5a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Aug 06 05:55:03 2015 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "Websocket.h" + +Serial pc(USBTX, USBRX); // tx, rx + +int main() +{ + char send[256]; + char recv[256]; + int i = 0; + + printf("Wait a second...\r\n"); + uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0xAB}; + EthernetInterface eth; + eth.init(mac_addr); //Use DHCP + eth.connect(); + printf("IP Address is %s\n\r", eth.getIPAddress()); + + Websocket ws("ws://192.168.0.2:8888/ws"); + ws.connect(); + + memset(send, 0, 256); + memset(recv, 0, 256); + + while (1) + { + if (ws.read(recv)) + { + pc.printf("%s\r\n", recv); + } + + if(pc.readable()) + { + send[i] = pc.getc(); + if (send[i] == 0x0d) + { + send[i] = 0x00; + i = 0; + ws.send(send); + memset(send, 0, 256); + } + else if (send[i] == 0x08) + { + i--; + } + else if ((send[i] < 0x20) || (send[i] >= 0x7F)) + { + } + else + { + i++; + } + } + } +}
diff -r 000000000000 -r 050ec445ef5a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Aug 06 05:55:03 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file