@@ -37,9 +37,9 @@ void menuMain()
3737 systemPrint (" ** Bluetooth broadcasting as: " );
3838 systemPrint (deviceName);
3939 systemPrintln (" **" );
40- #else // COMPILE_BT
40+ #else // COMPILE_BT
4141 systemPrintln (" ** Bluetooth Not Compiled **" );
42- #endif // COMPILE_BT
42+ #endif // COMPILE_BT
4343
4444 systemPrintln (" Menu: Main" );
4545
@@ -58,25 +58,25 @@ void menuMain()
5858
5959#ifdef COMPILE_WIFI
6060 systemPrintln (" 6) Configure WiFi" );
61- #else // COMPILE_WIFI
61+ #else // COMPILE_WIFI
6262 systemPrintln (" 6) **WiFi Not Compiled**" );
63- #endif // COMPILE_WIFI
63+ #endif // COMPILE_WIFI
6464
6565#ifdef COMPILE_ETHERNET
6666 if (HAS_ETHERNET)
6767 {
6868 systemPrintln (" e) Configure Ethernet" );
6969 systemPrintln (" n) Configure NTP" );
7070 }
71- #endif // COMPILE_ETHERNET
71+ #endif // COMPILE_ETHERNET
7272
7373 systemPrintln (" p) Configure User Profiles" );
7474
7575#ifdef COMPILE_ESPNOW
7676 systemPrintln (" r) Configure Radios" );
77- #else // COMPILE_ESPNOW
77+ #else // COMPILE_ESPNOW
7878 systemPrintln (" r) **ESP-Now Not Compiled**" );
79- #endif // COMPILE_ESPNOW
79+ #endif // COMPILE_ESPNOW
8080
8181 if (online.lband == true )
8282 systemPrintln (" P) Configure PointPerfect" );
@@ -119,7 +119,7 @@ void menuMain()
119119#ifdef COMPILE_ESPNOW
120120 else if (incoming == ' r' )
121121 menuRadio ();
122- #endif // COMPILE_ESPNOW
122+ #endif // COMPILE_ESPNOW
123123 else if (incoming == ' f' )
124124 menuFirmware ();
125125 else if (incoming == ' b' )
@@ -262,7 +262,7 @@ void menuUserProfiles()
262262 if (SD_MMC.exists (settingsFileName))
263263 SD_MMC.remove (settingsFileName);
264264 }
265- #endif // COMPILE_SD_MMC
265+ #endif // COMPILE_SD_MMC
266266 }
267267
268268 recordProfileNumber (0 ); // Move to Profile1
@@ -334,18 +334,22 @@ void changeProfileNumber(byte newProfileNumber)
334334}
335335
336336// Erase all settings. Upon restart, unit will use defaults
337- void factoryReset ()
337+ void factoryReset (bool alreadyHasSemaphore )
338338{
339339 displaySytemReset (); // Display friendly message on OLED
340340
341341 tasksStopUART2 ();
342342
343+ Serial.println (" remove old files" );
344+
343345 // Attempt to write to file system. This avoids collisions with file writing from other functions like
344- // recordSystemSettingsToFile() and F9PSerialReadTask() if (settings.enableSD && online.microSD) //Don't check
345- // settings.enableSD - it could be corrupt
346+ // recordSystemSettingsToFile() and F9PSerialReadTask() if (settings.enableSD && online.microSD)
347+ // Don't check settings.enableSD - it could be corrupt
346348 if (online.microSD )
347349 {
348- if (xSemaphoreTake (sdCardSemaphore, fatSemaphore_longWait_ms) == pdPASS)
350+ Serial.println (" 2 - remove old files" );
351+
352+ if (alreadyHasSemaphore == true || xSemaphoreTake (sdCardSemaphore, fatSemaphore_longWait_ms) == pdPASS)
349353 {
350354 if (USE_SPI_MICROSD)
351355 {
@@ -363,16 +367,20 @@ void factoryReset()
363367 SD_MMC.remove (stationCoordinateECEFFileName); // Remove station files
364368 SD_MMC.remove (stationCoordinateGeodeticFileName);
365369 }
366- #endif // COMPILE_SD_MMC
370+ #endif // COMPILE_SD_MMC
367371
368372 xSemaphoreGive (sdCardSemaphore);
369373 } // End sdCardSemaphore
370374 else
371375 {
376+ char semaphoreHolder[50 ];
377+ getSemaphoreFunction (semaphoreHolder);
378+
372379 // An error occurs when a settings file is on the microSD card and it is not
373380 // deleted, as such the settings on the microSD card will be loaded when the
374381 // RTK reboots, resulting in failure to achieve the factory reset condition
375- systemPrintf (" sdCardSemaphore failed to yield, menuMain.ino line %d\r\n " , __LINE__);
382+ log_d (" sdCardSemaphore failed to yield, held by %s, menuMain.ino line %d\r\n " , semaphoreHolder,
383+ __LINE__);
376384 }
377385 }
378386
@@ -512,5 +520,5 @@ void menuRadio()
512520 radioStart ();
513521
514522 clearBuffer (); // Empty buffer of any newline chars
515- #endif // COMPILE_ESPNOW
523+ #endif // COMPILE_ESPNOW
516524}
0 commit comments