Validation

Dependencies:   EthernetInterface WebSocketClient mbed-rtos mbed

Fork of UDPSocket_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
lavoieje
Date:
Tue Feb 13 17:35:50 2018 +0000
Parent:
10:1992d8ec32d2
Commit message:
validation;

Changed in this revision

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Tue Feb 13 17:35:50 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- a/main.cpp	Wed May 14 15:32:24 2014 +0000
+++ b/main.cpp	Tue Feb 13 17:35:50 2018 +0000
@@ -1,28 +1,22 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "Websocket.h"
+ 
  
 int main() {
+    char recv[30];
+ 
     EthernetInterface eth;
     eth.init(); //Use DHCP
     eth.connect();
-    
-    UDPSocket sock;
-    sock.init();
-    
-    Endpoint nist;
-    nist.set_address("utcnist.colorado.edu", 37);
-    
-    char out_buffer[] = "plop"; // Does not matter
-    sock.sendTo(nist, out_buffer, sizeof(out_buffer));
-    
-    char in_buffer[4];
-    int n = sock.receiveFrom(nist, in_buffer, sizeof(in_buffer));
-    
-    unsigned int timeRes = ntohl( *((unsigned int*)in_buffer));
-    printf("Received %d bytes from server %s on port %d: %u seconds since 1/01/1900 00:00 GMT\n", n, nist.get_address(), nist.get_port(), timeRes);
-    
-    sock.close();
-    
-    eth.disconnect();
-    while(1) {}
+    printf("IP Address is %s\n\r", eth.getIPAddress());
+ 
+    Websocket ws("ws://192.168.1.122:8000");
+    ws.connect();
+ 
+    while (1) {
+        ws.send("WebSocket Hello World over Ethernet");
+        wait(1.0);
+    }
 }
+   
\ No newline at end of file