Closed spark404 closed 1 year ago
We will provide API for this, thanks for pointing out
@spark404 The API is added here: https://github.com/espressif/esp-zigbee-sdk/blob/main/components/esp-zigbee-lib/include/esp_zigbee_secur.h#L117
Hi @chshu, thank you for doing this work.
It works like a charm in my test project. However I tried using this with the Zigbee device type set to "Zigbee End Device" and received the following error. If I set the device type to Zigbee Coordinator or Router device it works without problems.
/Users/hugo/.espressif/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/hugo/Projects/HackerHotelBadge/zll-light/managed_components/espressif__esp-zigbee-lib/lib/esp32c6/libesp_zb_api_ed.a(esp_zigbee_secur.c.obj): in function `.L0 ':
(.text.esp_zb_secur_TC_standard_distributed_key_set+0x4): undefined reference to `zb_zdo_set_tc_standard_distributed_key'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Thank you for your test. Currently, the end device of Zigbee does not support temporarily setting the distributed key. However, this feature will be fixed in the next week.
The current API doesn't expose a function to set the Standard Distributed Key. This would be nice to have in order to join networks that don't use the standard Zigbee Alliance Key Transport Key. Recognisable by having the Key Id set to 2 in the Security Control Field of the ZigBee Security Header.
This functionality is available in the boss library with the function call 'zb_zdo_set_tc_standard_distributed_key'. I was able to get my ZigBee device connected to the network by using a workaround. I reconfigured the on/off light example with 'CONFIG_ZB_ZCZR=y' to link against the zczr libraries that expose that function. And defined the function as external
extern void zb_zdo_set_tc_standard_distributed_key(unsigned char *key_ptr);
Calling this function with the correct key after invoking esp_zb_init allowed the module to extract the Standard Network Key from the Transport Key message. The module is correctly sending a Device Announcement with the network key.
Details: