WebSocket client test for AbitUSBModem. see: http://developer.mbed.org/users/phsfan/notebook/abitusbmodem/

Dependencies:   AbitUSBModem USBHost WebSocketClient mbed

Files at this revision

API Documentation at this revision

Comitter:
phsfan
Date:
Wed Feb 25 07:15:03 2015 +0000
Commit message:
1st build

Changed in this revision

AbitUSBModem.lib Show annotated file Show diff for this revision Revisions of this file
USBHost.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.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AbitUSBModem.lib	Wed Feb 25 07:15:03 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/phsfan/code/AbitUSBModem/#1b851249d70b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost.lib	Wed Feb 25 07:15:03 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/phsfan/code/USBHost/#87dd5da1a5fe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Wed Feb 25 07:15:03 2015 +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	Wed Feb 25 07:15:03 2015 +0000
@@ -0,0 +1,61 @@
+// http://developer.mbed.org/users/donatien/code/VodafoneUSBModemWebsocketTest/
+#include "mbed.h"
+#include "AbitUSBModem.h"
+#include "Websocket.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut myled(LED1);
+
+void test(void const*) 
+{
+    AbitUSBModem modem;
+    Websocket ws("ws://sockets.mbed.org:443/ws/username/demo/rw");
+    char recv[128];
+
+    printf("connect\r\n");
+    int ret = modem.connect("prin", "prin");
+    if(ret) {
+      printf("Could not connect\r\n");
+      return;
+    }
+
+    printf("IP Address %s\r\n", modem.getIPAddress());
+
+    bool c = ws.connect();
+    printf("Connect result: %s\r\n", c?"OK":"Failed");
+    
+    for(int i = 0; i < 10000; i++)
+    {
+        if(!(i%100))
+        {
+          int ret = ws.send("WebSocket Hello World over the Y!mobile Network!");
+          if(ret<0)
+          {
+            printf("Timeout\r\n");
+            ws.close();
+            c = ws.connect();
+            printf("Connect result: %s\r\n", c?"OK":"Failed");
+          }
+        }
+        
+        if (ws.read(recv)) {
+            printf("rcv: %s\r\n", recv);
+        }
+    }
+
+    Thread::wait(1000);
+    printf("exit\r\n");
+    modem.disconnect();  
+}
+
+int main()
+{
+    pc.baud(115200); 
+    printf("** PHS MQTT\r\n");
+
+    Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
+    while(1) {
+        myled = !myled;
+        Thread::wait(1000);  
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 25 07:15:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file