Initial commit

Dependencies:   ConfigFile FXOS8700CQ M2XStreamClient-JMF MODSERIAL SDFileSystem WNCInterface jsonlite mbed-rtos mbed

Fork of StarterKit_M2X_DevLab by Jan Korycan

Revision:
16:358604977188
Parent:
15:c63a080c6814
--- a/config_me.h	Thu Apr 05 16:41:34 2018 +0000
+++ b/config_me.h	Thu Apr 05 19:04:26 2018 +0000
@@ -38,37 +38,40 @@
             char buff[15];
             int aux;
             
-            cfg.getValue("Enable_M2X", buff, sizeof(buff));
-            enableM2X = strcmp(buff, "1") == 0;
+            if (cfg.getValue("Enable_M2X", buff, sizeof(buff)))
+                enableM2X = strcmp(buff, "1") == 0;
             
-            cfg.getValue("M2X_Commmands", buff, sizeof(buff));
-            enableCommands = strcmp(buff, "1") == 0;
-                        
-            cfg.getValue("Enable_UDP", buff, sizeof(buff));
-            enableUDP = strcmp(buff, "1") == 0;
+            if (cfg.getValue("M2X_Commmands", buff, sizeof(buff)))
+                enableCommands = strcmp(buff, "1") == 0;
+            
+            if (cfg.getValue("Enable_UDP", buff, sizeof(buff)))
+                enableUDP = strcmp(buff, "1") == 0;
             
-            cfg.getValue("Command_Wait", buff, sizeof(buff));
-            aux = atoi(buff);
-            if ((aux > 0) && (aux < 3600))
-                commandDelay = aux;
-                
-            cfg.getValue("Command_Polls", buff, sizeof(buff));
-            aux = atoi(buff);
-            if ((aux > 0) && (aux < 10))
-                commandPolls = aux;
+            if (cfg.getValue("Command_Wait", buff, sizeof(buff))) {
+                aux = atoi(buff);
+                if ((aux > 0) && (aux < 3600))
+                    commandDelay = aux;
+            };
 
-            cfg.getValue("UDP_Port", buff, sizeof(buff));
-            aux = atoi(buff);
-            if ((aux > 0) && (aux < 65535))
-                udpPort = aux;
+            if (cfg.getValue("Command_Polls", buff, sizeof(buff))) {
+                aux = atoi(buff);
+                if ((aux > 0) && (aux < 10))
+                    commandPolls = aux;
+            };
+
+            if (cfg.getValue("UDP_Port", buff, sizeof(buff))) {
+                aux = atoi(buff);
+                if ((aux > 0) && (aux < 65535))
+                    udpPort = aux;
+            };
                 
             double lat, lon;
             
-            cfg.getValue("Latitude", buff, sizeof(buff));
-            lat = atof(buff);
+            if (cfg.getValue("Latitude", buff, sizeof(buff)))
+                lat = atof(buff);
             
-            cfg.getValue("Latitude", buff, sizeof(buff));
-            lon = atof(buff);
+            if (cfg.getValue("Longitude", buff, sizeof(buff)))
+                lon = atof(buff);
             
             if ((lat >= -90) && (lat <= 90) && (lon >= -180) && (lon <= 180)) {
                 locLat = lat;
@@ -78,7 +81,7 @@
         
         m2xConfigured = *deviceId && *m2xKey;
         
-        enableCommands &= enableM2X;
+        enableCommands = enableM2X && enableCommands;
     };
     
     void dumpConfig(Serial& pc) {
@@ -97,6 +100,7 @@
         pc.printf("#" CRLF);
         pc.printf("Command_Wait=%d" CRLF, commandDelay);
         pc.printf("Command_Polls=%d" CRLF, commandPolls);
+        pc.printf("# Data will be sent every %d seconds" CRLF, commandPolls * commandDelay);
     }
         
 private: