#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); }