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:
+8
-21
@@ -1,4 +1,5 @@
|
||||
#include "cmd_handler.h"
|
||||
#include "ota_session.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -88,33 +89,19 @@ esp_err_t msg_register_handler(uint16_t id, msg_callback_t cb) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t msg_post(uint16_t id, const uint8_t *data, size_t len) {
|
||||
if (cmd_queue == NULL) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
generic_msg_t msg = {.msg_id = id, .len = len, .payload = NULL};
|
||||
if (len > 0) {
|
||||
msg.payload = malloc(len);
|
||||
if (msg.payload == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
memcpy(msg.payload, data, len);
|
||||
}
|
||||
|
||||
if (xQueueSend(cmd_queue, &msg, pdMS_TO_TICKS(100)) != pdPASS) {
|
||||
free(msg.payload);
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void vCmdDispatcherTask(void *param) {
|
||||
(void)param;
|
||||
generic_msg_t msg;
|
||||
|
||||
while (1) {
|
||||
if (xQueueReceive(cmd_queue, &msg, portMAX_DELAY) == pdPASS) {
|
||||
if (!ota_session_uart_cmd_allowed(msg.msg_id)) {
|
||||
ESP_LOGW(TAG, "reject %s (0x%02x) during OTA session",
|
||||
message_type_name(msg.msg_id), (unsigned)msg.msg_id);
|
||||
free(msg.payload);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool handled = false;
|
||||
for (int i = 0; i < handler_count; i++) {
|
||||
if (handlers[i].msg_id == msg.msg_id) {
|
||||
|
||||
Reference in New Issue
Block a user