mbed_websocket_client_for_gps

Dependencies:   WebSocketClient WiflyInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
mbedschool
Date:
Wed Feb 04 04:37:48 2015 +0000
Commit message:
mbed_sebsocket_client_for_gps

Changed in this revision

WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
WiflyInterface.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
diff -r 000000000000 -r ba2e56067722 WebSocketClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Wed Feb 04 04:37:48 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a
diff -r 000000000000 -r ba2e56067722 WiflyInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Wed Feb 04 04:37:48 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/WiflyInterface/#fb4494783863
diff -r 000000000000 -r ba2e56067722 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 04 04:37:48 2015 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "Websocket.h"
+
+
+
+
+
+/* wifly interface:
+*     - p9 and p10 are for the serial communication
+*     - p19 is for the reset pin
+*     - p26 is for the connection status
+*     - "mbed" is the ssid of the network
+*     - "password" is the password
+*     - WPA is the security
+*/
+WiflyInterface wifly(p28, p27, p19, p26, "SEEED-MKT", "depot0510", WPA);
+DigitalOut led1(LED1);
+Serial gps(p9, p10);
+char buffer[65];                  
+int count=0; 
+void clearBufferArray()                     // function to clear buffer array
+{
+    for (int i=0; i<count;i++)
+    { buffer[i]=NULL;}                      // clear all index of array with command NULL
+}
+ 
+int main() {
+    //wifly.init(); //Use DHCP
+    wifly.init("192.168.21.45","255.255.255.0","192.168.21.2");
+    while (!wifly.connect());
+    led1=1;
+    printf("IP Address is %s\n\r", wifly.getIPAddress());
+
+    Websocket ws("ws://192.168.21.123:8888");
+    while (!ws.connect());
+    led1=2;
+        
+    count=0;   
+    while (1) {
+        char locatedata[256];
+                
+        while(gps.readable ())               // reading data into char array
+        {
+            char data[1];          
+            data[0] = gps.getc();
+
+            ws.send(data);            
+        }
+     //   ws.send(buffer);                // if no data transmission ends, write buffer to hardware serial port
+        clearBufferArray();                         // call clearBufferArray function to clear the storaged data from the array
+        count = 0; 
+                 
+        wait(1.0);
+    }
+}
diff -r 000000000000 -r ba2e56067722 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 04 04:37:48 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6
\ No newline at end of file