A shared device state
An ESP32-C6 can observe BLE, parse Wi-Fi frames, drive a display, stream browser updates, and log to storage. Each interface needs a consistent view of device activity.
Detection produces a stream of domain events that update a bounded state model. The LCD and browser render this shared state without managing it independently.
Explicit state limits
Embedded contact history needs explicit capacity, expiry, and replacement rules to stay within available memory.
ccontact_upsert(&(contact_update_t) {
.kind = CONTACT_REMOTE_ID,
.identity = frame->uas_id,
.rssi = frame->rssi,
.seen_at_ms = now_ms,
});
The reducer owns deduplication and expiry. Interfaces receive snapshots, which makes a 500 ms WebSocket push and a 30 Hz LCD refresh coexist without coupling the radio task to either one.
Report subsystem status
Boot stages, scan health, storage state, GPS permissions, and stale contacts require explicit status reporting alongside positive detections. When a subsystem is waiting, the interface should identify the dependency.
- Use state names that operators can interpret.
- Limit history size and display expiry information.
- Log state transitions without excessive repeated entries.
- Define recovery steps for each failure state.
Defining these states during development keeps diagnostic behavior consistent as the firmware expands.