Logging::log() previously ran AsyncMqttClient::publish() and SD file writes synchronously on whatever task called LOG_*. Both are variable-depth, stack-hungry operations, and this is what let TelemetryTask's 4096B stack silently absorb enough nested cost to overflow its canary (see feature-catalog.md F-051). Serial output stays synchronous (cheap, and must reflect true event order for crash debugging). MQTT/SD-bound messages are now copied into a fixed-size LogQueueItem (256-byte message cap, audited against real LOG_* call sites — worst case ~150-180 chars, comfortable margin) and handed via non-blocking xQueueSend to a lazily-created LoggingTask, which performs the actual publish/write on its own 4096B stack. A full queue drops the line rather than blocking the caller. Queue+task creation is spinlock-guarded against concurrent first-callers. This removes the stack-nesting risk for every current and future task that logs, not just Telemetry/HealthMonitor — closing the broader risk flagged in F-051 for OutputManager, TimeKeeper, MQTTDriver's own tasks, and Networking's netRecon. Verified via pio run: RAM impact negligible (62980 vs 62956 bytes). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
41 KiB
Feature Catalog
This is the single source of truth for "what does this device actually do?"
Every feature — user-facing or significant internal mechanism — is listed here.
Rule: every new feature or observable behaviour change gets an entry before or with its commit.
Index
| ID | Feature | Since | Status |
|---|---|---|---|
| F-001 | Relay-driven melody playback | pre-v2 | Stable |
| F-002 | Built-in melody library (PROGMEM) | pre-v2 | Stable |
| F-003 | SD-card melody download & storage | pre-v2 | Stable |
| F-004 | MQTT transport | pre-v2 | Stable |
| F-005 | WebSocket transport | pre-v2 | Stable |
| F-006 | UART/Serial transport | pre-v2 | Stable |
| F-007 | HTTP / AsyncWebServer transport | pre-v2 | Stable |
| F-008 | MQTT heartbeat (retained, 30 s) | v130 | Stable |
| F-009 | SemVer firmware versioning | v2.0.0 | Stable |
| F-010 | OTA update (FastAPI backend, safe-mode boot check) | v2.0.1 | Stable |
| F-011 | MQTT dynamic auth (HMAC-SHA256 device password) | v2.x | Stable |
| F-012 | HAL variant system (multi-board build flags) | v2.x | Stable |
| F-013 | RF Remote subsystem (HAS_RF variant) | v2.x | Stable |
| F-014 | NVS device-identity migration (device_uid/hw_type/hw_version → serial/hw_family/hw_revision) |
v2.x | Stable |
| F-015 | Two-tier factory reset (5 s WiFi wipe / 10 s full reset) | v2.0.3 | Stable |
| F-016 | WiFi credential fallback chain (saved → failsafe → portal) | v2.0.3 | Stable |
| F-017 | SettingsWebServer (captive-portal config UI) | v2.0.3 | Stable |
| F-018 | Built-in melody builtin_* UID aliases (backward compat) |
v2.0.3 | Stable |
| F-019 | NTP sync — fetch UTC, apply stored offsets manually | v2.0.3 | Stable |
| F-020 | Command envelope version default changed to v1 | v2.0.3 | Stable |
| F-021 | RelayHandler v1/v2 dual-format compatibility | v2.0.3 | Stable |
| F-022 | Player speed guard (zero-speed defaults to 300 ms) | v2.0.3 | Stable |
| F-023 | Telemetry bell max load default raised to 500 | v2.0.3 | Stable |
| F-024 | V1 playback segment_duration fix (single-segment mode) | v2.0.4 | Stable |
| F-025 | V2 playback command namespace (playback.play / playback.stop) |
v2.0.4 | Stable |
| 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 |
| F-038 | Bell test fire commands (relay.test_bell / relay.test_batch) |
v2.1.0 | Stable |
| F-039 | Clock output test fire commands (clock.test_c1 / clock.test_c2) |
v2.1.0 | Stable |
| F-040 | Combined relay config command (relay.set_config) |
v2.1.1 | Stable |
| F-041 | Output numbering convention enforced — 1-based everywhere except raw chip pin | v2.1.1 | Stable |
| F-042 | Combined clock config commands (clock.set_config / clock.set_alerts_config) |
v2.1.1 | Stable |
| F-043 | network.info expanded — subnet, MAC, hostname, SSID, connection type |
v2.1.1 | Stable |
| F-044 | network.status slimmed — pure runtime state (connected, state, RSSI, uptime, AP mode) |
v2.1.1 | Stable |
| F-045 | Day-rotated SD log files with size cap (/logs/YYYY-MM-DD.log) |
v2.1.2 | Stable |
| F-046 | Boot reset-reason capture, routed to alerts (fault) or info (expected) | v2.1.2 | Stable |
| F-047 | Per-subsystem MQTT log rate limiting (token bucket + drop summary) | v2.1.2 | Stable |
| F-048 | SD log retrieval commands (logs.list / logs.download) |
v2.1.2 | Stable |
| F-049 | firmware.status rollback safety-net diagnostics (retry/failure counts, backup partition) |
v2.1.2 | Stable |
| F-050 | SD log lines prefixed with wall-clock date/time + uptime | v2.1.2 | Stable |
| F-051 | Fix: TelemetryTask/HealthMonitor stack overflow — stack bump + deferred MQTT/SD logging queue | v2.0.3 | Stable |
Feature Details
F-001 — Relay-driven melody playback
The core function of the device. The Player subsystem reads a sequence of 16-bit bitmasks (one per step) from either a .bsm file on SD or the built-in PROGMEM library. Each bit maps to a relay output (bell). Relays fire at a configurable speed (ms per step).
Key config: speed (ms/step), note_assignments[16] (relay index per note), total_duration, continuous_loop.
Subsystem: src/Player/Player.cpp
F-002 — Built-in melody library (PROGMEM)
A set of hardcoded melodies stored in flash (PROGMEM) inside src/BuiltInMelodies/BuiltInMelodies.hpp. No SD card required to play these. Looked up by PID string.
Lookup: BuiltInMelodies::findMelodyByPID(pid) and BuiltInMelodies::isBuiltInMelody(pid).
F-003 — SD-card melody download & storage
Melodies not found in the built-in library are downloaded from a URL (Firebase Storage) and stored as .bsm files on the SD card. FileManager handles download, write, and lookup. If the melody PID matches a built-in, the download is skipped entirely.
Subsystem: src/FileManager/FileManager.cpp
F-004 — MQTT transport
The device connects to a broker (VPS) and subscribes to vesper/{deviceUID}/cmd. Commands arrive as JSON envelopes. Responses are published back. Auth uses dynamic HMAC passwords (see F-011).
Subsystem: src/Communication/Transport/MQTTTransport/
F-005 — WebSocket transport
AsyncWebSocket on /ws. Commands arrive as JSON envelopes from browser or Node-RED. clientId is the WebSocket client ID for per-client responses.
Subsystem: src/Communication/Transport/WebSocketTransport/
F-006 — UART/Serial transport
Commands can be sent over Serial (USB). Useful for lab/dev work. JSON envelope format, same as other transports.
Subsystem: src/Communication/Transport/UARTTransport/
F-007 — HTTP / AsyncWebServer transport
REST-style HTTP endpoints via AsyncWebServer on port 80. Also hosts the SettingsWebServer (F-017).
F-008 — MQTT heartbeat (retained, 30 s)
Every 30 seconds while MQTT is connected, a retained message is published to vesper/{deviceUID}/status/heartbeat with uptime, IP, firmware version, and gateway. Clients get the last status immediately on subscribe.
See full details: heartbeat.md
Since: firmware v130
F-009 — SemVer firmware versioning
Version defined as FW_VERSION string in src/Version.hpp. Format MAJOR.MINOR.PATCH. Also exposes a SemVer struct for programmatic comparison. Changelog embedded in the same file.
F-010 — OTA update (FastAPI backend, safe-mode boot check)
On every boot, before starting normal operation, the device queries the backend for a pending OTA. If one exists, it is applied immediately (boot-phase OTA, safe-mode). OTA can also be triggered via MQTT/WebSocket command at runtime.
Backend: FastAPI on VPS. Binary served from Firebase Storage.
F-011 — MQTT dynamic auth (HMAC-SHA256 device password)
Each device authenticates to the MQTT broker with:
- username:
deviceUID(e.g.PV000000000000) - password:
HMAC-SHA256(MQTT_SECRET, deviceUID).hexdigest()[:32]
MQTT_SECRET is compiled in via platformio.ini. The backend verifies the same derivation. Legacy password vesper still accepted but will be removed in Stage 7.
F-012 — HAL variant system (multi-board build flags)
PlatformIO build flags (HAS_RF, HAS_RTC, HAS_LCD, etc.) select hardware capabilities at compile time. Code is guarded with #if HAS_RF etc. to produce board-specific binaries from a single codebase.
Environments: vesper-v1 (standard), others in progress.
F-013 — RF Remote subsystem (HAS_RF variant)
When compiled with HAS_RF, the device can receive IR/RF remote control signals and map them to bell actions.
F-014 — NVS device-identity migration
Runs once at the very start of setup(), before ConfigManager::begin(), to upgrade the NVS device-identity keys written by pre-v2 factory firmware.
Key renames (namespace device_id):
| Old key | New key | Notes |
|---|---|---|
device_uid |
serial |
Value carried forward unchanged |
hw_type |
hw_family |
Value translated via lookup table (e.g. "VS" → "vesper") |
hw_version |
hw_revision |
Value carried forward unchanged |
Lookup table (hw_type → hw_family) covers all codes ever written by factory firmware:
VS → vesper, VP → vesper_plus, VX → vesper_pro, bell_core → vesper, bell_plus → vesper_plus, bell_pro → vesper_pro, agnus_mini → agnus_mini. Unknown codes are carried forward as-is.
Behaviour: Each step is idempotent — if the new key already exists the old one is just erased. If none of the old keys are present, the migration exits immediately with no NVS writes. Safe to leave in permanently.
Subsystem: src/NvsMigration/NvsMigration.cpp
F-015 — Two-tier factory reset (5 s / 10 s button hold)
The BOOT button (GPIO 0) supports two hold durations:
| Hold | Action |
|---|---|
| < 5 s, then release | Short press — no action (reserved) |
| 5 s (while held) | WiFi credentials wiped immediately |
| Release between 5–10 s | Device restarts (WiFi-only reset complete) |
| 10 s (while held) | Full factory reset — all settings cleared, then restart |
Why two tiers: A deployed device that loses WiFi connectivity needs a way to re-provision without losing all its bell configuration and schedule. The 5 s gesture wipes only the WiFi credentials (so WiFiManager will open the captive portal on next boot). The 10 s gesture is a last resort that wipes everything.
Subsystem: src/InputManager/InputManager.cpp — MEDIUM_PRESSED state, mediumPressMs = 5000.
main.cpp callbacks: handleWiFiCredsReset(), handleWiFiCredsResetRelease(), handleFactoryReset().
F-016 — WiFi credential fallback chain
On WiFi connect attempt, the device tries credentials in order:
- Saved credentials (stored by WiFiManager from previous captive portal session) —
WiFi.begin() - Hardcoded failsafe (compiled-in
defaultWifiSsid/defaultWifiPskfrom config) — afterMAX_WIFI_FAILURES = 2on stage 1 - Captive portal (WiFiManager AP, boot-phase only) — after
MAX_WIFI_FAILURES = 2on stage 2
Post-boot: if all credentials fail, cycle restarts from stage 1 indefinitely (no portal after boot).
After portal saves credentials: device reboots (not continues) so AsyncWebServer can bind port 80 cleanly.
_triedSavedCredentials flag tracks which stage is active.
Subsystem: src/Networking/Networking.cpp
F-017 — SettingsWebServer (captive-portal config UI)
A web UI served on port 80 that allows local configuration of the device (network settings, bell config, etc.) without needing MQTT or a mobile app.
Instantiated as settingsWebServer in main.cpp. begin() called when network becomes ready.
Subsystem: src/SettingsWebServer/SettingsWebServer.hpp
F-018 — Built-in melody builtin_* UID aliases
24 backward-compatibility PID aliases prefixed with builtin_ that map to existing melody arrays. Devices shipped with old firmware used these PIDs in their schedules. The alias table ensures those schedules continue to work without SD downloads.
Two new PROGMEM arrays added: builtin_catehetical, bulitin_mournfull_toll_alternative.
isBuiltInMelody(pid) helper added for O(n) lookup without needing the full MelodyInfo*.
Subsystem: src/BuiltInMelodies/BuiltInMelodies.hpp
F-019 — NTP sync: fetch UTC, apply stored offsets manually
Previous behaviour: configTime(gmtOffset, dstOffset, ntpServer) let the ESP-IDF SDK apply offsets internally, which caused double-application bugs when the SDK also read stored timezone state.
Current behaviour: configTime(0, 0, ntpServer) fetches raw UTC. Stored gmtOffsetSec + daylightOffsetSec are added manually to the UTC epoch before writing to RTC. Logged as both UTC and local time.
Subsystem: src/TimeKeeper/TimeKeeper.cpp:syncTimeWithNTP()
F-020 — Command envelope version default changed to v1
When an incoming JSON command does not include a "v" field, the envelope version defaults to 1 (was 2). This matches the actual format sent by the mobile app and Node-RED flows, fixing a regression where the v2 default caused the legacy adapter to reject commands from these clients.
Affected transports: MQTT, UART, WebSocket.
F-021 — RelayHandler v1/v2 dual-format compatibility
relay.set_durations and relay.set_outputs now accept two payload shapes:
- v2:
{ "bells": { "b1": ..., "b2": ... } }— bells nested under a"bells"key - v1:
{ "b1": ..., "b2": ... }— bells at the top level ofcontents
The handler checks contents["bells"].is<JsonObject>() and unpacks accordingly.
Subsystem: src/Communication/Handlers/RelayHandler/RelayHandler.cpp
F-022 — Player speed guard
If the incoming playback command contains "speed": 0 (or omits it and JSON parsing produces 0), the Player now defaults to 300 ms per step instead of dividing by zero / producing silent playback.
Also guards calculateProjectedRunTime() against singleLoopDuration == 0.
Subsystem: src/Player/Player.cpp:setMelodyAttributes()
F-024 — V1 playback segment_duration fix (single-segment mode)
When continuous_loop: false and segment_duration > 0, the melody now plays for the full segment_duration milliseconds (completing the last loop in progress) before stopping. Previously, sending total_duration: 0 explicitly caused the player to stop after the very first loop regardless of segment_duration.
Root cause: setMelodyAttributes only derived total_duration from segment_duration when total_duration was absent from the payload. An explicit total_duration: 0 bypassed the derivation, leaving the stop timer at zero. onMelodyLoopCompleted then hit the "play-once" shortcut and stopped immediately.
Fix: When continuous_loop is false, total_duration is now always overwritten with segment_duration regardless of what the client sent — it is semantically meaningless in single-segment mode. The play-once fallback in onMelodyLoopCompleted is also tightened to only fire when both segment_duration and total_duration are zero (truly no duration configured).
Subsystem: src/Player/Player.cpp:setMelodyAttributes(), Player.cpp:onMelodyLoopCompleted()
F-025 — V2 playback command namespace
V2 clients send playback.play and playback.stop as the cmd field (with "v": 2), consistent with all other V2 namespaced commands (relay.set_durations, system.restart, etc.).
PlaybackHandler now registers these two commands directly. The old root-level "playback" command no longer exists in V2.
Legacy (V1) compatibility: LegacyAdapter maps { cmd:"playback", action:"play" } → "playback.play" and { cmd:"playback", action:"stop" } → "playback.stop". All deployed V1 clients continue to work without any changes.
Subsystem: src/Communication/Handlers/PlaybackHandler/PlaybackHandler.cpp, src/Communication/CommandBus/LegacyAdapter.cpp
F-026 — V2 playback mode field
V2 play commands replace the ambiguous continuous_loop / segment_duration / total_duration triplet with a single mode string and a duration field:
mode |
Behaviour | Required fields |
|---|---|---|
"single" |
Play exactly one melody loop, then stop | none |
"timed" |
Loop continuously for duration ms, stop at end of a full loop |
duration |
"interval" |
Loop for duration ms, pause for pause_duration ms, repeat until total_duration ms elapsed |
duration, pause_duration, total_duration |
"infinite" |
Loop forever until a stop command |
none |
V1 timing fields (segment_duration, continuous_loop, total_duration) are still parsed when mode is absent, so the fix from F-024 continues to apply to V1 clients.
Example V2 play command:
{ "cmd": "playback.play", "v": 2, "contents": { "pid": "builtin_festive_4voices", "speed": 232, "mode": "timed", "duration": 30000, "note_assignments": [1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0], "url": "..." } }
Subsystem: src/Player/Player.cpp:setMelodyAttributes()
F-027 — FileManager HTTPS removed — melody downloads over plain HTTP only
FileManager::downloadFile no longer supports HTTPS URLs. Any URL starting with https:// is rejected immediately with an error log.
Why: The ESP32's mbedTLS context requires ~40 KB of contiguous heap for the TLS handshake. After the device has been running for a while, heap fragmentation makes this allocation unreliable, causing intermittent download failures. Melody .bsm files contain only note sequences and carry no credentials, so plain HTTP is acceptable for this use case.
What was removed: WiFiClientSecure, the SSL heap guard (largestBlock < 40000 check), esp_task_wdt_delete/add calls around the GET, and all secureClient cleanup paths. The esp_task_wdt include was also dropped from FileManager.cpp and WiFiClientSecure.h from FileManager.hpp.
Also fixed in this change: ensureDirectoryExists now strips trailing slashes instead of appending one — SD.exists() returns false for directories when a trailing slash is present.
Melody files must be served via plain HTTP. The Firebase Storage URLs (currently used) must be proxied or replaced with an HTTP endpoint before downloads will work.
Subsystem: src/FileManager/FileManager.cpp, src/FileManager/FileManager.hpp
F-028 — Logging level calibration
Establishes sane production defaults for all three log channels and suppresses high-frequency noise on MQTT.
Default channel levels (ConfigManager defaults):
| Channel | Old default | New default | Effective behaviour |
|---|---|---|---|
| Serial | VERBOSE (5) | INFO (3) | Clean boot log; DEBUG/VERBOSE only when explicitly set |
| MQTT | NONE (0) | WARNING (2) | Error and warning events flow to server by default |
| SD | NONE (0) | WARNING (2) | Ready for SD log callback when wired up |
Per-subsystem MQTT caps (set in CommunicationRouter::begin()):
| Subsystem | MQTT cap | Reason |
|---|---|---|
| BellEngine | WARNING | Per-note STRIKE/FIRE logs are VERBOSE/DEBUG — would flood MQTT on every bell strike |
| OutputManager | WARNING | Per-output AUTO-EXTINGUISH log fires on every note |
| HealthMonitor | WARNING | Health-check runs every few seconds; only failures matter remotely |
| ConfigManager | WARNING | NVS read trace and isHealthy debug chatter |
| MQTTClient | NONE | Prevents feedback loop (MQTT driver logging over MQTT) |
| CommRouter | WARNING | Internal dispatch noise |
| Logger | NONE | Prevents recursion |
| Player | INFO | State transitions (PLAY/STOP/PAUSE) are useful to see remotely |
| Telemetry | INFO | Load data useful for fleet monitoring |
| OTAManager | INFO | Update events are important to track |
Other fixes in this change:
- Early
Logging::setLevel()call inmain.cppremoved —CommunicationRouter::begin()applies all three channels at once once the MQTT callback is wired, removing a redundant partial application. - Loop heartbeat downgraded
LOG_DEBUG→LOG_VERBOSE(only visible at VERBOSE level). - HealthMonitor periodic "skipping/performing" polling lines removed entirely. Per-subsystem status lines and completion timing: VERBOSE → DEBUG.
- FirmwareValidator boot-path health check lines: VERBOSE → INFO (one-shot boot events worth seeing at INFO).
- ConfigManager: all remaining VERBOSE lines → DEBUG.
Subsystem: src/ConfigManager/ConfigManager.hpp, src/Communication/CommunicationRouter/CommunicationRouter.cpp, src/HealthMonitor/HealthMonitor.cpp, src/FirmwareValidator/FirmwareValidator.cpp, src/main.cpp
F-023 — Telemetry bell max load default raised to 500
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) andboot(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 fromNetworkConfig
Subsystem: src/Communication/Handlers/NetworkHandler/NetworkHandler.cpp
F-038 — Bell test fire commands (relay.test_bell / relay.test_batch)
Two non-blocking test commands for firing bells on demand, bypassing the bellsEnabled guard (manual tests always work regardless of the master switch):
| Command | Behaviour |
|---|---|
relay.test_bell |
Fire bell channel N using its configured output and duration. Non-blocking — OutputManager timer handles the shutoff. Can be sent in rapid succession like piano keys. |
relay.test_batch |
Fire a list of bell channels simultaneously (like a single melody step). Each bell fires for its own configured duration. |
Both commands read output and duration from ConfigManager (same values as real playback). Returns the resolved output and duration so the caller can confirm what was fired.
Subsystem: src/Communication/Handlers/RelayHandler/RelayHandler.cpp
F-039 — Clock output test fire commands (clock.test_c1 / clock.test_c2)
Two test commands for verifying clock relay wiring without waiting for the next scheduled clock strike:
| Command | Behaviour |
|---|---|
clock.test_c1 |
Fire the C1 (ODD) clock output immediately for pulse_duration ms |
clock.test_c2 |
Fire the C2 (EVEN) clock output immediately for pulse_duration ms |
Both use OutputManager::fireClockOutput() which resolves the physical pin from ClockConfig. Returns the output name and actual duration used.
ClockHandler constructor now accepts an optional OutputManager* (defaults to nullptr); the router passes _outputManager so the test commands are live when the output manager is registered.
Subsystem: src/Communication/Handlers/ClockHandler/ClockHandler.cpp
F-040 — Combined relay config command (relay.set_config)
Single command that sets bell durations and/or output assignments in one round trip, replacing the need to send relay.set_durations + relay.set_outputs separately. Both durations and outputs fields are optional — at least one must be present. Partial updates accepted (only the fields provided are changed).
Subsystem: src/Communication/Handlers/RelayHandler/RelayHandler.cpp
F-041 — Output numbering convention enforced — 1-based everywhere except raw chip pin
Bell outputs are stored and communicated as 1-based numbers throughout the entire stack (config, MQTT protocol, console UI). The single conversion to 0-based chip pin index happens only in OutputManager::getPhysicalOutput(), which subtracts 1 immediately before calling the hardware driver.
0 = disabled. 255 = unconfigured sentinel (internal only, never sent over wire).
All call sites (BellEngine, RelayHandler test commands, TimeKeeper alerts) now go through getPhysicalOutput() rather than calling fireOutputForDuration() with a raw stored value. relay.test_output is the sole exception — it is a raw hardware diagnostic that intentionally takes a 0-based chip pin directly, and is documented as such.
createDefaultBellConfig() initialised outputs to i (0-based identity map) — corrected to 0 (all disabled).
Subsystems: src/OutputManager/OutputManager.cpp, src/ConfigManager/ConfigManager.cpp, src/Communication/Handlers/RelayHandler/RelayHandler.cpp, src/TimeKeeper/TimeKeeper.cpp
F-042 — Combined clock config commands (clock.set_config / clock.set_alerts_config)
Two batch commands that each collapse multiple individual clock commands into one round trip:
| Command | Replaces |
|---|---|
clock.set_config |
clock.enable/disable + clock.set_outputs + clock.set_timings |
clock.set_alerts_config |
clock.set_alerts + clock.set_silence |
All fields optional — at least one required. Single saveClockConfig() call per command regardless of how many fields are set.
Subsystem: src/Communication/Handlers/ClockHandler/ClockHandler.cpp
F-043 — network.info expanded
network.info now returns the full set of fields needed by the console network panel:
| Field | Source |
|---|---|
ip |
WiFi.localIP() |
subnet |
WiFi.subnetMask() |
gateway |
WiFi.gatewayIP() |
dns |
WiFi.dnsIP() |
mac |
WiFi.macAddress() |
hostname |
NetworkConfig.hostname |
ssid |
WiFi.SSID() |
connection_type |
"WIFI" / "ETHERNET" / "AP" |
Previously only returned ip, gateway, dns. Fields mac, hostname, ssid were spread across network.status.
Subsystem: src/Communication/Handlers/NetworkHandler/NetworkHandler.cpp
F-044 — network.status slimmed to pure runtime state
network.status now returns only live/volatile data useful for health monitoring and polling:
| Field | Notes |
|---|---|
connected |
bool |
ap_mode |
bool |
rssi |
dBm, live WiFi signal strength |
uptime_ms |
millis() — time since last boot |
state |
Connection state machine: DISCONNECTED / CONNECTING / CONNECTED_WIFI / CONNECTED_ETHERNET / RECONNECTING / AP_MODE |
Removed from network.status: ip, mac, hostname, ssid, type — these are static addressing facts, now served by network.info.
Subsystem: src/Communication/Handlers/NetworkHandler/NetworkHandler.cpp
F-045 — Day-rotated SD log files with size cap
Fixes a bug where SD logging was a silent no-op: FileManager::appendLine never created the /logs directory before opening the file in append mode, which fails on most SD/FAT implementations when the parent directory doesn't exist.
New FileManager::appendLogLine(logDir, line, timestamp, maxTotalBytes) replaces the direct appendLine call as the SD log channel's write path:
- Ensures
logDirexists before every write. - Names the file
YYYY-MM-DD.logfrom the supplied timestamp (time(nullptr), works with or without an RTC once NTP has synced). Falls back tounset-date.logif no wall clock is available yet, rather than dropping early-boot lines. - Every 50 writes (not every write), sums directory size and prunes oldest whole files once over a 512KB total budget (
SD_LOG_MAX_TOTAL_BYTESinCommunicationRouter.cpp).
Fixed after initial testing: the first version pruned on every write, which does a full SD.open() directory scan + std::vector build on the calling task's own stack. The first device test (SD log level set to INFO) hit this from MQTTDriver's 3KB-stack connect task and panicked with a stack canary trigger, causing a reboot loop. Fixed by throttling the prune check to once per 50 writes and bumping the three MQTT driver task stacks (connect/reconnect/heartbeat) from 3072 to 4096 bytes.
Subsystems: src/FileManager/FileManager.cpp, src/Communication/CommunicationRouter/CommunicationRouter.cpp, src/Communication/Drivers/MQTTDriver/MQTTDriver.cpp
F-046 — Boot reset-reason capture
Telemetry::begin() now reads esp_reset_reason() at the very start of boot, before anything else can crash again this cycle. Classified into fault (ESP_RST_PANIC, ESP_RST_INT_WDT, ESP_RST_TASK_WDT, ESP_RST_WDT, ESP_RST_BROWNOUT) vs expected (power-on, software reset/OTA, deep sleep wake, etc).
- Persisted in the SD boot log (
/telemetry_boot_log.json, fieldreason) regardless of connectivity — works for offline devices. - For online devices,
CommunicationRouter::reportBootReasonOnce()fires the first time MQTT connects after boot (registered viaMQTTDriver::setOnConnectCallback): fault reasons publish tovesper/{uid}/status/alerts, expected reasons publish tovesper/{uid}/status/info(event typeboot_reason). Fires once per boot, not on every reconnect.
Subsystems: src/Telemetry/Telemetry.cpp, src/Communication/CommunicationRouter/CommunicationRouter.cpp, src/Communication/Drivers/MQTTDriver/MQTTDriver.cpp
F-047 — Per-subsystem MQTT log rate limiting
Token bucket per subsystem tag on the MQTT log channel (burst of 10, refills 1/second) inside Logging::publishToMqtt(). Protects the broker/airtime from a chatty or misconfigured subsystem (e.g. a per-subsystem override left at VERBOSE via log.set_mqtt).
Drops are counted, not silently discarded: the next time a rate-limited tag is allowed to publish again, a WARNING summary line ("suppressed N log message(s) (MQTT rate limit)") is emitted first. Serial and SD channels are unaffected — MQTT only.
Subsystem: src/Logging/Logging.cpp
F-048 — SD log retrieval commands (logs.list / logs.download)
Two new commands on LoggingHandler for pulling day-rotated SD logs off a device remotely (offline-device troubleshooting workflow: app queries device directly, or backend requests once the device is back online).
| Command | Description |
|---|---|
logs.list |
Lists dated log files under /logs with name + size. |
logs.download |
Returns a bounded chunk ({file, offset} → {data, next_offset, eof}) of a log file. Callers loop, feeding next_offset back as offset, until eof is true. Rejects path traversal in file. |
Chunked rather than whole-file because CommandResult JSON payloads need to stay small regardless of file size (a rotated file can be up to the full SD log budget). Both commands return an error (not a crash) on boards without an SD card — LoggingHandler now takes an optional FileManager*.
Subsystems: src/Communication/Handlers/LoggingHandler/LoggingHandler.cpp, src/FileManager/FileManager.cpp
F-049 — firmware.status rollback safety-net diagnostics
FirmwareValidator tracked startup retry count, runtime failure count, and backup partition info internally (NVS-persisted) but never exposed them remotely — only visible via LOG_* output. Added public getters (getStartupRetryCount(), getRuntimeFailureCount()) and extended firmware.status with startup_retry_count, max_startup_retries, runtime_failure_count, max_runtime_failures, backup_version, backup_is_valid.
Subsystems: src/FirmwareValidator/FirmwareValidator.hpp, src/Communication/Handlers/FirmwareHandler/FirmwareHandler.cpp
F-050 — SD log lines prefixed with wall-clock date/time + uptime
The SD log line format previously carried only millis() — useless for reading a log file after the fact without knowing when boot happened. Lines are now prefixed with real date/time plus uptime:
2026-07-15 | 12:28:04 | 13460843 -> 🔵 [DEBG][OutputManager] message
Date/time comes from time(nullptr), set by NTP via Timekeeper::syncTimeWithNTP() — works regardless of HAS_RTC, since NTP sync sets the ESP32 system clock independently of any RTC peripheral. Prints unset-date | unset-time instead of a bogus 1970 epoch date if NTP hasn't synced yet (matches the day-rotation file's unset-date.log fallback from F-045). The level icon (🔴🟡🟢🔵⚪) — previously Serial-only — is now also written to SD for faster visual scanning.
Serial and MQTT lines are unchanged (Serial already had the icon; MQTT already carries a timestamp field, albeit millis()-only).
F-051 — Fix: TelemetryTask/HealthMonitor stack overflow on SD+MQTT-nested logging
Device rebooted every ~10 minutes with Guru Meditation Error: ... Stack canary watchpoint triggered (TelemetryTask).
Root cause: Telemetry::flushRuntimeToSD() runs on TelemetryTask (4096-byte stack) every RUNTIME_FLUSH_INTERVAL_MS. Its call chain nests several stack-hungry operations on top of each other: FileManager::writeJsonFile() (SD.open + ArduinoJson serializeJson) → LOG_DEBUG on success → Logging::log() (allocates a 512-byte char buffer[512] for vsnprintf) → Logging::publishToMqtt() (builds a String reserved at 600 bytes) → AsyncMqttClient::publish(). Combined, this exceeded the 4096-byte budget and corrupted the stack canary.
Fix applied: Bumped TelemetryTask to 8192 bytes (Telemetry.cpp) and HealthMonitor's monitoring task to 6144 bytes (HealthMonitor.cpp) — HealthMonitor::performFullHealthCheck() logs once per subsystem (11 LOG_* calls per pass) through the same nested nesting pattern and was judged the next most likely to trip. Verified via pio run — RAM usage after the bump is 19.2% (63KB/320KB), so the +6KB combined stack cost is not a concern.
Broader risk identified at the time: OutputManager (OutputDuration, 4096B), TimeKeeper (TimeKeeper, 4096B), MQTTDriver's mqttRecon/mqttHB/mqttConnect (4096B each), and Networking's netRecon (3072B, the tightest of all) all called LOG_* directly on small task stacks, sharing the same structural fragility: any LOG_* call that fanned out to MQTT or SD added Logging::log()'s 512-byte buffer plus publishToMqtt()'s 600-byte String and a synchronous AsyncMqttClient::publish()/SD-write call onto whatever stack the calling task happened to have. This is fixed at the root by the logging redesign below — those tasks no longer pay that cost regardless of their own stack size.
Proper fix — deferred MQTT/SD logging via a dedicated queue + task:
The root architectural problem was that Logging::log() did all formatting and all I/O (Serial/MQTT/SD) synchronously, on whatever task called LOG_*. A task with other stack-heavy work nested (JSON serialization, SD I/O) had no way to know it was borrowing stack for the logger too.
Implemented in src/Logging/Logging.hpp / Logging.cpp:
- A dedicated
LoggingTask(4096B stack, Core 0, priority 1), lazily created on the first log call that needs MQTT or SD output —ensureLoggingTaskStarted()is guarded by a spinlock (_logQueueInitSpinlock) so concurrent first-callers can't race and create two queues/tasks. Logging::log()still doesvsnprintfinto its local 512-byte buffer (cheap, fixed-size, stays on the caller's stack — unchanged). If the message is MQTT- or SD-enabled for that tag, it's copied into a fixed-sizeLogQueueItem(tag[24],levelStr[6],message[256], plus theLogLevelenum andtoMqtt/toSdflags) and sent viaxQueueSend(..., 0)— non-blocking, so a full queue (depth 16) drops the line rather than stalling the caller.LoggingTaskdrains the queue and calls the existingpublishToMqtt()/writeToSd()unchanged — those functions, and the expensive/variable-depthAsyncMqttClient::publish()and SD file write calls inside them, now only ever nest on the logging task's own stack, never on the caller's.- Serial output stays synchronous in
Logging::log()— cheap, and keeps the USB serial monitor showing the true, immediate order of events (important when debugging a crash, as opposed to a queue-drained/reordered view).
Message length cap: queued MQTT/SD messages are capped at 256 bytes (vs. 512 for the Serial/vsnprintf buffer). Audited via grep across all LOG_* call sites in the codebase — the longest literal format strings are ~110 characters; with realistic %s/%d substitutions (hostnames, paths, ArduinoJson::DeserializationError::c_str(), which is always a short fixed string like "InvalidInput"), worst-case realistic messages land around 150–180 characters. 256 bytes leaves comfortable margin with no observed truncation risk.
What this does NOT fix: stack pressure from non-logging causes. FileManager::writeJsonFile()'s own ArduinoJson serialization and SD I/O still run synchronously on whatever task calls it — only the logging fan-out (the part that made TelemetryTask's overflow possible in the first place) was moved off the caller's stack.
RAM impact verified negligible via pio run (62980 vs. 62956 bytes static RAM; the 4096B task stack is allocated at runtime only if MQTT or SD logging is actually enabled).
Subsystem: src/Logging/Logging.hpp, src/Logging/Logging.cpp