@@ -307,8 +307,8 @@ void beginLogging()
307
307
{
308
308
// Based on GPS data/time, create a log file in the format SFE_Surveyor_YYMMDD_HHMMSS.ubx
309
309
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;
312
312
if (i2cGNSS.getConfirmedTime () == true && i2cGNSS.getConfirmedDate () == true ) // Requires GNSS fix
313
313
timeValid = true ;
314
314
@@ -346,11 +346,30 @@ void beginLogging()
346
346
347
347
startLogTime_minutes = millis () / 1000L / 60 ; // Mark now as start of logging
348
348
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
+
350
370
if (reuseLastLog == true )
351
371
{
352
372
Serial.println (F (" Appending last available log" ));
353
- ubxFile.println (" Append file due to system reset" );
354
373
}
355
374
356
375
xSemaphoreGive (xFATSemaphore);
@@ -455,7 +474,7 @@ void setMessageOffsets(char* messageType, int& startOfBlock, int& endOfBlock)
455
474
{
456
475
char messageNamePiece[40 ]; // UBX_RTCM
457
476
sprintf (messageNamePiece, " UBX_%s" , messageType); // Put UBX_ infront of type
458
-
477
+
459
478
// Find the first occurrence
460
479
for (startOfBlock = 0 ; startOfBlock < MAX_UBX_MSG ; startOfBlock++)
461
480
{
@@ -490,13 +509,13 @@ bool setMessageRateByName(char *msgName, uint8_t msgRate)
490
509
{
491
510
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
492
511
{
493
- if (strcmp (ubxMessages[x].msgTextName , msgName) == 0 )
512
+ if (strcmp (ubxMessages[x].msgTextName , msgName) == 0 )
494
513
{
495
514
ubxMessages[x].msgRate = msgRate;
496
- return (true );
497
- }
515
+ return (true );
516
+ }
498
517
}
499
518
500
519
Serial.printf (" setMessageRateByName: %s not found\n\r " , msgName);
501
- return (false );
520
+ return (false );
502
521
}
0 commit comments