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:
@@ -61,6 +61,6 @@ Responses are published to `control/ack`:
|
||||
- **`control/ack` is strictly request/response plus bus-wide broadcasts — never purpose-specific events.** The broker does not distinguish a command reply from a `CommandBus::broadcast()` fan-out; clients must inspect `"type"` and `"status"` to differentiate. But playback transitions, alerts, reports, and metrics never appear here — those go to their own topics via `CommunicationRouter` (`publishPlayback()`, `publishAlert()`, `publishReport()`, `publishMetrics()`), bypassing this transport entirely.
|
||||
- **Broker connection is deferred.** `begin()` does not connect. The connection is triggered by `onNetworkConnected()`, which starts a 2-second non-blocking stabilisation timer in `MQTTDriver`.
|
||||
- **MQTT must be enabled in config, and the `command` topic switch must be on.** `MQTTDriver::connect()` is a no-op if `mqttConfig.enabled` is false. Toggle the master switch with `mqtt.enable` / `mqtt.disable`. Independently, the `command` topic switch (via `mqtt.set_topics`) gates the `control/command` subscription and `control/ack` replies — turning it off while MQTT stays connected silently stops all command traffic.
|
||||
- **No per-message QoS.** Command replies and broadcasts are published at QoS 0 (see F-071 — QoS 1 caused head-of-line blocking in AsyncMqttClient). Heartbeats use QoS 1 with `retain = true`.
|
||||
- **No per-message QoS.** Command replies and broadcasts are published at QoS 0 (see F-072/F-073). Heartbeats use QoS 1 with `retain = true`.
|
||||
- **JSON parse errors and missing `cmd` get an `ERROR` reply on `control/ack`** (`type: "parse_error"`), not a silent drop — a `LOG_WARNING` is still emitted too. A parse-error reply necessarily has no `req_id` (it can't be read from input that failed to parse); a missing-`cmd` reply echoes `req_id` if the JSON was otherwise valid and included one.
|
||||
- **Incoming commands are dropped under critical heap pressure.** `onMessage()` checks `MQTTDriver::hasHeapForPublish()` (free heap ≥ 20KB) before even constructing the `JsonDocument` used to deserialize the incoming payload. Below that threshold, the message is dropped with no reply and no error response — indistinguishable from a lost network message to the caller. This exists because a rapid burst of commands (each involving deserialize + dispatch + reply, all allocation-heavy, all running inline on AsyncTCP's own task) previously fragmented the heap enough to crash the device with an unrecoverable `abort()` — see `docs/features/feature-catalog.md` F-055. A full fix (queueing incoming commands to a dedicated task, so this work never runs on AsyncTCP's task at all) is a scoped future improvement, not yet implemented.
|
||||
|
||||
Reference in New Issue
Block a user