Files
powerpods/main/cmd/cmd_client_id_map_reset.c
skrueckenandCursor 567dab6d0a Assign sequential pod IDs from the master with NVS-stable bindings.
Replaces MAC-byte self-IDs with master allocation (1–255), slave preferred-ID reconnect, debug reset via UART/UI, and rate-limited ASSIGN to avoid ESP-NOW NO_MEM storms.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-01 17:25:07 +01:00

36 lines
1.0 KiB
C

#include "cmd_client_id_map_reset.h"
#include "esp_log.h"
#include "esp_now_comm.h"
#include "esp_now_core.h"
#include "uart_cmd.h"
static const char *TAG = "[ID_MAP_RESET]";
static void reply(bool success) {
alox_UartMessage response;
uart_cmd_init_response(&response, alox_MessageType_CLIENT_ID_MAP_RESET,
alox_UartMessage_client_id_map_reset_response_tag);
response.payload.client_id_map_reset_response.success = success;
uart_cmd_send(&response, TAG);
}
static void handle_client_id_map_reset(const uint8_t *data, size_t len) {
(void)data;
(void)len;
esp_err_t err;
if (esp_now_core_is_master()) {
ESP_LOGI(TAG, "reset master id map + notify online slaves");
err = esp_now_comm_reset_client_id_map();
} else {
ESP_LOGI(TAG, "clear local slave id binding");
err = esp_now_comm_clear_local_id_binding();
}
reply(err == ESP_OK);
}
void cmd_client_id_map_reset_register(void) {
uart_cmd_register(alox_MessageType_CLIENT_ID_MAP_RESET,
handle_client_id_map_reset);
}