Skip to content

Commit

Permalink
ESP32 Factory Reset (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
unlogisch04 authored Jun 28, 2022
1 parent 37d95bf commit 91ef1f8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/serial/serialcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <CmdCallback.hpp>
#include "GlobalVars.h"

#if ESP32
#include "nvs_flash.h"
#endif

namespace SerialCommands {
SlimeVR::Logging::Logger logger("SerialCommands");

Expand Down Expand Up @@ -78,10 +82,20 @@ namespace SerialCommands {

WiFi.disconnect(true); // Clear WiFi credentials
#if ESP8266
ESP.eraseConfig(); // Clear ESP config
ESP.eraseConfig(); // Clear ESP config
#elif ESP32
nvs_flash_erase();
#else
// TODO: Implement eraseConfig for other boards
#warning SERIAL COMMAND FACTORY RESET NOT SUPPORTED
logger.info("FACTORY RESET NOT SUPPORTED");
return;
#endif

#if defined(WIFI_CREDS_SSID) && defined(WIFI_CREDS_PASSWD)
#warning FACTORY RESET does not clear your hardcoded WiFi credentials!
logger.warn("FACTORY RESET does not clear your hardcoded WiFi credentials!");
#endif

delay(3000);
ESP.restart();
}
Expand Down

0 comments on commit 91ef1f8

Please sign in to comment.