powerpods/main/cmd_ota_slave_progress.c
simon a0f4a81a55 Add per-slave ESP-NOW OTA progress over UART and fix dashboard updates.
Expose OTA_SLAVE_PROGRESS on the master, track per-slave state during
distribution, run ESP-NOW OTA in a background task so the host can poll
while slaves update, and show master/slave progress in the dashboard
with table layout and faster WebSocket refresh during uploads.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 21:07:46 +02:00

38 lines
1.2 KiB
C

#include "cmd_ota_slave_progress.h"
#include "ota_espnow.h"
#include "uart_cmd.h"
#include "esp_log.h"
static const char *TAG = "[OTA_PROG]";
static void handle_ota_slave_progress(const uint8_t *data, size_t len) {
alox_UartMessage uart_msg;
uint32_t filter = 0;
if (uart_cmd_decode(data, len, &uart_msg) == ESP_OK) {
const alox_OtaSlaveProgressRequest *req =
UART_CMD_REQ(&uart_msg, alox_UartMessage_ota_slave_progress_request_tag,
ota_slave_progress_request);
if (req != NULL) {
filter = req->client_id;
}
}
alox_UartMessage response;
uart_cmd_init_response(
&response, alox_MessageType_OTA_SLAVE_PROGRESS,
alox_UartMessage_ota_slave_progress_response_tag);
ota_espnow_progress_query(filter, &response.payload.ota_slave_progress_response);
ESP_LOGI(TAG, "query client_id=%lu -> %u slave(s) active=%d",
(unsigned long)filter,
(unsigned)response.payload.ota_slave_progress_response.slaves_count,
(int)response.payload.ota_slave_progress_response.active);
uart_cmd_send(&response, TAG);
}
void cmd_ota_slave_progress_register(void) {
uart_cmd_register(alox_MessageType_OTA_SLAVE_PROGRESS,
handle_ota_slave_progress);
}