-
Notifications
You must be signed in to change notification settings - Fork 25
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
ESP32C6 coordinator: Unable to receive attribute reports from devices (TZ-165) #42
Comments
hi @pieterjanbuntinx Your implemented callback for receiving attribute reports is missing the `static void esp_zb_dev_reporting_cb(esp_zb_zcl_addr_t *addr, uint8_t src_endpoint, uint8_t dst_endpoint, uint16_t cluster_id, { |
Hi @abdulrehmanee12, Sadly changing the callback function did not solve my issue. Otherwise, with the wrong callback, I would have expected the ESP to crash every time that callback was called. The esp_HA_customized_switch example is where I found the original callback. I must have copied it from an earlier version of the SDK. In that example, they bind the two devices. Is that necessary for reporting to work? I wanted to try and bind the devices but I was not able to create a find temp/humid sensor or find door sensor function as there exists in the example for the on_off_light (esp_zb_zdo_find_on_off_light). I was thinking of using the ZBOSS function |
@pieterjanbuntinx Yes, binding two devices is necessary for reporting to function correctly. At present, our SDK does not support the "find temp/humid sensor" or "find door sensor" functions. However, in our next release, we will introduce a common function that caters to those requirements. As an example for your work, here is a guide on how to achieve it: `void esp_zb_zdo_find_door_lock(esp_zb_zdo_match_desc_req_param_t *cmd_req, esp_zb_zdo_match_desc_callback_t user_cb, void *user_ctx) { }` |
Great thanks! I will try this out now. |
The IAS zone cluster has already been implemented in our SDK. To receive |
Correct me if I am wrong, but is this function not only for sending the status notifications? I need a function similar to
I was able to get most of it working. I now have the following code:
But I have the last two lines commented out. Most importantly, |
Yes, you're correct. We haven't tested receiving
It has already been implemented in our SDK and I tested it on my side. |
If I search on GitHub I cannot find any reference to |
Yes, my mistake. It's our internal implementation and is not currently exposed to users. However, in the next release, we plan to provide a common function that will support door sensors and temp/humid sensors. |
Okay, thanks! |
The ias zone cluster can not receive the status notification issue has been fixed in esp-zigbee-lib. Please update the latest esp-zigbee-sdk to fix your problem. |
@pieterjanbuntinx We have released a new version of esp_zigbee_sdk that includes the common function to find the matched cluster |
Thank you for the update @xieqinan & @abdulrehmanee12, Can my issue be reopened? void status_change_notif_cb(uint16_t zone_status, uint8_t extended_status, uint8_t zone_id, uint16_t delay) {
printf("(%lli) received stat_ch_notif: zone_status: %i, ext status: %i, zone_id: %i, delay: %i\n", esp_timer_get_time() / 1000, zone_status, extended_status, zone_id, delay);
}
#define EXTERNAL_DEVICES_ENDPOINT 1
static void esp_zb_task(void* pvParameters) {
/* initialize Zigbee stack with Zigbee coordinator config */
esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZC_CONFIG();
esp_zb_init(&zb_nwk_cfg);
/* create endpoint list */
esp_zb_ep_list_t* esp_zb_ep_list = esp_zb_ep_list_create();
/* create cluster list for external device endpoint */
esp_zb_cluster_list_t* esp_zb_external_devices_cluster_list = esp_zb_zcl_cluster_list_create();
/* create ias zone cluster with server parameters */
esp_zb_ias_zone_cluster_cfg_t zone_cfg = {
.zone_state = 0,
.zone_type = ESP_ZB_ZCL_IAS_ZONE_ZONETYPE_CONTACT_SWITCH,
.zone_status = 0,
.ias_cie_addr = ESP_ZB_ZCL_ZONE_IAS_CIE_ADDR_DEFAULT,
.zone_id = 0xFF,
};
esp_zb_attribute_list_t* esp_zb_ias_zone_cluster = esp_zb_ias_zone_cluster_create(&zone_cfg);
esp_zb_cluster_list_add_ias_zone_cluster(esp_zb_external_devices_cluster_list, esp_zb_ias_zone_cluster, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE);
/* create endpoint for external devices */
esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_external_devices_cluster_list, EXTERNAL_DEVICES_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_TEST_DEVICE_ID);
/* register endpoints */
esp_zb_device_register(esp_zb_ep_list);
esp_zb_add_ias_zone_status_notification_cb(EXTERNAL_DEVICES_ENDPOINT, status_change_notif_cb);
/* initiate Zigbee Stack start without zb_send_no_autostart_signal auto-start */
esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
ESP_ERROR_CHECK(esp_zb_start(false));
#if (CONFIG_ZB_RADIO_MACSPLIT_UART)
esp_zb_add_rcp_failure_cb(rcp_error_handler);
#endif
esp_zb_main_loop_iteration();
esp_rcp_update_deinit();
vTaskDelete(NULL);
}
|
Hi @xieqinan, I am trying to do step 5 from your screenshot but I am not sure how to send the enroll response command inside of the callback shown below. In this callback, I have no access to the ieee/short address of the device that has sent the enroll request. Can you maybe also link to the document where you got this screenshot from? I have found a similar document but from NXP, is there an ESP-specific document available?
|
Hi @pieterjanbuntinx ,
The current method should work, but it is not optimal; a better solution that the network address of request side will as the parameter of callback will be provided in esp-zigbee-sdk v1.0.0.
The screenshot is from the Zigbee Zcl library specification 8.2.2.1.3. |
I am having trouble writing the CIE address to the sensor. I am using the code below to write and read the CIE address to the door sensor. But it always reads out as 00:00:00:00:00:00:00:00 on one sensor and FF:FF:FF:FF:FF:FF:FF:FF on another.
If I don't create the IAS Zone cluster locally and don't bind it, I get the exact same behavior.
Will this be the next release? void esp_zb_app_signal_handler(esp_zb_app_signal_t* signal_struct) {
// (...)
switch (sig_type) {
// (...)
case ESP_ZB_ZDO_SIGNAL_DEVICE_ANNCE: {
dev_annce_params = (esp_zb_zdo_signal_device_annce_params_t*)esp_zb_app_signal_get_params(p_sg_p);
ESP_LOGI(TAG, "New device commissioned or rejoined (short: 0x%04hx)", dev_annce_params->device_short_addr);
// Write CIE address
esp_zb_zcl_write_attr_cmd_t req_param = {0};
req_param.zcl_basic_cmd.src_endpoint = 1;
req_param.zcl_basic_cmd.dst_endpoint = 1;
memcpy(req_param.zcl_basic_cmd.dst_addr_u.addr_long, dev_annce_params->ieee_addr, sizeof(esp_zb_ieee_addr_t));
req_param.clusterID = ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE;
req_param.attributeID = ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID;
req_param.attrType = ESP_ZB_ZCL_ATTR_TYPE_IEEE_ADDR;
esp_zb_ieee_addr_t addr = {0};
esp_zb_get_long_address(addr);
req_param.attrVal = addr;
esp_zb_zcl_write_attr_cmd_req(&req_param);
break;
}
// (...)
}
}
// (...)
// read CIE address
esp_zb_zcl_read_attr_cmd_t read_req;
read_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
read_req.attributeID = ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID;
read_req.clusterID = ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE;
read_req.zcl_basic_cmd.dst_endpoint = EXTERNAL_DEVICES_ENDPOINT;
read_req.zcl_basic_cmd.src_endpoint = EXTERNAL_DEVICES_ENDPOINT;
memcpy(read_req.zcl_basic_cmd.dst_addr_u.addr_long, test_addr, sizeof(esp_zb_ieee_addr_t));
esp_zb_zcl_read_attr_cmd_req(&read_req);
// (...)
|
With temperature/humidity sensors I get a similar behavior. The device joins the network, I do binding and configure reporting in the bind callback and the device starts sending reports for the configured attributes. But after like 10 seconds the device leaves the network and never rejoins. The device also seems to be in pairing mode with the led blinking. I (11590) COREDUMP_UPLOAD: reset reason is 3
I (12820) ESP_ZB_GATEWAY: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
I (13200) ESP_ZB_GATEWAY: Formed network successfully (ieee extended address: 18:97:40:fe:ff:ca:4c:40, PAN ID: 0x7166)
I (14030) ESP_ZB_GATEWAY: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
I (14430) ESP_ZB_GATEWAY: Network steering started
I (24800) ESP_ZB_GATEWAY: ZDO signal: NWK Device Associated (0x12), status: ESP_OK
I (25030) ESP_ZB_GATEWAY: ZDO signal: ZDO Device Update (0x30), status: ESP_OK
I (25890) ESP_ZB_GATEWAY: Switch got report attribute from address:0xfb3d,src_ep:1,dst_ep:1,cluster_id:0x405,attr_id:0x0,value:248,attr_type:0x21,
I (25910) ESP_ZB_GATEWAY: New device commissioned or rejoined (short: 0xfb3d)
Bind successful! (fb3d)
I (28870) ESP_ZB_GATEWAY: Switch got report attribute from address:0xfb3d,src_ep:1,dst_ep:1,cluster_id:0x402,attr_id:0x0,value:108,attr_type:0x29,
I (29070) ESP_ZB_GATEWAY: Switch got report attribute from address:0xfb3d,src_ep:1,dst_ep:1,cluster_id:0x405,attr_id:0x0,value:109,attr_type:0x21,
I (35050) ESP_ZB_GATEWAY: Switch got report attribute from address:0xfb3d,src_ep:1,dst_ep:1,cluster_id:0x402,attr_id:0x0,value:117,attr_type:0x29,
I (35090) ESP_ZB_GATEWAY: Switch got report attribute from address:0xfb3d,src_ep:1,dst_ep:1,cluster_id:0x405,attr_id:0x0,value:232,attr_type:0x21,
I (38050) ESP_ZB_GATEWAY: Switch got report attribute from address:0xfb3d,src_ep:1,dst_ep:1,cluster_id:0x402,attr_id:0x0,value:108,attr_type:0x29,
I (40080) ESP_ZB_GATEWAY: ZDO signal: ZDO Device Authorized (0x2f), status: ESP_OK
I (40880) ESP_ZB_GATEWAY: ZDO signal: ZDO Leave Indication (0x13), status: ESP_OK
I (40920) ESP_ZB_GATEWAY: ZDO signal: ZDO Leave Indication (0x13), status: ESP_OK // (...)
// is called when device has joined in esp_zb_app_signal_handler
esp_zb_zdo_bind_req_param_t bind_req;
memcpy(bind_req.src_address, device->ieee_addr, sizeof(esp_zb_ieee_addr_t));
bind_req.src_endp = 1;
bind_req.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
bind_req.dst_addr_mode = ESP_ZB_ZDO_BIND_DST_ADDR_MODE_64_BIT_EXTENDED;
esp_zb_get_long_address(bind_req.dst_address_u.addr_long);
bind_req.dst_endp = EXTERNAL_DEVICES_ENDPOINT;
bind_req.req_dst_addr = device->short_addr;
esp_zb_zdo_device_bind_req(&bind_req, bind_cb, (void*)device);
// (...)
// bind callback, attribute reporting is here configured
static void bind_cb(esp_zb_zdp_status_t zdo_status, void* user_ctx) {
if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
device_t* device = (device_t*)user_ctx;
printf("Bind successful! (%x)\n", device->short_addr);
/* configure report attribute command */
esp_zb_zcl_config_report_cmd_t report_cmd = {0};
int16_t report_change = 2;
memcpy(&report_cmd.zcl_basic_cmd.dst_addr_u.addr_long, device->ieee_addr, sizeof(esp_zb_ieee_addr_t));
report_cmd.zcl_basic_cmd.dst_endpoint = 1;
report_cmd.zcl_basic_cmd.src_endpoint = EXTERNAL_DEVICES_ENDPOINT;
report_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
report_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
report_cmd.attributeID = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID;
report_cmd.attrType = ESP_ZB_ZCL_ATTR_TYPE_S16;
report_cmd.min_interval = 1;
report_cmd.max_interval = 10;
report_cmd.reportable_change = (void*)&report_change;
esp_zb_zcl_config_report_cmd_req(&report_cmd);
}
} |
Let's address the leave indication problem first. Can you please refer to the related issue? Ensure the same preconfigured key between Zigbee gateway and the sensor. |
I have set |
Yes, it is a better way to join Zigbee network by the install code. |
ηι!!! |
before was esp_zb_add_ias_zone_status_notification_cb, what now need use for cb IAS zone change ? |
@straga , The By the way, this issue had been closed, please feel free to open new issue if you have questions for the esp-zigbee-sdk. |
Hi
I am developing a custom Zigbee gateway with an ESP32S3 as the main microcontroller and an ESP32C6 as the RCP. Currently, I am trying to receive attribute reports from some temperature/humidity sensors (Sonoff SNZB-02). I am using the
esp_zigbee_gateway
example (master & esp-idf v5.1rc2) with a few additions:But the callback
esp_zb_dev_reporting_cb
never seems to be called. When using Zigbee2MQTT I can see the received "attributeReport" message about every 10 minutes or when the temperature/humidity changes.Am I doing something wrong or is this something that does not work yet in the SDK?
For some door/window sensors, I have a similar issue. How can I have a callback when there is a "statusChangeNotification"?
The text was updated successfully, but these errors were encountered: