feat(firmware): log reason before FATAL hang loops

Two FATAL while(true) hangs in main.cpp (config load fail, camera init
fail) previously relied on the hardware watchdog to reboot the device,
leaving the cause invisible beyond a generic TWDT reset reason. Now
each path logs EVT_REBOOT with REBOOT_FATAL_CONFIG or REBOOT_FATAL_CAMERA
before hanging, so the next heartbeat's recent_events surfaces which
branch hung. Server-side decoder updated for the two new enum values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 14:03:57 -07:00
parent 2d95069bd1
commit d943b3df5a
3 changed files with 6 additions and 0 deletions

View File

@@ -169,6 +169,7 @@ void setup() {
if (!config_load(g_cfg)) {
Serial.println("FATAL: device_id/location_id/hmac_secret not provisioned");
event_log_write(EVT_REBOOT, REBOOT_FATAL_CONFIG, 0);
while (true) { delay(500); led_set(!digitalRead(LED_PIN)); } // fast blink
}
@@ -203,6 +204,7 @@ void setup() {
if (!camera_init()) {
Serial.println("FATAL: camera init failed");
event_log_write(EVT_REBOOT, REBOOT_FATAL_CAMERA, 0);
while (true) delay(1000);
}