Enable host OTA over BLE and harden ESP-NOW slave distribution.

Allow the same staged firmware upload path on BLE as UART, fix distribute stack/event-group crashes, and recover sticky slave OTA sessions instead of failing with err=4.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-01 20:42:14 +01:00
co-authored by Cursor
parent 567dab6d0a
commit ae8ef40820
16 changed files with 400 additions and 208 deletions
+2 -19
View File
@@ -1,5 +1,4 @@
#include "cmd_ota.h"
#include "app_config.h"
#include "led_ring.h"
#include "ota_espnow.h"
#include "ota_uart.h"
@@ -14,6 +13,8 @@ static const char *TAG = "[OTA_CMD]";
#define OTA_PREPARE_STACK 8192
#define OTA_PREPARE_PRIO 5
/* Block buffer is static .bss; stack is for nested EspNowMessage + encode buf +
* esp_now_send path. 4 KiB overflowed; 8 KiB matches the pre-crash budget. */
#define OTA_DIST_STACK 8192
#define OTA_DIST_PRIO 5
@@ -104,24 +105,10 @@ static void ota_prepare_task(void *param) {
vTaskDelete(NULL);
}
static bool ota_host_is_uart(void) {
const app_config_t *cfg = app_config_get();
if (cfg != NULL && cfg->host_ble) {
ESP_LOGW(TAG, "OTA requires UART host (DIP8=0); BLE host active");
return false;
}
return true;
}
static void handle_ota_start(const uint8_t *data, size_t len) {
alox_UartMessage uart_msg;
alox_OtaStartPayload req = alox_OtaStartPayload_init_zero;
if (!ota_host_is_uart()) {
send_ota_failed(20);
return;
}
if (uart_cmd_decode(data, len, &uart_msg) != ESP_OK) {
send_ota_failed( 2);
return;
@@ -349,10 +336,6 @@ static void ota_start_espnow_task(void *param) {
}
static void handle_ota_start_espnow(const uint8_t *data, size_t len) {
if (!ota_host_is_uart()) {
send_ota_failed(20);
return;
}
(void)data;
(void)len;