Skip to content

Commit

Permalink
Allow resetting WiFi only
Browse files Browse the repository at this point in the history
  • Loading branch information
lptr committed Nov 9, 2024
1 parent a03ee48 commit a5d0156
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions main/devices/Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,12 @@ class Device {
public:
Device() {
kernel.switches.onReleased("factory-reset", deviceDefinition.bootPin, SwitchMode::PullUp, [this](const Switch&, milliseconds duration) {
if (duration >= 5s) {
if (duration >= 15s) {
Log.info("Factory reset triggered after %lld ms", duration.count());
kernel.performFactoryReset();
kernel.performFactoryReset(true);
} else if (duration >= 5s) {
Log.info("WiFi reset triggered after %lld ms", duration.count());
kernel.performFactoryReset(false);
}
});

Expand Down
15 changes: 10 additions & 5 deletions main/kernel/Kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Kernel {
fUpdate.close();
}

void performFactoryReset() {
void performFactoryReset(bool completeReset) {
Log.printlnToSerial("Performing factory reset");

statusLed.turnOn();
Expand All @@ -117,15 +117,20 @@ class Kernel {
delay(1000);
statusLed.turnOn();

Log.printlnToSerial(" - Deleting the file system...");
fs.reset();
if (completeReset) {
delay(1000);
statusLed.turnOff();
delay(1000);
statusLed.turnOn();

Log.printlnToSerial(" - Clearing NVS...");
Log.printlnToSerial(" - Deleting the file system...");
fs.reset();
}

Log.printlnToSerial(" - Clearing NVS...");
nvs_flash_erase();

Log.printlnToSerial(" - Restarting...");

ESP.restart();
}

Expand Down

0 comments on commit a5d0156

Please sign in to comment.