tes

Dependencies:   ASyncTicker EthernetInterface WebSocketClient mbed-rtos mbed MbedJSONValue xbee_lib

Revision:
0:d73af3f5c81d
Child:
1:6c1df6c9be4d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 27 21:50:20 2014 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include <stdio.h>
+#include <string.h>
+#include "Websocket.h"
+#include "Updateable.h"
+#include "ASyncTicker.h"
+#define PORT   80
+
+
+EthernetInterface ethernet;
+Websocket ws("ws://192.168.0.4:8080/");
+Ticker pull_ticker;
+
+
+
+void pull_updates(){
+  wait(0.1f);
+  printf("%s", "hello");
+
+}
+
+int main ()
+{
+
+    ethernet.init();    // connect with DHCP
+    int ret_val = ethernet.connect();
+ 
+    if (0 == ret_val) {
+        printf("IP Address: %s\n\r", ethernet.getIPAddress());
+    } else {
+        error("ethernet failed to connect: %d.\n\r", ret_val);
+    }
+    
+    
+    ws.connect();
+    
+        char str[100];
+    // string with a message
+        sprintf(str, "PU");
+        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\r", str);
+        }
+        ws.close();
+        pull_ticker.attach(&pull_updates, 5.0);
+        while(1){
+            
+            wait(0.1f);
+            }
+
+}