powerpods/main/cmd/cmd_ota_slave_progress.c
simon 16c521f71c Move UART command handlers into main/cmd/ for clearer layout.
Add cmd/ to CMake include paths and update documentation paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 22:49:11 +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);
}