Skip to content

Commit f136fff

Browse files
committed
Add block to prevent timestamp timeout if RTC is not available
1 parent f13725c commit f136fff

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Firmware/RTK_Surveyor/States.ino

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void updateSystemState()
324324

325325
//Start the NTRIP server if requested
326326
if ((settings.ntripServer_StartAtSurveyIn == false)
327-
&& (settings.enableNtripServer == true))
327+
&& (settings.enableNtripServer == true))
328328
{
329329
ntripServerStart();
330330
}
@@ -458,7 +458,7 @@ void updateSystemState()
458458
//Try to gain access the SD card
459459
sdCardWasOnline = online.microSD;
460460
if (online.microSD != true)
461-
beginSD();
461+
beginSD();
462462

463463
if (online.microSD == true)
464464
{
@@ -468,15 +468,15 @@ void updateSystemState()
468468
{
469469
fileOpen = true;
470470
marksFile->timestamp(T_CREATE, rtc.getYear(), rtc.getMonth() + 1, rtc.getDay(),
471-
rtc.getHour(true), rtc.getMinute(), rtc.getSecond());
471+
rtc.getHour(true), rtc.getMinute(), rtc.getSecond());
472472
}
473473
else if (marksFile && marksFile->open(fileName, O_CREAT | O_WRITE))
474474
{
475475
fileOpen = true;
476476
marksFile->timestamp(T_ACCESS, rtc.getYear(), rtc.getMonth() + 1, rtc.getDay(),
477-
rtc.getHour(true), rtc.getMinute(), rtc.getSecond());
477+
rtc.getHour(true), rtc.getMinute(), rtc.getSecond());
478478
marksFile->timestamp(T_WRITE, rtc.getYear(), rtc.getMonth() + 1, rtc.getDay(),
479-
rtc.getHour(true), rtc.getMinute(), rtc.getSecond());
479+
rtc.getHour(true), rtc.getMinute(), rtc.getSecond());
480480

481481
//Add the column headers
482482
//YYYYMMDDHHMMSS, Lat: xxxx, Long: xxxx, Alt: xxxx, SIV: xx, HPA: xxxx, Batt: xxx
@@ -529,7 +529,7 @@ void updateSystemState()
529529

530530
//Dismount the SD card
531531
if (!sdCardWasOnline)
532-
endSD(true, false);
532+
endSD(true, false);
533533
}
534534
}
535535

@@ -1039,12 +1039,15 @@ void changeState(SystemState newState)
10391039
break;
10401040
}
10411041

1042-
//Timestamp the state change
1043-
// 1 2
1044-
//12345678901234567890123456
1045-
//YYYY-mm-dd HH:MM:SS.xxxrn0
1046-
struct tm timeinfo = rtc.getTimeStruct();
1047-
char s[30];
1048-
strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", &timeinfo);
1049-
Serial.printf(", %s.%03d\r\n", s, rtc.getMillis());
1042+
if (online.rtc)
1043+
{
1044+
//Timestamp the state change
1045+
// 1 2
1046+
//12345678901234567890123456
1047+
//YYYY-mm-dd HH:MM:SS.xxxrn0
1048+
struct tm timeinfo = rtc.getTimeStruct();
1049+
char s[30];
1050+
strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", &timeinfo);
1051+
Serial.printf(", %s.%03d\r\n", s, rtc.getMillis());
1052+
}
10501053
}

0 commit comments

Comments
 (0)