File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ void DataStore::begin() {
6565
6666#if defined(ESP32)
6767 #include < SPIFFS.h>
68+ #include < nvs_flash.h>
6869#elif defined(RP2040_PLATFORM)
6970 #include < LittleFS.h>
7071#elif defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
@@ -172,7 +173,9 @@ bool DataStore::formatFileSystem() {
172173#elif defined(RP2040_PLATFORM)
173174 return LittleFS.format ();
174175#elif defined(ESP32)
175- return ((fs::SPIFFSFS *)_fs)->format ();
176+ bool fs_success = ((fs::SPIFFSFS *)_fs)->format ();
177+ esp_err_t nvs_err = nvs_flash_erase (); // no need to reinit, will be done by reboot
178+ return fs_success && (nvs_err == ESP_OK);
176179#else
177180 #error "need to implement format()"
178181#endif
Original file line number Diff line number Diff line change @@ -1613,6 +1613,10 @@ void MyMesh::handleCmdFrame(size_t len) {
16131613 writeErrFrame (ERR_CODE_ILLEGAL_ARG); // invalid stats sub-type
16141614 }
16151615 } else if (cmd_frame[0 ] == CMD_FACTORY_RESET && memcmp (&cmd_frame[1 ], " reset" , 5 ) == 0 ) {
1616+ if (_serial) {
1617+ MESH_DEBUG_PRINTLN (" Factory reset: disabling serial interface to prevent reconnects (BLE/WiFi)" );
1618+ _serial->disable (); // Phone app disconnects before we can send OK frame so it's safe here
1619+ }
16161620 bool success = _store->formatFileSystem ();
16171621 if (success) {
16181622 writeOKFrame ();
You can’t perform that action at this time.
0 commit comments