Update factory reset procedure in README and main.cpp for clarity and functionality
This commit is contained in:
@@ -79,12 +79,15 @@ After connecting, the device is reachable at:
|
||||
|
||||
### Factory reset (forgot password)
|
||||
|
||||
If you lose the web UI password, hold the **BOOT button** (GPIO0) for 3 seconds during startup. The firmware resets all settings to factory defaults **except** meter pin assignments and calibration (maxDuty), which are preserved. On acknowledgement, all connected meters sweep 0→100→0.
|
||||
If you lose the web UI password, **reset the device 5 times in quick succession** (press the EN button or cycle power 5× within a few seconds — before the boot completes). The firmware resets all settings to factory defaults **except** meter pin assignments and calibration (maxDuty), which are preserved. On acknowledgement, all connected meters sweep 0→100→0.
|
||||
|
||||
Serial output confirms the reset:
|
||||
Serial output shows the progress:
|
||||
|
||||
```
|
||||
[BOOT] BOOT button held, hold 3s for factory reset...
|
||||
[BOOT] reset count 1/5
|
||||
[BOOT] reset count 2/5
|
||||
...
|
||||
[BOOT] reset count 5/5, triggering factory reset
|
||||
[BOOT] factory reset triggered!
|
||||
...
|
||||
[BOOT] factory reset complete, restarting...
|
||||
@@ -236,4 +239,4 @@ Config is stored as JSON in LittleFS at `/config.json`.
|
||||
}
|
||||
```
|
||||
|
||||
The file is written by the web UI and should not need manual editing. To reset to factory defaults (keeping pin/calibration), hold the BOOT button for 3 seconds at startup. To erase everything including flash, use `pio run --target erase`.
|
||||
The file is written by the web UI and should not need manual editing. To reset to factory defaults (keeping pin/calibration), reset the device 5 times in quick succession. To erase everything including flash, use `pio run --target erase`.
|
||||
|
||||
+19
-12
@@ -613,7 +613,7 @@ static void startServer() {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Factory reset (hold BOOT button 3s at startup)
|
||||
// Factory reset (rapid reset 5× within a few seconds)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void factoryReset() {
|
||||
@@ -699,19 +699,25 @@ static void factoryReset() {
|
||||
}
|
||||
|
||||
static void checkFactoryReset() {
|
||||
pinMode(0, INPUT_PULLUP);
|
||||
delay(10);
|
||||
if (digitalRead(0) == LOW) {
|
||||
Serial.println("[BOOT] BOOT button held, hold 3s for factory reset...");
|
||||
unsigned long start = millis();
|
||||
while (millis() - start < 3000) {
|
||||
delay(50);
|
||||
if (digitalRead(0) != LOW) {
|
||||
Serial.println("[BOOT] factory reset aborted (button released)");
|
||||
const int THRESHOLD = 5;
|
||||
int count = 0;
|
||||
File f = LittleFS.open("/reset_count", "r");
|
||||
if (f) {
|
||||
count = f.parseInt();
|
||||
f.close();
|
||||
}
|
||||
count++;
|
||||
if (count >= THRESHOLD) {
|
||||
LittleFS.remove("/reset_count");
|
||||
Serial.printf("[BOOT] reset count %d, triggering factory reset\n", count);
|
||||
factoryReset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
factoryReset();
|
||||
f = LittleFS.open("/reset_count", "w");
|
||||
if (f) {
|
||||
f.print(count);
|
||||
f.close();
|
||||
Serial.printf("[BOOT] reset count %d/%d\n", count, THRESHOLD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,6 +760,7 @@ void setup() {
|
||||
startMDNS();
|
||||
mqttReconnectAt = 0;
|
||||
|
||||
LittleFS.remove("/reset_count");
|
||||
Serial.printf("[BOOT] ready at http://%s.local or http://%s\n",
|
||||
hostname, WiFi.localIP().toString().c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user