Web Socket connection (MBED is client side)

Dependencies:   EthernetNetIf MbedJSONValue mbed

Fork of WebSocket_test by Suga koubou

Files at this revision

API Documentation at this revision

Comitter:
sura0111
Date:
Tue Mar 22 05:17:52 2016 +0000
Parent:
1:6d42db5e8ace
Commit message:
update 0.01

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Mar 21 09:50:49 2016 +0000
+++ b/main.cpp	Tue Mar 22 05:17:52 2016 +0000
@@ -18,19 +18,12 @@
 // LED
 PwmOut led1(LED1);
 PwmOut led2(LED2);
-DigitalOut led3(p5);
-DigitalOut led4(p6);
-DigitalOut led5(p7);
-DigitalOut led6(LED3);
-DigitalOut led7(LED4);
+DigitalOut led[] = {(p5),(p6),(p7), (LED3), (LED4)};
 
 // Ethernet variables
 EthernetNetIf *eth;
 Websocket *ws;
 
-// Electro-tactile display data set
-unsigned int ElectroDots[CELL_COUNT]={0};
-
 bool readFlag = false;
 char buf[255] = {0};
 MbedJSONValue json;
@@ -46,8 +39,8 @@
 
 int main() {
     wsConnection();
-    led6 = 1;
-    led7 = 1;
+    led[3] = 1;
+    led[4] = 1;
     while(1){
         if(readFlag){
             if(json["edata"].size()>0){
@@ -55,9 +48,9 @@
                 led2 = json["edata"]["1"].get<int>()/100.0;
             };
             if(json["mdata"].size()>0){
-                led3 = json["mdata"]["0"].get<int>();
-                led4 = json["mdata"]["1"].get<int>();
-                led5 = json["mdata"]["2"].get<int>();
+                for(int i=0; i<3; i++){
+                    led[i] = json["mdata"][i].get<int>();
+                }
             };
             readFlag=false;
             // if(json["option"].size()>0){