client: remove is_group in command_handle to make cluster_update be able to notify all the binding entries

closes CON-874
This commit is contained in:
WanqQixiang
2023-11-09 15:47:13 +08:00
parent 1ff7b63828
commit 12e73847aa
5 changed files with 8 additions and 71 deletions
+2 -2
View File
@@ -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);
+4 -12
View File
@@ -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 */
@@ -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: <local_endpoint_id> <cluster_id> <command_id> parameters ... \n"
"\t\tExample: matter esp bound invoke 0x0001 0x0008 0x0000 0x50 0x0 0x1 0x1.\n"
"\tinvoke-group: <local_endpoint_id> <cluster_id> <command_id> 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;
@@ -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);
+1 -29
View File
@@ -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: <local_endpoint_id> <cluster_id> <command_id> parameters ... \n"
"\t\tExample: matter esp bound invoke 0x0001 0x0003 0x0000 0x78.\n"
"\tinvoke-group: <local_endpoint_id> <cluster_id> <command_id> 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);