feat(comms): bidirectional device control — bells master switch, guard toggle, runtime tracking, system aggregate commands
Adds full bidirectional remote control across all major subsystems, establishing the device as the single source of truth for all settings. New firmware features (F-029 to F-037): - bells.enable / bells.disable: master ON/OFF for all playback and clock alerts (relay.test_output intentionally unaffected) - telemetry.set_guard_enabled: enable/disable thermal protection at runtime without touching thresholds - telemetry.set_max_loads: set bellMaxLoad per-bell or globally via command - Device runtime tracking: lifetime seconds flushed to SD every 10 min, boot log (up to 200 entries, rotating) written after first NTP sync - Total playback counter persisted to SD, increments on every play() - telemetry.get_metrics / telemetry.reset_metrics: new aggregate read + reset - system.get_config (replaces system.get_settings, old name still accepted), system.get_all (everything in one call), system.get_telemetry - log.get_config, mqtt.get_config, bells.get_config: new getters for previously write-only subsystems - network.status now includes ssid, mac, hostname - BellsHandler: new handler registered on CommandBus - LegacyAdapter updated with all new command mappings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,15 @@ Every feature — user-facing or significant internal mechanism — is listed he
|
||||
| F-026 | V2 playback `mode` field (`single` / `timed` / `interval` / `infinite`) | v2.0.4 | Stable |
|
||||
| F-027 | FileManager HTTPS removed — melody downloads over plain HTTP only | v2.0.4 | Stable |
|
||||
| F-028 | Logging level calibration — sane defaults + per-subsystem MQTT caps | v2.0.5 | Stable |
|
||||
| F-029 | Bell mechanism master ON/OFF switch (`bells.enable` / `bells.disable`) | v2.1.0 | Stable |
|
||||
| F-030 | Bell load guard ON/OFF switch (`telemetry.set_guard_enabled`) | v2.1.0 | Stable |
|
||||
| F-031 | Bell load guard threshold control per-bell (`telemetry.set_max_loads`) | v2.1.0 | Stable |
|
||||
| F-032 | Device runtime + boot tracking (SD-persisted, 10-min flush, boot log) | v2.1.0 | Stable |
|
||||
| F-033 | Total playback counter (SD-persisted lifetime count) | v2.1.0 | Stable |
|
||||
| F-034 | Telemetry aggregate commands (`telemetry.get_metrics`, `telemetry.reset_metrics`) | v2.1.0 | Stable |
|
||||
| F-035 | System aggregate commands (`system.get_config`, `system.get_all`, `system.get_telemetry`) | v2.1.0 | Stable |
|
||||
| F-036 | Per-subsystem config getters (`log.get_config`, `mqtt.get_config`, `bells.get_config`) | v2.1.0 | Stable |
|
||||
| F-037 | Network status extended (SSID + MAC in `network.status`) | v2.1.0 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -366,3 +375,120 @@ Subsystem: `src/ConfigManager/ConfigManager.hpp`, `src/Communication/Communicati
|
||||
`bellMaxLoad[i]` initialised to `500` (was `200`). This is the denominator used to calculate bell load percentage in telemetry reports. The old value caused false "overload" warnings on normal use patterns.
|
||||
|
||||
Subsystem: `src/Telemetry/Telemetry.cpp:begin()`
|
||||
|
||||
---
|
||||
|
||||
### F-029 — Bell mechanism master ON/OFF switch
|
||||
|
||||
A new `bellsEnabled` boolean in `GeneralConfig` (default `true`) gates all bell firing at the mechanism level. When disabled:
|
||||
- `BellEngine::start()` returns immediately without activating any relay outputs.
|
||||
- `Timekeeper::checkClockAlerts()` returns immediately without firing hour/half/quarter bells.
|
||||
- Manual relay tests (`relay.test_output`) are **not** affected — the guard is at the playback/alert layer, not the hardware layer.
|
||||
|
||||
Persisted to `settings/generalConfig.json` via `saveGeneralConfig()`.
|
||||
|
||||
Commands: `bells.enable` / `bells.disable` / `bells.get_config`
|
||||
Subsystems: `src/ConfigManager/ConfigManager.hpp`, `src/BellEngine/BellEngine.cpp`, `src/TimeKeeper/TimeKeeper.cpp`, `src/Communication/Handlers/BellsHandler/`
|
||||
|
||||
---
|
||||
|
||||
### F-030 — Bell load guard ON/OFF switch
|
||||
|
||||
`Telemetry::guardEnabled` (default `true`) allows the thermal protection system to be disabled at runtime via command without touching the thresholds. When disabled, load decay still runs for accurate reporting, but `forceStopCallback` is never triggered regardless of load levels.
|
||||
|
||||
Command: `telemetry.set_guard_enabled` `{ "enabled": true|false }`
|
||||
Not persisted — resets to `true` on reboot (deliberate: guard is a safety feature).
|
||||
Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-031 — Bell load guard threshold control
|
||||
|
||||
`telemetry.set_max_loads` allows setting `bellMaxLoad[i]` per-bell or globally via command at runtime. Two forms:
|
||||
- `{ "all": 500 }` — sets all 16 bells to the same threshold.
|
||||
- `{ "loads": { "0": 300, "3": 700 } }` — sets specific bells individually.
|
||||
|
||||
`telemetry.get_loads` now also returns `max_loads` and `guard_enabled` alongside the existing `loads`, `cooling_active`, `overloaded` fields.
|
||||
|
||||
Subsystem: `src/Telemetry/Telemetry.cpp`, `src/Communication/Handlers/TelemetryHandler/TelemetryHandler.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-032 — Device runtime and boot tracking
|
||||
|
||||
Three types of persistent records written to SD:
|
||||
|
||||
**Runtime (`/telemetry_runtime.json`):**
|
||||
- `lifetime_seconds`: cumulative powered-on time across all boots. Loaded at boot, flushed every 10 minutes. If the device reboots before 10 minutes, that session's contribution is lost (accepted trade-off to avoid SD wear).
|
||||
|
||||
**Boot log (`/telemetry_boot_log.json`):**
|
||||
- Rotating array of up to 200 boot entries, each with `ts` (Unix timestamp) and `boot` (sequential boot count).
|
||||
- Written after first NTP sync so the timestamp is real. Offline boots without NTP produce no entry.
|
||||
- Useful for diagnosing crash/reboot loops: a device that rebooted 25 times on one day is instantly visible.
|
||||
|
||||
Runtime flush is done inside `TelemetryTask` on a 10-minute timer (`RUNTIME_FLUSH_INTERVAL_MS`). Boot log is written from `ntpSyncTask` in `main.cpp`.
|
||||
|
||||
Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp`, `src/main.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-033 — Total playback counter
|
||||
|
||||
`Telemetry::totalPlaybackCount` (uint32_t) increments on every call to `Player::play()`. Persisted in `telemetry_runtime.json` alongside lifetime runtime. Readable via `telemetry.get_metrics` and `system.get_telemetry`. Resettable via `telemetry.reset_metrics` (also resets lifetime runtime).
|
||||
|
||||
Subsystem: `src/Telemetry/Telemetry.cpp`, `src/Player/Player.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-034 — Telemetry aggregate commands
|
||||
|
||||
New commands added to `TelemetryHandler`:
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `telemetry.get_metrics` | Returns `lifetime_runtime_seconds`, `session_runtime_seconds`, `total_playbacks`, `guard_enabled` |
|
||||
| `telemetry.reset_metrics` | Resets lifetime runtime and playback count to zero (persisted) |
|
||||
|
||||
Subsystem: `src/Communication/Handlers/TelemetryHandler/`
|
||||
|
||||
---
|
||||
|
||||
### F-035 — System aggregate commands
|
||||
|
||||
`system.get_settings` renamed to `system.get_config` (old name still accepted as backward-compat alias). Two new aggregate commands:
|
||||
|
||||
| Command | Returns |
|
||||
|---|---|
|
||||
| `system.get_config` | All user-configurable settings (full config dump) + `general` block with `bells_enabled`, `mqtt_enabled`, `ota_channel`, log levels |
|
||||
| `system.get_telemetry` | Strike counters, loads, max_loads, cooling, guard, runtime metrics, uptime, free heap — all in one call |
|
||||
| `system.get_all` | Everything: device identity + full config + telemetry snapshot + player status |
|
||||
|
||||
Reduces initialization round-trips from 8+ commands to 1.
|
||||
|
||||
Subsystem: `src/Communication/Handlers/SystemHandler/SystemHandler.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-036 — Per-subsystem config getters
|
||||
|
||||
Three new getter commands that were previously write-only:
|
||||
|
||||
| Command | Returns |
|
||||
|---|---|
|
||||
| `log.get_config` | `serial_level`, `sd_level`, `mqtt_level` |
|
||||
| `mqtt.get_config` | `enabled`, `host`, `port`, `user`, `use_ssl` |
|
||||
| `bells.get_config` | `bells_enabled`, `durations[16]`, `outputs[16]` |
|
||||
|
||||
Subsystem: `src/Communication/Handlers/LoggingHandler/`, `src/Communication/Handlers/MQTTHandler/`, `src/Communication/Handlers/BellsHandler/`
|
||||
|
||||
---
|
||||
|
||||
### F-037 — Network status extended
|
||||
|
||||
`network.status` now returns three additional fields alongside the existing `connected`, `ip`, `ap_mode`, `rssi`, `state`, `type`:
|
||||
|
||||
- `ssid`: currently connected WiFi network name (`WiFi.SSID()`)
|
||||
- `mac`: device MAC address (`WiFi.macAddress()`)
|
||||
- `hostname`: device hostname from `NetworkConfig`
|
||||
|
||||
Subsystem: `src/Communication/Handlers/NetworkHandler/NetworkHandler.cpp`
|
||||
|
||||
Reference in New Issue
Block a user