Skip to content

Commit 4221d4f

Browse files
committed
Update files (log and settings) with date/time.
1 parent f86db6b commit 4221d4f

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
Text menu interactions
2525
2626
Main Menu (Display MAC address / broadcast name):
27-
(Done) GNSS - Configure measurement rate, enable/disable common NMEA sentences, RAWX, SBAS
28-
(Done) Log - Log to SD
27+
(Done) GNSS - Configure measurement rate, SBAS
28+
(Done) Log - Control messages logged to SD
29+
(Done) Broadcast - Control messages sent over BT SPP
2930
(Done) Base - Enter fixed coordinates, survey-in settings, WiFi/Caster settings,
3031
(Done) Ports - Configure Radio and Data port baud rates
3132
(Done) Test menu
3233
(Done) Firmware upgrade menu
3334
Enable various debug outputs sent over BT
3435
35-
Test file date/time updates
36-
Test firmware loading
3736
Add blinking log file icon
3837
*/
3938

@@ -347,13 +346,18 @@ void updateLogs()
347346

348347
int bytesWritten = ubxFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
349348

349+
if (settings.frequentFileAccessTimestamps == true)
350+
updateDataFileAccess(&ubxFile); // Update the file access time & date
351+
350352
//Force sync every 1000ms
351353
if (millis() - lastUBXLogSyncTime > 1000)
352354
{
353355
lastUBXLogSyncTime = millis();
354356
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Blink LED to indicate logging activity
355357
ubxFile.sync();
356358
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Return LED to previous state
359+
360+
updateDataFileAccess(&ubxFile); // Update the file access time & date
357361
}
358362

359363
xSemaphoreGive(xFATSemaphore);
@@ -393,14 +397,16 @@ void updateRTC()
393397
{
394398
if (i2cGNSS.getConfirmedDate() == true && i2cGNSS.getConfirmedTime() == true)
395399
{
396-
//For the ESP32 SD library, the date/time stamp of files is set using the internal system time
400+
//Set the internal system time
397401
//This is normally set with WiFi NTP but we will rarely have WiFi
398402
rtc.setTime(i2cGNSS.getSecond(), i2cGNSS.getMinute(), i2cGNSS.getHour(), i2cGNSS.getDay(), i2cGNSS.getMonth(), i2cGNSS.getYear()); // 17th Jan 2021 15:24:30
399403

400404
online.rtc = true;
401405

402406
Serial.print(F("System time set to: "));
403407
Serial.println(rtc.getTime("%B %d %Y %H:%M:%S")); //From ESP32Time library example
408+
409+
recordSystemSettingsToFile(); //This will re-record the setting file with current date/time.
404410
}
405411
}
406412
}

Firmware/RTK_Surveyor/menuLog.ino

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ void beginLogging()
166166
i2cGNSS.checkUblox();
167167

168168
//Based on GPS data/time, create a log file in the format SFE_Surveyor_YYMMDD_HHMMSS.ubx
169-
bool haveLogTime = false;
169+
bool timeValid = false;
170170
if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true) //Will pass if ZED's RTC is reporting (regardless of GNSS fix)
171-
haveLogTime = true;
171+
timeValid = true;
172172
if (i2cGNSS.getConfirmedTime() == true && i2cGNSS.getConfirmedDate() == true) //Requires GNSS fix
173-
haveLogTime = true;
173+
timeValid = true;
174174

175-
if (haveLogTime == false)
175+
if (timeValid == false)
176176
{
177177
Serial.println(F("beginLoggingUBX: No date/time available. No file created."));
178178
delay(1000); //Give the receiver time to get a lock
@@ -224,7 +224,13 @@ void beginLogging()
224224
//Updates the timestemp on a given data file
225225
void updateDataFileAccess(SdFile *dataFile)
226226
{
227-
if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true)
227+
bool timeValid = false;
228+
if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true) //Will pass if ZED's RTC is reporting (regardless of GNSS fix)
229+
timeValid = true;
230+
if (i2cGNSS.getConfirmedTime() == true && i2cGNSS.getConfirmedDate() == true) //Requires GNSS fix
231+
timeValid = true;
232+
233+
if (timeValid == true)
228234
{
229235
//Update the file access time
230236
dataFile->timestamp(T_ACCESS, i2cGNSS.getYear(), i2cGNSS.getMonth(), i2cGNSS.getDay(), i2cGNSS.getHour(), i2cGNSS.getMinute(), i2cGNSS.getSecond());
@@ -235,7 +241,13 @@ void updateDataFileAccess(SdFile *dataFile)
235241

236242
void updateDataFileCreate(SdFile *dataFile)
237243
{
238-
if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true)
244+
bool timeValid = false;
245+
if (i2cGNSS.getTimeValid() == true && i2cGNSS.getDateValid() == true) //Will pass if ZED's RTC is reporting (regardless of GNSS fix)
246+
timeValid = true;
247+
if (i2cGNSS.getConfirmedTime() == true && i2cGNSS.getConfirmedDate() == true) //Requires GNSS fix
248+
timeValid = true;
249+
250+
if (timeValid == true)
239251
{
240252
//Update the file create time
241253
dataFile->timestamp(T_CREATE, i2cGNSS.getYear(), i2cGNSS.getMonth(), i2cGNSS.getDay(), i2cGNSS.getHour(), i2cGNSS.getMinute(), i2cGNSS.getSecond());

Firmware/RTK_Surveyor/nvm.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ void recordSystemSettingsToFile()
7878
Serial.println(F("Failed to create settings file"));
7979
return;
8080
}
81+
if (online.gnss)
82+
updateDataFileCreate(&settingsFile); // Update the file to create time & date
8183

8284
settingsFile.println("sizeOfSettings=" + (String)settings.sizeOfSettings);
8385
settingsFile.println("rtkIdentifier=" + (String)settings.rtkIdentifier);
@@ -126,6 +128,9 @@ void recordSystemSettingsToFile()
126128
settingsFile.println("log.rawx=" + (String)settings.log.rawx);
127129
settingsFile.println("log.sfrbx=" + (String)settings.log.sfrbx);
128130

131+
if (online.gnss)
132+
updateDataFileAccess(&settingsFile); // Update the file access time & date
133+
129134
settingsFile.close();
130135

131136
xSemaphoreGive(xFATSemaphore);

0 commit comments

Comments
 (0)