websocket client for mbed

Dependencies:   C12832_lcd EthernetInterface WebSocketClient mbed-rtos mbed

Revision:
0:f36d489a4172
Child:
1:c15b0540e252
diff -r 000000000000 -r f36d489a4172 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 07 09:06:58 2018 +0000
@@ -0,0 +1,27 @@
+#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");
+      
+}