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:
@@ -14,7 +14,8 @@ std::vector<String> TelemetryHandler::commands() const {
|
||||
"telemetry.get_strikes", "telemetry.reset_strikes", "telemetry.get_loads",
|
||||
"telemetry.set_max_loads", "telemetry.set_guard_enabled",
|
||||
"telemetry.get_metrics", "telemetry.reset_metrics",
|
||||
"telemetry.get_boot_history", "telemetry.get_diagnostics"
|
||||
"telemetry.get_boot_history", "telemetry.get_diagnostics",
|
||||
"telemetry.reset_boot_data"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@ CommandResult TelemetryHandler::execute(const CommandEnvelope& envelope) {
|
||||
if (envelope.command == "telemetry.reset_metrics") return handleResetMetrics(envelope);
|
||||
if (envelope.command == "telemetry.get_boot_history") return handleGetBootHistory(envelope);
|
||||
if (envelope.command == "telemetry.get_diagnostics") return handleGetDiagnostics(envelope);
|
||||
if (envelope.command == "telemetry.reset_boot_data") return handleResetBootData(envelope);
|
||||
return CommandResult::err(envelope.command, "Unknown telemetry command");
|
||||
}
|
||||
|
||||
@@ -162,3 +164,17 @@ CommandResult TelemetryHandler::handleGetDiagnostics(const CommandEnvelope& e) {
|
||||
|
||||
return CommandResult::ok("telemetry.get_diagnostics", doc);
|
||||
}
|
||||
|
||||
CommandResult TelemetryHandler::handleResetBootData(const CommandEnvelope& e) {
|
||||
// Zeroes the lifetime boot counter (NVS) and deletes the SD boot history
|
||||
// log — used before shipping a device to a customer, to clear reboot
|
||||
// counts accumulated during QA/bench testing. Console-side history in
|
||||
// device_boot_events (Postgres) is a separate reset, not touched here.
|
||||
bool ok = _telemetry.resetBootData();
|
||||
if (!ok) {
|
||||
return CommandResult::err("telemetry.reset_boot_data",
|
||||
"Failed to reset lifetime boot count in NVS");
|
||||
}
|
||||
LOG_WARNING(TAG, "Boot data reset via telemetry.reset_boot_data command");
|
||||
return CommandResult::ok("telemetry.reset_boot_data", "Lifetime boot count and SD boot log reset");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user