
websocket client for mbed
Dependencies: C12832_lcd EthernetInterface WebSocketClient mbed-rtos mbed
main.cpp
- Committer:
- MohamadNazrin
- Date:
- 2018-03-07
- Revision:
- 0:f36d489a4172
- Child:
- 1:c15b0540e252
File content as of revision 0:f36d489a4172:
#include "mbed.h" #include "EthernetInterface.h" #include "C12832_lcd.h" // Include for LCD code #include "Websocket.h" C12832_LCD lcd; //Initialize LCD Screen DigitalOut led(LED1); int main() { static const char* mbedIp = "192.168.137.2"; //IP static const char* mbedMask = "255.255.255.0"; // Mask static const char* mbedGateway = "192.168.137.1"; //Gateway EthernetInterface eth; // eth.init(); //Use DHCP eth.init(mbedIp,mbedMask,mbedGateway); eth.connect(); printf("IP Address is %s\n", eth.getIPAddress()); // display at terminal lcd.printf("IP address: %s \n",eth.getIPAddress()); // display LCD screen // websocket Websocket ws("ws://192.168.1.109:8000/ws"); bool c = ws.connect(); printf("Connect result: %s\n", c?"OK":"Failed"); ws.send("hello world"); }