@@ -307,8 +307,8 @@ void beginLogging()
307307 {
308308 // Based on GPS data/time, create a log file in the format SFE_Surveyor_YYMMDD_HHMMSS.ubx
309309 bool timeValid = false ;
310- // if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true) //Will pass if ZED's RTC is reporting (regardless of GNSS fix)
311- // timeValid = true;
310+ // if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true) //Will pass if ZED's RTC is reporting (regardless of GNSS fix)
311+ // timeValid = true;
312312 if (i2cGNSS.getConfirmedTime () == true && i2cGNSS.getConfirmedDate () == true ) // Requires GNSS fix
313313 timeValid = true ;
314314
@@ -346,11 +346,30 @@ void beginLogging()
346346
347347 startLogTime_minutes = millis () / 1000L / 60 ; // Mark now as start of logging
348348
349- // TODO For debug only, remove
349+ // Add NMEA txt message with restart reason
350+ char rstReason[30 ];
351+ switch (esp_reset_reason ())
352+ {
353+ case ESP_RST_UNKNOWN: strcpy (rstReason, " ESP_RST_UNKNOWN" ); break ;
354+ case ESP_RST_POWERON : strcpy (rstReason, " ESP_RST_POWERON" ); break ;
355+ case ESP_RST_SW : strcpy (rstReason, " ESP_RST_SW" ); break ;
356+ case ESP_RST_PANIC : strcpy (rstReason, " ESP_RST_PANIC" ); break ;
357+ case ESP_RST_INT_WDT : strcpy (rstReason, " ESP_RST_INT_WDT" ); break ;
358+ case ESP_RST_TASK_WDT : strcpy (rstReason, " ESP_RST_TASK_WDT" ); break ;
359+ case ESP_RST_WDT : strcpy (rstReason, " ESP_RST_WDT" ); break ;
360+ case ESP_RST_DEEPSLEEP : strcpy (rstReason, " ESP_RST_DEEPSLEEP" ); break ;
361+ case ESP_RST_BROWNOUT : strcpy (rstReason, " ESP_RST_BROWNOUT" ); break ;
362+ case ESP_RST_SDIO : strcpy (rstReason, " ESP_RST_SDIO" ); break ;
363+ default : strcpy (rstReason, " Unknown" );
364+ }
365+
366+ char nmeaMessage[82 ]; // Max NMEA sentence length is 82
367+ createNMEASentence (1 , 1 , nmeaMessage, rstReason); // sentenceNumber, textID
368+ ubxFile.println (nmeaMessage);
369+
350370 if (reuseLastLog == true )
351371 {
352372 Serial.println (F (" Appending last available log" ));
353- ubxFile.println (" Append file due to system reset" );
354373 }
355374
356375 xSemaphoreGive (xFATSemaphore);
@@ -455,7 +474,7 @@ void setMessageOffsets(char* messageType, int& startOfBlock, int& endOfBlock)
455474{
456475 char messageNamePiece[40 ]; // UBX_RTCM
457476 sprintf (messageNamePiece, " UBX_%s" , messageType); // Put UBX_ infront of type
458-
477+
459478 // Find the first occurrence
460479 for (startOfBlock = 0 ; startOfBlock < MAX_UBX_MSG ; startOfBlock++)
461480 {
@@ -490,13 +509,13 @@ bool setMessageRateByName(char *msgName, uint8_t msgRate)
490509{
491510 for (int x = 0 ; x < MAX_UBX_MSG ; x++)
492511 {
493- if (strcmp (ubxMessages[x].msgTextName , msgName) == 0 )
512+ if (strcmp (ubxMessages[x].msgTextName , msgName) == 0 )
494513 {
495514 ubxMessages[x].msgRate = msgRate;
496- return (true );
497- }
515+ return (true );
516+ }
498517 }
499518
500519 Serial.printf (" setMessageRateByName: %s not found\n\r " , msgName);
501- return (false );
520+ return (false );
502521}
0 commit comments