diff --git a/docs/features/feature-catalog.md b/docs/features/feature-catalog.md index 51298a2..b003c6a 100644 --- a/docs/features/feature-catalog.md +++ b/docs/features/feature-catalog.md @@ -87,6 +87,7 @@ Check `git log -- src/Version.hpp` for the real bump history before tagging a ne | F-072 | Lower status/reply latency — QoS 0 for non-critical MQTT topics; WiFi modem sleep disabled | v2.4.0 | Stable | | F-073 | Confirmed delivery for `status/playback` + `control/reports` (QoS 1, PUBACK tracked, reset + republish/resend); AsyncMqttClient vendored + patched; all dependencies pinned | v2.4.0 | Stable | | F-074 | Fix: `mode: "infinite"` no longer flips status playing/paused every ~0.5 s | v2.4.0 | Stable | +| F-075 | Play/stop command replies no longer wait for telemetry SD writes (deferred to TelemetryTask) | v2.4.1 | Stable | --- @@ -1549,3 +1550,19 @@ checked `continuous_loop`, so with a 0 ms segment every duration-timer tick paus rejects `duration: 0`, so no valid segmented mode is affected. Subsystem: `src/Player/Player.cpp` + +### F-075 — Telemetry SD writes deferred off the command path + +**Symptom.** Measured on hardware (2026-10-15): the `playback.play`/`playback.stop` reply arrived 50–100 ms +after the status broadcast even with serial logging off. Between the two, the command handler wrote to the SD +card: `Telemetry::recordPlayback()` (play → `/telemetry_runtime.json`) and `saveStrikeCounters()` (stop → +`/telemetry_data.json`), both inline in the async_tcp task that also has to send the reply. + +**Change.** Both now set a pending flag and notify `TelemetryTask`, which does the write within milliseconds +(`processPendingSaves()`). The task waits on a notification instead of a plain 1 s delay, but the periodic +work keeps its 1 s cadence, since `checkBellLoads()` decays bell loads once per call. Pending writes are +held while telemetry is paused for OTA and done right after `resume()`. Before the task exists (early boot) +`saveStrikeCounters()` still writes synchronously. Repeated requests before the write happens collapse into +one write of the latest values. + +Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp` diff --git a/src/Telemetry/Telemetry.cpp b/src/Telemetry/Telemetry.cpp index d16705d..7df6a6c 100644 Binary files a/src/Telemetry/Telemetry.cpp and b/src/Telemetry/Telemetry.cpp differ diff --git a/src/Telemetry/Telemetry.hpp b/src/Telemetry/Telemetry.hpp index f77d89c..7f575a0 100644 --- a/src/Telemetry/Telemetry.hpp +++ b/src/Telemetry/Telemetry.hpp @@ -192,7 +192,10 @@ public: uint32_t getStrikeCount(uint8_t bellIndex); void resetStrikeCounters(); // User-requested reset (per bell or all) - // Persistence methods + // Persistence methods. + // saveStrikeCounters() only *requests* the SD write; TelemetryTask does it + // within a few ms. Player calls this on stop, inside the command handler — + // an inline SD write held the command reply back by 50-100 ms (F-075). void saveStrikeCounters(); void loadStrikeCounters(); @@ -314,6 +317,13 @@ private: void checkBellLoads(); void loadMetrics(); void saveMetrics(); + void writeStrikeCountersNow(); + + // Deferred SD writes, set from any task, done by TelemetryTask (F-075) + volatile bool _strikeSavePending = false; + volatile bool _metricsSavePending = false; + TaskHandle_t telemetryTaskHandleForNotify() const; + void processPendingSaves(); }; #endif diff --git a/src/Version.hpp b/src/Version.hpp index 70571f0..f0ddeba 100644 --- a/src/Version.hpp +++ b/src/Version.hpp @@ -28,8 +28,9 @@ // mqtt.status, confirmed QoS 1 for playback/reports (QoS 0 elsewhere), // WiFi modem sleep off, vendored/patched AsyncMqttClient, pinned deps, // WiFi/NTP task-retry, infinite-mode status flicker fix (F-071..F-074) +// v2.4.1 - Play/stop replies no longer wait for telemetry SD writes (F-075) // ═══════════════════════════════════════════════════════════════════════ -#define FW_VERSION "2.4.0" +#define FW_VERSION "2.4.1" // ═══════════════════════════════════════════════════════════════════════ // SemVer — lightweight 3-part version struct