Skip to content

Commit 82f2fc9

Browse files
committed
Revert factoryReset
We need to remove settings and coordinate files
1 parent b83bce6 commit 82f2fc9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,28 @@ void factoryReset()
291291

292292
tasksStopUART2();
293293

294-
endSD(false, false); //Disable SD card use
295-
294+
//Attempt to write to file system. This avoids collisions with file writing from other functions like recordSystemSettingsToFile() and F9PSerialReadTask()
295+
if (settings.enableSD && online.microSD)
296+
{
297+
if (xSemaphoreTake(sdCardSemaphore, fatSemaphore_longWait_ms) == pdPASS)
298+
{
299+
//Remove this specific settings file. Don't remove the other profiles.
300+
sd->remove(settingsFileName);
301+
302+
sd->remove(stationCoordinateECEFFileName); //Remove station files
303+
sd->remove(stationCoordinateGeodeticFileName);
304+
305+
xSemaphoreGive(sdCardSemaphore);
306+
} //End sdCardSemaphore
307+
else
308+
{
309+
//An error occurs when a settings file is on the microSD card and it is not
310+
//deleted, as such the settings on the microSD card will be loaded when the
311+
//RTK reboots, resulting in failure to achieve the factory reset condition
312+
Serial.printf("sdCardSemaphore failed to yield, menuMain.ino line %d\r\n", __LINE__);
313+
}
314+
}
315+
296316
Serial.println("Formatting file system...");
297317
LittleFS.format();
298318

0 commit comments

Comments
 (0)