Skeleton program for Federico's 4YP project.

Dependencies:   WebSocketClient WiflyInterface mbed messages

Fork of IoT_Ex by Damien Frost

Files at this revision

API Documentation at this revision

Comitter:
defrost
Date:
Tue Oct 04 16:20:14 2016 +0000
Parent:
2:7abdaa5a9209
Child:
4:9e98e7679a62
Commit message:
- Works well with server

Changed in this revision

WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
headers/globals.h 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
source/ADC.cpp Show annotated file Show diff for this revision Revisions of this file
source/globals.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/WebSocketClient.lib	Tue Oct 04 13:59:13 2016 +0000
+++ b/WebSocketClient.lib	Tue Oct 04 16:20:14 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/defrost/code/WebSocketClient/#0d7b33cd11f9
+https://developer.mbed.org/users/defrost/code/WebSocketClient/#6f30d0c4ff7b
--- a/headers/globals.h	Tue Oct 04 13:59:13 2016 +0000
+++ b/headers/globals.h	Tue Oct 04 16:20:14 2016 +0000
@@ -24,7 +24,7 @@
 #define CHARMSGBUFF     1024
 #define TIMEOUTRECEIVEATTEMPTS  5
 #define WS_PORT     4444
-#define SERVER_IP "192.168.0.3"
+#define SERVER_IP "192.168.1.99"
 
 extern char* wifissid;
 extern char* wifipassword;
--- a/main.cpp	Tue Oct 04 13:59:13 2016 +0000
+++ b/main.cpp	Tue Oct 04 16:20:14 2016 +0000
@@ -22,6 +22,9 @@
     // Set the IoT ID:
     IoT_ID = 1;
     
+    // Set the Auto reconnect flag:
+    IotStatus.SetFlag(SF_AUTOCONNECT);
+    
     // Send a startup message to serial port:
     INFO("");
     INFO("");
@@ -59,6 +62,7 @@
     }
     
     
+    
     DisplayTimer.start();
     // Inifinite loop:
     while(1) {
@@ -99,11 +103,6 @@
             // Reset the timer:
             DisplayTimer.reset();
             
-            if(Led == 1){
-                Led = 0;
-            }else{
-                Led = 1;
-            }
         }
         
        
--- a/source/ADC.cpp	Tue Oct 04 13:59:13 2016 +0000
+++ b/source/ADC.cpp	Tue Oct 04 16:20:14 2016 +0000
@@ -40,7 +40,6 @@
     
     // Set the sample numbers (making this bigger samples more slowly):
     ADC1->SMPR2 = ADC_SMPR1_SMP16_1 | ADC_SMPR1_SMP16_2; // Set for 144 ADC clock cycles
-    ADC1->SMPR2 = ADC_SMPR1_SMP18_1 | ADC_SMPR1_SMP18_2; // Set for 144 ADC clock cycles
     
     
     INFO("ADC configuration complete!");
--- a/source/globals.cpp	Tue Oct 04 13:59:13 2016 +0000
+++ b/source/globals.cpp	Tue Oct 04 16:20:14 2016 +0000
@@ -23,7 +23,7 @@
 Timer           DisplayTimer;
 DigitalOut      Led(LED1);
 
-WiflyInterface eth(D8, D2, D6, LED1, wifissid, wifipassword, WPA2);
+WiflyInterface eth(D8, D2, D6, D5, wifissid, wifipassword, WPA2);
 
 int ReconnectAttempts = 0;
 int SendCounter = 0;
@@ -140,10 +140,7 @@
             INFO("Received: %s", msg_buffer);
             sscanf(msg_buffer, "%d,%s", wifi_cmd, msg_buffer2);
             if(*wifi_cmd == CHANGEVAR_WIFI_CMD){
-                // Get two more values:
-                sscanf(msg_buffer2, "%d,%f", var, value);
-            }else{
-                // Get one:
+                // Get one more value:
                 sscanf(msg_buffer2, "%f", value);
             }
         }else if(resp == -1){
@@ -163,7 +160,11 @@
     // modifies something in the SCS Controller:
     switch(wifi_var){
         case CV_LED:
-            
+            if(wifi_data > 0){
+                Led = 1;
+            }else{
+                Led = 0;
+            }
             break;
         
         default: