Fix web OTA upload and isolate OTA sessions across firmware and goTool.

Split ESP-NOW into core/master/slave modules, block non-OTA UART traffic during updates, and hold the host serial port exclusively so dashboard polling cannot interleave with firmware uploads.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 16:35:18 +02:00
co-authored by Cursor
parent 0cbc4d0644
commit 0eea27a876
29 changed files with 1828 additions and 1416 deletions
+7 -3
View File
@@ -178,7 +178,7 @@ Logging:
## Command handler
Generic dispatch for host commands (UART today; `msg_post()` for in-firmware sources later).
Generic dispatch for host commands over UART only.
```
UART → generic_msg_t queue → vCmdDispatcherTask → registered handler
@@ -188,7 +188,8 @@ UART → generic_msg_t queue → vCmdDispatcherTask → registered handler
|-----|-------------|
| `init_cmdHandler(queue)` | Start dispatcher task (priority 5) |
| `msg_register_handler(id, cb)` | Register callback; max 32 handlers |
| `msg_post(id, data, len)` | Enqueue from firmware (e.g. future ESP-NOW → PC path) |
During an OTA session (`ota_session_busy()`), the dispatcher rejects all UART commands except OTA_* and `OTA_SLAVE_PROGRESS` (see `ota_session.c`).
```c
typedef void (*msg_callback_t)(const uint8_t *data, size_t len);
@@ -519,7 +520,10 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
| `powerpod.c` | `app_main`, DIP/network config, init order |
| `powerpod.h` | Pin defines |
| `app_config.h` | `app_config_t` |
| `esp_now_comm.c/h` | WiFi, ESP-NOW, discover / slave info / OTA send |
| `esp_now_comm.c/h` | ESP-NOW init and recv router |
| `esp_now_core.c/h` | Shared WiFi, peer, send |
| `esp_now_master.c/h` | Master discover, monitor, unicast |
| `esp_now_slave.c/h` | Slave join, heartbeat, telemetry |
| `ota_uart.c/h` | Shared 4 KiB OTA flash buffer (UART + ESP-NOW) |
| `ota_espnow.c/h` | Master: distribute staged image to slaves |
| `cmd/cmd_ota.c/h` | UART OTA command handlers (master only) |