feat(MQTTDriver,SystemHandler): free_heap on heartbeat + ping RTT timestamp echo

Requested by the console-side agent building a device Health tab
(RSSI, ping latency, free heap, restart timeline graphs). Both changes
are additive and backward-compatible.

publishHeartbeat() now includes free_heap (ESP.getFreeHeap()) on the
existing 30s heartbeat, alongside rssi — previously free heap was only
visible once per boot via boot_report, a single point rather than a
trend.

handlePing() previously built a JsonDocument and never used it —
ping was a pure ack. It now echoes back an optional caller-supplied
"ts" (epoch-millis) unchanged, plus device_uptime_ms, so the caller
can compute round-trip latency as (time of receipt) - ts without
needing synchronized clocks. ts is optional on both request and
response, so existing callers doing a plain liveness check are
unaffected. Left the existing #if HAS_RTC scoping on SystemHandler.cpp
untouched, per the request — ping remains RTC-variant-only.

Verified: pio run on vesper-std-v1 and agnus-v1 (confirms the HAS_RTC
scoping around SystemHandler.cpp wasn't disturbed).

Documented in feature-catalog.md F-054, MQTTDriver/README.md, and
Communication/Handlers/README.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 12:32:51 +03:00
co-authored by Claude Sonnet 5
parent 957c283788
commit 8546604490
5 changed files with 43 additions and 4 deletions
@@ -62,7 +62,7 @@ Reconnect attempts are reset to 0 on a successful connection or a new `onNetwork
## Heartbeat
Once connected, a heartbeat is published immediately and then every 30 seconds to `vesper/{uid}/status/heartbeat` with `retain = true`. Heartbeat payload includes `device_id`, `firmware_version`, `ip_address`, `gateway`, `uptime_ms`, `rssi`, and an uptime string. The heartbeat timer is stopped on disconnect and restarted on reconnect.
Once connected, a heartbeat is published immediately and then every 30 seconds to `vesper/{uid}/status/heartbeat` with `retain = true`. Heartbeat payload includes `device_id`, `firmware_version`, `ip_address`, `gateway`, `uptime_ms`, `rssi`, `free_heap` (bytes, via `ESP.getFreeHeap()` — added so a console can chart heap trend over time from the same 30s cadence as RSSI, rather than only seeing one heap sample per boot via `boot_report`), and an uptime string. The heartbeat timer is stopped on disconnect and restarted on reconnect.
---