The Analog value is updated to the server of ponniyin selvan

Dependencies:   EthernetInterface WebSocketClient mbed-rtos mbed

Fork of Websocket_Ethernet_HelloWorld by Mbed

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Fri Oct 25 00:07:04 2013 +0000
Parent:
2:00da1457c871
Child:
4:6b19b3ecbf42
Commit message:
Updated example and dependencies

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
--- a/EthernetInterface.lib	Thu Aug 23 14:11:49 2012 +0000
+++ b/EthernetInterface.lib	Fri Oct 25 00:07:04 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#0d9ae7845bfe
+http://mbed.org/users/mbed_official/code/EthernetInterface/#cba86db5ab96
--- a/WebSocketClient.lib	Thu Aug 23 14:11:49 2012 +0000
+++ b/WebSocketClient.lib	Fri Oct 25 00:07:04 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- a/main.cpp	Thu Aug 23 14:11:49 2012 +0000
+++ b/main.cpp	Fri Oct 25 00:07:04 2013 +0000
@@ -1,21 +1,47 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
 #include "Websocket.h"
+
+Ticker flash;
+DigitalOut led(LED1);
+void flashLED(void){led = !led;}
  
  
-int main() {
-    char recv[30];
- 
-    EthernetInterface eth;
-    eth.init(); //Use DHCP
-    eth.connect();
-    printf("IP Address is %s\n\r", eth.getIPAddress());
- 
-    Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo");
+int main() 
+{
+    flash.attach(&flashLED, 1.0f);
+    
+    EthernetInterface ethernet;
+    ethernet.init();    // connect with DHCP
+    int ret_val = ethernet.connect();
+
+    if (0 == ret_val) {
+        printf("IP Address: %s\n", ethernet.getIPAddress());
+    } else {
+        error("ethernet failed to connect: %d.\n", ret_val);
+    }
+
+    // view @ http://sockets.mbed.org/demo/viewer
+    Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw");
     ws.connect();
- 
-    while (1) {
-        ws.send("WebSocket Hello World over Ethernet");
-        wait(1.0);
+    char str[100];
+    
+    for(int i=0; i<0x7fffffff; ++i) {
+        // string with a message
+        sprintf(str, "%d WebSocket Hello World over Ethernet", i);
+        ws.send(str);
+    
+        // clear the buffer and wait a sec...
+        memset(str, 0, 100);
+        wait(0.5f);
+    
+        // websocket server should echo whatever we sent it
+        if (ws.read(str)) {
+            printf("rcv'd: %s\n", str);
+        }
     }
+    ws.close();
+    ethernet.disconnect();
+    
+    while(true);
 }
\ No newline at end of file
--- a/mbed-rtos.lib	Thu Aug 23 14:11:49 2012 +0000
+++ b/mbed-rtos.lib	Fri Oct 25 00:07:04 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#70bd33086f56
+http://mbed.org/users/mbed_official/code/mbed-rtos/#ee87e782d34f