feat(MQTT): confirmed delivery for playback/reports; vendor AsyncMqttClient; pin all deps (F-073)

- MQTTDriver::publishConfirmed(): QoS 1 + PUBACK tracking (8 s; heartbeat
  20 s). A missed PUBACK forces a reconnect. status/playback relies on the
  existing republish-current-state-on-connect; control/reports are resent
  after the next CONNACK (newest 4). Publish + registration under one
  recursive mutex since the PUBACK can arrive before publish() returns.
- AsyncMqttClient vendored into lib/ (upstream 3d93fc7) with one patch:
  _onPubAck()/_onPubComp() call _handleQueue(), so a QoS 1 message delays
  the next packet by one RTT instead of RTT + up to ~500 ms.
- platformio.ini: platform and every library pinned to the exact versions
  already being built (git deps by commit). Clean-libdeps rebuild verified
  to resolve the same AsyncTCP and the vendored AsyncMqttClient.
- Removed board_build.cmake_extra_args (timer stack): no effect on Arduino
  builds, the SDK is precompiled with 2048. Replaced by a warning comment.
- mqtt.status gains resent_messages and the new forced-reset reasons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 21:50:54 +03:00
co-authored by Claude Opus 5.5
parent cec4db4894
commit c43d9ae11c
59 changed files with 2674 additions and 69 deletions
+6 -6
View File
@@ -80,7 +80,7 @@ MQTT uses the v2 topic set — see [vesper_mqtt_topic_spec_v2.md](vesper_mqtt_to
| MQTT | `vesper/{device_id}/control/ack` | Outbound replies | Strictly request/response — nothing unsolicited |
| MQTT | `vesper/{device_id}/control/reports` | Outbound, critical unsolicited events | `bell_overload`, `playback_failed` — not retained |
| MQTT | `vesper/{device_id}/status/heartbeat` | Outbound, retained, QoS 1 | Heartbeat every 30s + LWT |
| MQTT | `vesper/{device_id}/status/playback` | Outbound, retained, QoS 0 | Playback transitions |
| MQTT | `vesper/{device_id}/status/playback` | Outbound, retained, QoS 1 (confirmed) | Playback transitions |
| MQTT | `vesper/{device_id}/system/alerts` | Outbound, retained until cleared, QoS 0 | Subsystem state-change events |
| MQTT | `vesper/{device_id}/system/info` | Outbound, retained, QoS 0 | Discrete device events (boot report) |
| MQTT | `vesper/{device_id}/system/logs` | Outbound, QoS 0 | Mirrors serial log stream |
@@ -824,8 +824,8 @@ Returns `data: { "enabled", "host", "port", "user", "use_ssl" }` (never the pass
### `mqtt.status`
Connection health since boot — works on every transport, so it's the command to send over WebSocket when the cloud shows a device offline but the local app still works.
Returns `data: { "enabled", "connected", "connected_for_ms", "connects", "disconnects", "reconnect_attempts", "last_disconnect_reason", "last_disconnect_ago_ms", "forced_resets", "last_forced_reset_reason", "last_forced_reset_ago_ms", "wifi_connected", "free_heap" }`.
`*_ago_ms` and `connected_for_ms` are `0` when the event never happened / not connected. `last_forced_reset_reason` is `"connect attempt stuck"` or `"heartbeat PUBACK timeout"` (empty if self-recovery never fired). No errors.
Returns `data: { "enabled", "connected", "connected_for_ms", "connects", "disconnects", "reconnect_attempts", "last_disconnect_reason", "last_disconnect_ago_ms", "forced_resets", "last_forced_reset_reason", "last_forced_reset_ago_ms", "resent_messages", "wifi_connected", "free_heap" }`.
`*_ago_ms` and `connected_for_ms` are `0` when the event never happened / not connected. `last_forced_reset_reason` is `"connect attempt stuck"`, `"heartbeat PUBACK timeout"`, `"playback PUBACK timeout"` or `"report PUBACK timeout"` (empty if self-recovery never fired). `resent_messages` counts `control/reports` messages republished after a reconnect because their PUBACK never came. No errors.
### `mqtt.get_topics`
@@ -879,8 +879,8 @@ Published without a request, on the v2 topic set. Full field-level reference: [m
| Topic | When | QoS | Retained | Switch |
|---|---|---|---|---|
| `vesper/{id}/status/heartbeat` | Every 30s (+ LWT on unclean disconnect) | 1 | yes | `heartbeat` |
| `vesper/{id}/status/playback` | On playback transition | 0 | yes | `playback` |
| `vesper/{id}/control/reports` | Critical unsolicited events (`bell_overload`, `playback_failed`) | 0 | no | `reports` |
| `vesper/{id}/status/playback` | On playback transition | 1 | yes | `playback` |
| `vesper/{id}/control/reports` | Critical unsolicited events (`bell_overload`, `playback_failed`) | 1 | no | `reports` |
| `vesper/{id}/system/alerts` | On subsystem state change only | 0 | yes, until cleared | `alerts` |
| `vesper/{id}/system/info` | Discrete device events (e.g. boot report) | 0 | yes | `info` |
| `vesper/{id}/system/logs` | Mirrors serial log stream | 0 | no | `logs` |
@@ -888,7 +888,7 @@ Published without a request, on the v2 topic set. Full field-level reference: [m
`control/ack` carries only replies (it is not an event topic). Replies are published at QoS 0.
Everything the board publishes is QoS 0 except the heartbeat (QoS 1, its PUBACK doubles as a liveness probe) — see F-071 in the feature catalog for why.
QoS 1 is used only for the heartbeat, `status/playback` and `control/reports`, and the firmware tracks their PUBACKs: a missing one makes the device reset the connection, republish the current playback state, and resend unconfirmed reports. Everything else is QoS 0 — see F-071/F-073 in the feature catalog.
---