пропажа слешей

Dependencies:   mbed mbed-STM32F103C8T6 MLX90614 Watchdog DS1820

Revision:
9:e8a07983289f
Parent:
7:870aba638c02
Child:
10:51960145754a
--- a/main.cpp	Tue Sep 29 17:45:22 2020 +0000
+++ b/main.cpp	Tue Sep 29 19:48:56 2020 +0000
@@ -159,7 +159,7 @@
 }
 
 bool enableGPS(bool powerUp) {
-    pc.printf("Powering GPS:");
+    pc.printf("Powering GPS %s:",powerUp?"up":"down");
     if(powerUp){
         _parser->send("AT+CGNSPWR=1"); //GPS power on
     } else {
@@ -195,7 +195,7 @@
           curLine = nextLine ? (nextLine+1) : NULL;
         }
         return fix>0;
-    }    
+    } 
     return false;
 }
 
@@ -207,9 +207,9 @@
     #if DEBUG_PC
     pc.baud(115200);
     pc.printf("Starting\r\n");
-    if (wd.WatchdogCausedReset())
+    if (wd.WatchdogCausedReset()) {
         pc.printf("Watchdog caused reset.\r\n");
-    
+    }
     #endif
     
     wd.Configure(WATCHDOG_INTERVAL_S);       // sets the timeout interval
@@ -219,7 +219,7 @@
     _parser = new ATCmdParser(_serial);
     _parser->debug_on( DEBUG_SIM );
     _parser->set_delimiter( "\r\n" );
-    _parser->set_timeout (1000*60);
+    _parser->set_timeout (WATCHDOG_INTERVAL_S/2);
     wait(0.5);
     
     enableGPS(0);
@@ -261,10 +261,14 @@
                 enableGPS(0);
                 state=STATE_COLLECTING_TELEMETRY; 
             } else {
+                #if DEBUG_PC
+                pc.printf("No fix at %d try\n", fixTries);
+                #endif
                 fixTries++;
                 if (fixTries>FIX_MAX_TRIES) {
                     //fix not achieved in given tries, send as is
                     enableGPS(0);
+                    wd.Service();
                     state=STATE_COLLECTING_TELEMETRY;
                 } else {
                     wd.Service();
@@ -295,13 +299,14 @@
             //Form JSON as {"tempIR":1,"temps":[1,...,10],"latitude":37,"longitude":51,"altitude":21,"validGeo":true}
             
             
-            snprintf(bufferString,2048,"{\"tempIR\":%f,\"latitude\":%f,\"longitude\":%f,\"altitude\":%f,\"validGeo\":%s,", IRtemp, latitude, longitude, altitude, fix ? "true" : "false");
+            snprintf(bufferString,2048,"{\"tempIR\":%f,\"latitude\":%f,\"longitude\":%f,\"altitude\":%f,\"validGeo\":%s,temps:[", IRtemp, latitude, longitude, altitude, fix ? "true" : "false");
             
             index = strlen(bufferString);
             
             for(i=0;i<SENSORS_COUNT;i++){
-                index += snprintf(&bufferString[index], 128-index, "%f", stickTemperatures[i]);
+                index += snprintf(&bufferString[index], 2048-index, i==0?"%f":",%f", stickTemperatures[i]);
             }
+            strcat (bufferString,"]}");
             
             
             state=STATE_SENDING_TELEMETRY;
@@ -328,12 +333,12 @@
         
         wd.Service();
         
-        #if DEBUG_PC
+        /*#if DEBUG_PC
             for(i=0;i<SENSORS_COUNT;i++){
                 pc.printf("temp[%d] = %3.1f C\r\n", i, stickTemperatures[i]);     // read temperature    
             }
             pc.printf("Temperature : %4.2f C2\r\n",IRtemp);
-        #endif
+        #endif*/
 
         //Feed the watchdog
         wd.Service();