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
+27 -22
View File
@@ -24,38 +24,44 @@
; SHARED SETTINGS — inherited by all environments
; ───────────────────────────────────────────────────────────────────────────────
[common]
platform = espressif32
; Everything below is pinned to an exact version on purpose — like the Arduino
; IDE asking before it updates a library. Nothing changes on a clean build
; unless someone edits a version here in a commit. To update one: change the
; pin, rebuild all envs, test on hardware, note it in the commit message.
; Platform 6.12.0 = Arduino-ESP32 core 2.0.17 (ESP-IDF 4.4).
platform = espressif32 @ 6.12.0
framework = arduino
monitor_speed = 115200
; All external library dependencies
; All external library dependencies.
; Not listed here: AsyncMqttClient — vendored and patched in lib/AsyncMqttClient
; (see lib/AsyncMqttClient/VENDORED.md). PlatformIO picks it up from lib/.
lib_deps =
; WiFi provisioning portal
tzapu/WiFiManager @ ^2.0.17
tzapu/WiFiManager @ 2.0.17
; Async web server + WebSocket support
; NOTE: Use the ESP32-compatible fork, not the original
https://github.com/me-no-dev/ESPAsyncWebServer.git
https://github.com/me-no-dev/AsyncTCP.git
; Async web server + WebSocket support, and its TCP layer (also used by
; AsyncMqttClient). Git sources are pinned to the exact commit after '#'.
; me-no-dev/* now redirects to the ESP32Async forks (v3.6.0 / v3.3.2).
https://github.com/me-no-dev/ESPAsyncWebServer.git#ad3741d159f9cfd50c567e81b67f3bef1dc6d89f
https://github.com/me-no-dev/AsyncTCP.git#ef448a8a1dffe4ec1b72326dd5a26211ff227b49
; JSON parsing
bblanchon/ArduinoJson @ ^7.0.0
bblanchon/ArduinoJson @ 7.4.3
; I2C GPIO expanders (relay control) — PCF8575 header is bundled in same library
adafruit/Adafruit PCF8574 @ ^1.1.0
adafruit/Adafruit PCF8574 @ 1.1.2
; Pulled in by the Adafruit libraries; pinned so it can't float either
adafruit/Adafruit BusIO @ 1.17.4
; Real-time clock
adafruit/RTClib @ ^2.1.4
; Async MQTT client
; NOTE: Requires AsyncTCP (already listed above)
https://github.com/marvinroger/async-mqtt-client.git
adafruit/RTClib @ 2.1.4
; RF remote receiver (433MHz, RCSwitch protocol)
sui77/rc-switch @ ^2.6.4
sui77/rc-switch @ 2.6.4
; Modbus RTU master (used by Rs485OutputManager for bespoke-rs485 build)
4-20ma/ModbusMaster @ ^2.0.1
4-20ma/ModbusMaster @ 2.0.1
build_flags_common =
-std=gnu++14
@@ -95,9 +101,11 @@ board_build.partitions = no_fs.csv
; Upgrade to C++14 so std::make_unique is available
build_unflags = -std=gnu++11
; FreeRTOS timer service task stack — default 2048 is too small when timer callbacks
; do LOG formatting, MQTT connect(), NTP sync, etc. Increase to 4096.
board_build.cmake_extra_args = -DCONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
; NOTE: the FreeRTOS timer service task (Tmr Svc) stack is fixed at 2048 bytes in
; Arduino builds — the SDK is precompiled, so it can't be raised from here (a
; `board_build.cmake_extra_args` line used to claim 4096; it only works for
; ESP-IDF framework builds and never had any effect). Timer callbacks must stay
; tiny: set a flag or notify a task, never LOG / JSON / network / xTaskCreate.
; Build flags for this variant
; IMPORTANT: MQTT_SECRET must match the MQTT_SECRET in the backend .env file exactly.
@@ -132,7 +140,6 @@ upload_protocol = esptool
; for the full rationale). No spiffs partition; SD-card only, no SPIFFS usage.
board_build.partitions = no_fs.csv
build_unflags = -std=gnu++11
board_build.cmake_extra_args = -DCONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
build_flags =
${common.build_flags_common}
@@ -161,7 +168,6 @@ upload_protocol = esptool
; for the full rationale). No spiffs partition; SD-card only, no SPIFFS usage.
board_build.partitions = no_fs.csv
build_unflags = -std=gnu++11
board_build.cmake_extra_args = -DCONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
build_flags =
${common.build_flags_common}
@@ -196,7 +202,6 @@ upload_protocol = esptool
; for the full rationale). No spiffs partition; SD-card only, no SPIFFS usage.
board_build.partitions = no_fs.csv
build_unflags = -std=gnu++11
board_build.cmake_extra_args = -DCONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
build_flags =
${common.build_flags_common}