diff --git a/components/esp_matter/esp_matter_client.cpp b/components/esp_matter/esp_matter_client.cpp index 9c58a72ae..30d5ad26a 100644 --- a/components/esp_matter/esp_matter_client.cpp +++ b/components/esp_matter/esp_matter_client.cpp @@ -116,12 +116,12 @@ static void esp_matter_command_client_binding_callback(const EmberBindingTableEn ESP_LOGE(TAG, "Failed to call the binding callback since command handle is NULL"); return; } - if (binding.type == EMBER_UNICAST_BINDING && !cmd_handle->is_group && peer_device) { + if (binding.type == EMBER_UNICAST_BINDING && peer_device) { if (client_command_callback) { cmd_handle->endpoint_id = binding.remote; client_command_callback(peer_device, cmd_handle, command_callback_priv_data); } - } else if (binding.type == EMBER_MULTICAST_BINDING && cmd_handle->is_group && !peer_device) { + } else if (binding.type == EMBER_MULTICAST_BINDING && !peer_device) { if (client_group_command_callback) { cmd_handle->group_id = binding.groupId; client_group_command_callback(binding.fabricIndex, cmd_handle, command_callback_priv_data); diff --git a/components/esp_matter/esp_matter_core.h b/components/esp_matter/esp_matter_core.h index 5971dd5ff..7459c91ba 100644 --- a/components/esp_matter/esp_matter_core.h +++ b/components/esp_matter/esp_matter_core.h @@ -763,19 +763,11 @@ typedef struct command_handle { }; uint32_t cluster_id; uint32_t command_id; - void *command_data { NULL }; - bool is_group; + void *command_data; command_handle() : endpoint_id(chip::kInvalidEndpointId), cluster_id(chip::kInvalidClusterId), - command_id(chip::kInvalidCommandId), command_data(NULL), is_group(false) {} - command_handle(struct command_handle* cmd) : cluster_id(cmd->cluster_id), command_id(cmd->command_id), - command_data(cmd->command_data), is_group(cmd->is_group) - { - if (cmd->is_group) { - this->group_id = cmd->group_id; - } else { - this->endpoint_id = cmd->endpoint_id; - } - } + command_id(chip::kInvalidCommandId), command_data(NULL){} + command_handle(struct command_handle* cmd) : endpoint_id(cmd->endpoint_id), cluster_id(cmd->cluster_id), + command_id(cmd->command_id), command_data(cmd->command_data) {} } command_handle_t; /** Peer device handle */ diff --git a/examples/esp-now_bridge_light/main/app_driver.cpp b/examples/esp-now_bridge_light/main/app_driver.cpp index 8ebd7da18..ffd58e9ef 100644 --- a/examples/esp-now_bridge_light/main/app_driver.cpp +++ b/examples/esp-now_bridge_light/main/app_driver.cpp @@ -32,36 +32,12 @@ static esp_err_t app_driver_bound_console_handler(int argc, char **argv) printf("Bound commands:\n" "\thelp: Print help\n" "\tinvoke: parameters ... \n" - "\t\tExample: matter esp bound invoke 0x0001 0x0008 0x0000 0x50 0x0 0x1 0x1.\n" - "\tinvoke-group: parameters ...\n" - "\t\tExample: matter esp bound invoke-group 0x0001 0x0008 0x0000 0x50 0x0 0x1 0x1.\n"); + "\t\tExample: matter esp bound invoke 0x0001 0x0008 0x0000 0x50 0x0 0x1 0x1.\n"); } else if (argc >= 4 && strncmp(argv[0], "invoke", sizeof("invoke")) == 0) { client::command_handle_t cmd_handle; uint16_t local_endpoint_id = strtoul((const char *)&argv[1][2], NULL, 16); cmd_handle.cluster_id = strtoul((const char *)&argv[2][2], NULL, 16); cmd_handle.command_id = strtoul((const char *)&argv[3][2], NULL, 16); - cmd_handle.is_group = false; - - if (argc > 4) { - console_buffer[0] = argc - 4; - for (int i = 0; i < (argc - 4); i++) { - if ((argv[4+i][0] != '0') || (argv[4+i][1] != 'x') || (strlen((const char*)&argv[4+i][2]) > 10)) { - ESP_LOGE(TAG, "Incorrect arguments. Check help for more details."); - return ESP_ERR_INVALID_ARG; - } - strcpy((console_buffer + 1 + 10*i), &argv[4+i][2]); - } - - cmd_handle.command_data = console_buffer; - } - - client::cluster_update(local_endpoint_id, &cmd_handle); - } else if (argc >= 4 && strncmp(argv[0], "invoke-group", sizeof("invoke-group")) == 0) { - client::command_handle_t cmd_handle; - uint16_t local_endpoint_id = strtoul((const char *)&argv[1][2], NULL, 16); - cmd_handle.cluster_id = strtoul((const char *)&argv[2][2], NULL, 16); - cmd_handle.command_id = strtoul((const char *)&argv[3][2], NULL, 16); - cmd_handle.is_group = true; if (argc > 4) { console_buffer[0] = argc - 4; @@ -104,7 +80,6 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) cmd_handle.endpoint_id = strtoul((const char *)&argv[3][2], NULL, 16); cmd_handle.cluster_id = strtoul((const char *)&argv[4][2], NULL, 16); cmd_handle.command_id = strtoul((const char *)&argv[5][2], NULL, 16); - cmd_handle.is_group = false; if (argc > 6) { console_buffer[0] = argc - 6; @@ -126,7 +101,6 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) cmd_handle.group_id = strtoul((const char *)&argv[2][2], NULL, 16); cmd_handle.cluster_id = strtoul((const char *)&argv[3][2], NULL, 16); cmd_handle.command_id = strtoul((const char *)&argv[4][2], NULL, 16); - cmd_handle.is_group = true; if (argc > 5) { console_buffer[0] = argc - 5; diff --git a/examples/esp-now_bridge_light/main/app_espnow.cpp b/examples/esp-now_bridge_light/main/app_espnow.cpp index 0832aeadf..0bcec20c1 100644 --- a/examples/esp-now_bridge_light/main/app_espnow.cpp +++ b/examples/esp-now_bridge_light/main/app_espnow.cpp @@ -42,7 +42,6 @@ static void espnow_ctrl_onoff(espnow_addr_t src_addr, bool status) } else { cmd_handle.command_id = OnOff::Commands::Off::Id; } - cmd_handle.is_group = false; uint16_t bridged_switch_endpoint_id = app_bridge_get_matter_endpointid_by_espnow_macaddr(src_addr); ESP_LOGI(TAG, "Using bridge endpoint: %d", bridged_switch_endpoint_id); diff --git a/examples/light_switch/main/app_driver.cpp b/examples/light_switch/main/app_driver.cpp index 2221a9dc1..01bf6bb30 100644 --- a/examples/light_switch/main/app_driver.cpp +++ b/examples/light_switch/main/app_driver.cpp @@ -36,37 +36,12 @@ static esp_err_t app_driver_bound_console_handler(int argc, char **argv) printf("Bound commands:\n" "\thelp: Print help\n" "\tinvoke: parameters ... \n" - "\t\tExample: matter esp bound invoke 0x0001 0x0003 0x0000 0x78.\n" - "\tinvoke-group: parameters ...\n" - "\t\tExample: matter esp bound invoke-group 0x0001 0x0003 0x0000 0x78.\n"); + "\t\tExample: matter esp bound invoke 0x0001 0x0003 0x0000 0x78.\n"); } else if (argc >= 4 && strncmp(argv[0], "invoke", sizeof("invoke")) == 0) { client::command_handle_t cmd_handle; uint16_t local_endpoint_id = strtoul((const char *)&argv[1][2], NULL, 16); cmd_handle.cluster_id = strtoul((const char *)&argv[2][2], NULL, 16); cmd_handle.command_id = strtoul((const char *)&argv[3][2], NULL, 16); - cmd_handle.is_group = false; - - if (argc > 4) { - console_buffer[0] = argc - 4; - for (int i = 0; i < (argc - 4); i++) { - if ((argv[4 + i][0] != '0') || (argv[4 + i][1] != 'x') || - (strlen((const char *)&argv[4 + i][2]) > 10)) { - ESP_LOGE(TAG, "Incorrect arguments. Check help for more details."); - return ESP_ERR_INVALID_ARG; - } - strcpy((console_buffer + 1 + 10 * i), &argv[4 + i][2]); - } - - cmd_handle.command_data = console_buffer; - } - - client::cluster_update(local_endpoint_id, &cmd_handle); - } else if (argc >= 4 && strncmp(argv[0], "invoke-group", sizeof("invoke-group")) == 0) { - client::command_handle_t cmd_handle; - uint16_t local_endpoint_id = strtoul((const char *)&argv[1][2], NULL, 16); - cmd_handle.cluster_id = strtoul((const char *)&argv[2][2], NULL, 16); - cmd_handle.command_id = strtoul((const char *)&argv[3][2], NULL, 16); - cmd_handle.is_group = true; if (argc > 4) { console_buffer[0] = argc - 4; @@ -108,7 +83,6 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) cmd_handle.endpoint_id = strtoul((const char *)&argv[3][2], NULL, 16); cmd_handle.cluster_id = strtoul((const char *)&argv[4][2], NULL, 16); cmd_handle.command_id = strtoul((const char *)&argv[5][2], NULL, 16); - cmd_handle.is_group = false; if (argc > 6) { console_buffer[0] = argc - 6; @@ -131,7 +105,6 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) cmd_handle.group_id = strtoul((const char *)&argv[2][2], NULL, 16); cmd_handle.cluster_id = strtoul((const char *)&argv[3][2], NULL, 16); cmd_handle.command_id = strtoul((const char *)&argv[4][2], NULL, 16); - cmd_handle.is_group = true; if (argc > 5) { console_buffer[0] = argc - 5; @@ -260,7 +233,6 @@ static void app_driver_button_toggle_cb(void *arg, void *data) client::command_handle_t cmd_handle; cmd_handle.cluster_id = OnOff::Id; cmd_handle.command_id = OnOff::Commands::Toggle::Id; - cmd_handle.is_group = false; lock::chip_stack_lock(portMAX_DELAY); client::cluster_update(switch_endpoint_id, &cmd_handle);