webrocket program

Dependencies:   EthernetInterface WebSocketClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
fadel
Date:
Tue Dec 13 08:18:12 2016 +0000
Commit message:
websocket working program

Changed in this revision

EthernetInterface.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-rtos.lib 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/EthernetInterface.lib	Tue Dec 13 08:18:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#5887ae6c0c2c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Tue Dec 13 08:18:12 2016 +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 Dec 13 08:18:12 2016 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "Websocket.h"
+
+
+DigitalOut myled(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+Serial pc (USBTX,USBRX);
+ char mess[100];
+    
+int main() {
+    
+       EthernetInterface ether;
+       ether.init();
+    ether.connect();
+    
+     
+   
+ 
+    myled=1;
+
+      Websocket ws("ws://sockets.mbed.org:443/ws/fadel/rw");
+    ws.connect();
+ myled2=1;
+    
+    pc.printf("\n  connected %s\n\r");
+     //   TCPSocketConnection ggg;
+    // char ip[4];
+    //          ip[0] = 192;
+     //       ip[1] = 168;
+     //       ip[2] = 1;
+      //      ip[3] = 2;
+    
+   // ggg.connect(ip,3000);
+ // myled = 1;
+
+    while(1) {
+         
+         
+if(ws.is_connected())
+ myled3=1;
+ else if(!ws.is_connected())
+ myled3=0;
+ 
+        
+      //  ws.send("FADEL :)");
+       if( ws.read(mess))
+       {
+           pc.printf("\n  received %s\n\r");
+        myled4 = 1;
+        pc.printf(mess);
+     //   pc.printf("\n       IP Address is %s\n\r", ether.getIPAddress());
+       // ws.close();
+       myled4 = 0;
+      }
+        
+       //  wait(1);
+       // if(ggg.is_connected())
+       //  myled3=1;
+      //    pc.printf("IP Address is %s\n\r", ether.getIPAddress());
+      //    pc.printf("\n\r Network mask is %s\n\r", ether.getNetworkMask());
+       //   pc.printf("\n\r Gatewa ip Address is %s\n\r", ether.getGateway());
+      //  myled4 = 0;
+      //  wait(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Tue Dec 13 08:18:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#e2da1b20a6d5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 13 08:18:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file