feat(Telemetry,FileManager,LoggingHandler): QA-to-shipping stats reset — telemetry.reset_boot_data + logs.clear
Console wants a "reset device stats before shipping" button for staff to clear QA-bench data (test reboots, debug log spam) without wiping actual device configuration. telemetry.reset_strikes and telemetry.reset_metrics already covered bell strikes and runtime/playback counters — this adds the two gaps: lifetime boot count + SD boot history, and SD debug logs. Deliberately does not touch FirmwareValidator's NVS namespace (rollback safety state, not history) or device identity NVS (serial/hw_family). Verified: pio run on all four board variants.
This commit is contained in:
@@ -66,6 +66,7 @@ Every feature — user-facing or significant internal mechanism — is listed he
|
||||
| F-054 | Console Health tab support — `free_heap` on heartbeat + `ping` round-trip timestamp echo | v2.1.4 | Stable |
|
||||
| F-055 | Fix: heap-exhaustion abort() under rapid MQTT command bursts — free-heap guard on publish + command intake | v2.1.4 | Stable |
|
||||
| F-056 | Diagnostics report — CPU temperature, WiFi reconnects, OTA state, stack high-water mark, published automatically every 5 min + on-demand via `telemetry.get_diagnostics` | v2.1.5 | Stable |
|
||||
| F-057 | QA-to-shipping stats reset — `telemetry.reset_boot_data` (lifetime boot count + SD boot log) and `logs.clear` (SD debug logs) | v2.1.6 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -900,3 +901,35 @@ Only temperature needed the local-sampling treatment; over-engineering a samplin
|
||||
**Scope note (RTC/SD independence):** unlike F-054's `ping` addition, none of these four metrics depend on `#if HAS_RTC` or SD-card presence — `temperatureRead()`, `uxTaskGetStackHighWaterMark()`, WiFi events, and `OTAManager` are all available on every board variant. Verified via `pio run` on all four environments (`vesper-std-v1`, `agnus-v1`, `agnus-mini-v1`, `bespoke-rs485-v1`).
|
||||
|
||||
Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp`, `src/Networking/Networking.hpp`, `src/Networking/Networking.cpp`, `src/OTAManager/OTAManager.hpp`, `src/OTAManager/OTAManager.cpp`, `src/HealthMonitor/HealthMonitor.cpp`, `src/Communication/CommunicationRouter/CommunicationRouter.hpp`, `src/Communication/CommunicationRouter/CommunicationRouter.cpp`, `src/Communication/Handlers/TelemetryHandler/TelemetryHandler.hpp`, `src/Communication/Handlers/TelemetryHandler/TelemetryHandler.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-057 — QA-to-shipping stats reset: `telemetry.reset_boot_data` + `logs.clear`
|
||||
|
||||
Console-requested: a "reset device stats before shipping to customer" button, to clear data accumulated on the bench during QA (bell fires, melody playback, deliberate reboots) without wiping the device's actual configuration. Two commands cover the pieces that had no existing reset path — `telemetry.reset_strikes` (bell strikes) and `telemetry.reset_metrics` (runtime seconds + playback count) already existed and needed no changes.
|
||||
|
||||
**1. `telemetry.reset_boot_data`.** [Telemetry.hpp](../../src/Telemetry/Telemetry.hpp)/[.cpp](../../src/Telemetry/Telemetry.cpp) add `resetBootData()`, called by the new command in [TelemetryHandler.cpp](../../src/Communication/Handlers/TelemetryHandler/TelemetryHandler.cpp). Does two things:
|
||||
- Zeroes the lifetime boot counter — both in RAM (`lifetimeBootCount`) and persisted (`nvs_set_u32(_bootNvsHandle, "lifetime_boots", 0)` + `nvs_commit()`, namespace `vesper_boot`).
|
||||
- Deletes `/telemetry_boot_log.json` (the SD-side rotating boot history) via `FileManager::deleteFile()`. Best-effort — a missing SD card or FileManager doesn't fail the command, since the NVS counter is the authoritative piece.
|
||||
|
||||
**Explicitly does NOT touch `FirmwareValidator`'s NVS namespace (`fw_validator`)** — `boot_count` there is validation-cycle/rollback-safety bookkeeping (boots since the current OTA slot was flashed), not a customer-facing "how many times has this device rebooted" stat. Wiping it would be pointless (not history) and could force an unwanted re-validation cycle. See the boot-tracking table in F-052 for why these two counters are kept structurally separate — this reset only ever touches the one meant to represent device history.
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "telemetry.reset_boot_data", "contents": {} }
|
||||
```
|
||||
Response: `{ "status": "SUCCESS", "type": "telemetry.reset_boot_data", "message": "Lifetime boot count and SD boot log reset" }` — or an error if the NVS write itself failed (SD-only failure is silent/best-effort, not surfaced as an error).
|
||||
|
||||
**2. `logs.clear`.** [FileManager.hpp](../../src/FileManager/FileManager.hpp)/[.cpp](../../src/FileManager/FileManager.cpp) add `deleteAllLogFiles(logDir)` — lists every file under `/logs` (the day-rotated SD debug log directory) via the same `SD.open()`/`openNextFile()` iteration `pruneLogDirectory()` already uses, then `SD.remove()`s each one. [LoggingHandler.cpp](../../src/Communication/Handlers/LoggingHandler/LoggingHandler.cpp) wires this to a new `logs.clear` command.
|
||||
|
||||
**Not the same thing as automatic day-rotation pruning** (`FileManager::pruneLogDirectory()`, called from inside `appendLogLine()`) — that only trims the *oldest* files once the directory exceeds `SD_LOG_MAX_TOTAL_BYTES` (512KB), during normal operation, and is deliberately silent (no `LOG_*` calls, to avoid re-entering the SD log write path it's called from). `logs.clear` is a full wipe, invoked only via explicit command, and logs normally (`LOG_WARNING`) since it isn't called from that same nested write path.
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "logs.clear", "contents": {} }
|
||||
```
|
||||
Response: `{ "status": "SUCCESS", "type": "logs.clear", "data": { "deleted": 4 } }` — `deleted` is the file count actually removed. Returns an error only when no SD card/FileManager is present on this board variant (same degrade-gracefully pattern as `logs.list`/`logs.download`).
|
||||
|
||||
**What this feature does NOT reset** (by design — see the console-side plan for the full picture): `strikeCounters`/runtime seconds/playback count (already covered by the two pre-existing commands), NVS `device_id` (factory identity, never touched by any reset), NVS `fw_validator` (rollback safety state, not history), NVS `rf` (RF remote pairings — customer configuration, not QA noise), and anything `system.factory_reset` already covers (network/bell/clock config, melodies — a different, much broader operation).
|
||||
|
||||
Verified: `pio run` on all four environments.
|
||||
|
||||
Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp`, `src/FileManager/FileManager.hpp`, `src/FileManager/FileManager.cpp`, `src/Communication/Handlers/TelemetryHandler/TelemetryHandler.hpp`, `src/Communication/Handlers/TelemetryHandler/TelemetryHandler.cpp`, `src/Communication/Handlers/LoggingHandler/LoggingHandler.hpp`, `src/Communication/Handlers/LoggingHandler/LoggingHandler.cpp`
|
||||
|
||||
Reference in New Issue
Block a user