Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callback for resending the same command id value for cluster on_off (TZ-1526) #557

Open
igoshev-media opened this issue Feb 6, 2025 · 0 comments

Comments

@igoshev-media
Copy link

igoshev-media commented Feb 6, 2025

Is your feature request related to a problem?

I have a two-key Green Power switch. I was able to connect it to my ESP32-C6 board, and I get reports ( esp_zb_core_action_handler_register ) when pressing the 1-key "ON", when pressing the 2-key "OFF". But I do not receive a report on the repeated key press. When using the esp_zb_raw_command_handler_register function, I see that the repeated data is received. How can I configure the code to receive repeated presses?

`static esp_err_t zb_attribute_handler(const esp_zb_zcl_set_attr_value_message_t *message)
{
esp_err_t ret = ESP_OK;
bool light_state = 0;
ESP_RETURN_ON_FALSE(message, ESP_FAIL, "TAG", "Empty message");
ESP_RETURN_ON_FALSE(message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS, ESP_ERR_INVALID_ARG, "TAG", "Received message: error status(%d)",
message->info.status);
LOG(ESP_LOG_INFO, "Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)", message->info.dst_endpoint, message->info.cluster,
message->attribute.id, message->attribute.data.size);
if (message->info.dst_endpoint == HA_LIGHT_ENDPOINT) {
if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_ON_OFF) {
if (message->attribute.id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_BOOL) {
light_state = message->attribute.data.value ? *(bool *)message->attribute.data.value : light_state;
LOG(ESP_LOG_INFO, "Light sets to %s", light_state ? "On" : "Off");
}
}
}
return ret;
}
static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void *message)
{
esp_err_t ret = ESP_OK;
switch (callback_id) {
case ESP_ZB_CORE_SET_ATTR_VALUE_CB_ID:
ret = zb_attribute_handler((esp_zb_zcl_set_attr_value_message_t *)message);
break;
default:
LOG(ESP_LOG_WARN, "Receive Zigbee action(0x%x) callback", callback_id);
break;
}
return ret;
}
static void esp_zb_task(void *pvParameters)
{
esp_zb_cfg_t zb_nwk_cfg = {
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR,
.install_code_policy = INSTALLCODE_POLICY_ENABLE,
.nwk_cfg.zczr_cfg = {
.max_children = MAX_CHILDREN,
},
};
esp_zb_init(&zb_nwk_cfg);
esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);

esp_zb_zgp_set_skip_gpdf(!ZGP_COMBO_PROXY_ENABLED);
esp_zb_zgps_set_mapping_table((const esp_zb_zgps_mapping_entry_t **)zgp_mapping_table, &zgp_mapping_table_length);
esp_zb_zgps_set_communication_mode(ESP_ZB_ZGP_COMMUNICATION_MODE_GROUPCAST_DERIVED);
esp_zb_zgps_set_commissioning_exit_mode(ESP_ZGP_COMMISSIONING_EXIT_MODE_ON_PAIRING_SUCCESS);
esp_zb_zgps_set_commissioning_window(180);
esp_zb_zgps_set_functionality(ESP_ZGP_GPSB_FUNCTIONALITY, ESP_ZGP_ACTIVE_FUNCTIONALITY_ID);
esp_zb_zgps_set_security_level(ESP_ZB_ZGP_FILL_GPS_SECURITY_LEVEL(
    ESP_ZB_ZGP_SEC_LEVEL_FULL_NO_ENC, ESP_ZB_ZGP_SEC_LEVEL_PROTECTION_WITH_GP_LINK_KEY, ESP_ZB_ZGP_SEC_LEVEL_PROTECTION_DO_NOT_INVOLVE_TC));

esp_zb_ep_list_t *ep_list = esp_zb_ep_list_create();
esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create();
esp_zb_endpoint_config_t endpoint_config1 = {
    .endpoint = HA_LIGHT_ENDPOINT,
    .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID,
    .app_device_id = ESP_ZB_HA_REMOTE_CONTROL_DEVICE_ID,
    .app_device_version = 0,
};

esp_zb_attribute_list_t *basic_cluster = esp_zb_basic_cluster_create(NULL);
esp_zb_basic_cluster_add_attr(basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, ESP_MANUFACTURER_NAME);
esp_zb_basic_cluster_add_attr(basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, ESP_MODEL_IDENTIFIER);
esp_zb_cluster_list_add_basic_cluster(cluster_list, basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

esp_zb_cluster_list_add_on_off_cluster          (cluster_list, esp_zb_on_off_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

esp_zb_ep_list_add_ep(ep_list, cluster_list, endpoint_config1);
esp_zb_device_register(ep_list);

// https://github.com/espressif/esp-zigbee-sdk/issues/21
esp_zb_secur_link_key_exchange_required_set(false);

esp_zb_core_action_handler_register(zb_action_handler);
//esp_zb_raw_command_handler_register(rawCmdHandlerCb);
ESP_ERROR_CHECK(esp_zb_start(false));
esp_zb_stack_main_loop();
vTaskDelete(NULL);

}`

RAW Data:
cluster id: 0x6, command id: 1, dst_ep: 1, src_ep: 0 <--- There is a report on the switch
I (15154) RAW: bufid: 15 size: 0

cluster id: 0x6, command id: 0, dst_ep: 1, src_ep: 0 <--- There is a report on the switch
I (16904) RAW: bufid: 17 size: 0

cluster id: 0x6, command id: 0, dst_ep: 1, src_ep: 0 <--- This package does not appear in the esp_zb_core_action_handler_register(zb_action_handler) report;

Is it possible to set it to display all received events so that I can use each key separately?

Describe the solution you'd like.

No response

Describe alternatives you've considered.

At the moment the solution is only to analyze RAW data obtained using esp_zb_raw_command_handler_register...

Additional context.

No response

@github-actions github-actions bot changed the title Add callback for resending the same command id value for cluster on_off Add callback for resending the same command id value for cluster on_off (TZ-1526) Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant