fix: move radio TX to a dedicated task so HA WebSocket stays connected

Web command handlers ran on the async_tcp task and blocked up to 3s
waiting for loop() to bit-bang radio frames. async_tcp also services the
WebSocket on port 8080, so pongs stalled and Home Assistant
(ping_timeout=15) disconnected when several covers were commanded.

- Add a radio_tx FreeRTOS task with a job queue; sendFrame/repeatFrame
  and repeater frames enqueue instead of transmitting inline.
- Serialize CC1101 access with a recursive mutex (TX task, apply, end,
  frequency scan, RSSI read).
- Make Web::queueCommand fire-and-forget; drop the done semaphore.
- Route /setMyPosition and /unpairShade through the command queue.
- Clamp repeats to MAX_TX_REPEATS (40).
- Pin AsyncTCP to core 0 on dual-core targets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-10 20:13:31 +02:00
parent b117c34cb8
commit 9a9afa5e86
5 changed files with 202 additions and 81 deletions

View file

@ -39,14 +39,23 @@ monitor_filters =
esp32_exception_decoder
log2file
; Dual-core targets: keep the async web/socket task on core 0 so the radio
; task on core 1 (with loop()) never competes with network handling.
[dualcore]
build_flags =
${env.build_flags}
-DCONFIG_ASYNC_TCP_RUNNING_CORE=0
[env:esp32dev]
board = esp32dev
board_build.partitions = esp32_3MB.csv
build_flags = ${dualcore.build_flags}
[env:esp32devdbg]
board = esp32dev
build_type = debug
board_build.partitions = esp32_3MB.csv
build_flags = ${dualcore.build_flags}
[env:esp32c3]
board = esp32-c3-devkitm-1
@ -54,6 +63,7 @@ board_build.partitions = esp32_3MB.csv
[env:esp32s3]
board = esp32-s3-devkitc-1
build_flags = ${dualcore.build_flags}
[env:esp32c6]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip