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

Connecting an ESP32-C6 with "Zigbee_Light_Bulb" example to the Philips Hue Bridge (TZ-919) #358

Open
m4nu-el opened this issue Jun 5, 2024 · 9 comments
Labels

Comments

@m4nu-el
Copy link

m4nu-el commented Jun 5, 2024

Question

Lately I was experimenting with a Waveshare ESP32-C6-DEV-KIT-N8 and zigbee communication. I got the communication working with another ESP32-C6 (loaded with Zigbee_Light_Switch.ino example). However I'd like to connect the ESP32-C6 with my Hue Bridge to later control a light connected to ESP32-C6. When I start searching for a new light with the hue bridge I get an ZDO signal with ZDO Leave (0x3). As soon as the the Hue Bridge stops searching, this signal also disappeares (as shown in the logs).

[ 278][I][sketch_jun5d.ino:107] esp_zb_app_signal_handler(): ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL [ 288][I][sketch_jun5d.ino:75] esp_zb_app_signal_handler(): Zigbee stack initialized [ 297][I][sketch_jun5d.ino:81] esp_zb_app_signal_handler(): Device started up in factory-reset mode [ 307][I][sketch_jun5d.ino:83] esp_zb_app_signal_handler(): Start network formation [ 2540][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 6311][I][sketch_jun5d.ino:107] esp_zb_app_signal_handler(): ZDO signal: ZDO Leave (0x3), status: ESP_OK [ 6321][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 10093][I][sketch_jun5d.ino:107] esp_zb_app_signal_handler(): ZDO signal: ZDO Leave (0x3), status: ESP_OK [ 10103][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 13875][I][sketch_jun5d.ino:107] esp_zb_app_signal_handler(): ZDO signal: ZDO Leave (0x3), status: ESP_OK [ 13885][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 17719][I][sketch_jun5d.ino:107] esp_zb_app_signal_handler(): ZDO signal: ZDO Leave (0x3), status: ESP_OK [ 17729][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 21498][I][sketch_jun5d.ino:107] esp_zb_app_signal_handler(): ZDO signal: ZDO Leave (0x3), status: ESP_OK [ 21508][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 24744][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 27981][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 31218][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL) [ 34455][I][sketch_jun5d.ino:103] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL)

I already read about this problem in this issue: #168 . However I haven't understood how to optain that key. I found some blogs online where people tried to optain that key by sniffing the connection with wireshark like here: https://www.hal9k.dk/sniffing-philips-hue-zigbee-traffic-with-wireshark/. I also found this resource https://moh-computer.de/zigbee-zll-master-key-fuer-philips-hue/. With the key from the last resource I modified the esp_zb_task().

static void esp_zb_task(void *pvParameters) {
  esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
  esp_zb_init(&zb_nwk_cfg);
  esp_zb_enable_joining_to_distributed(true); // not declared in scope
  uint8_t secret_zll_trust_center_key[] = { 0x9F, 0x55, 0x95, 0xF1, 0x02, 0x57, 0xC8, 0xA4, 0x69, 0xCB, 0xF4, 0x2B, 0xC9, 0x3F, 0xEE, 0x31 };
  esp_zb_secur_TC_standard_distributed_key_set(secret_zll_trust_center_key);
  esp_zb_on_off_light_cfg_t light_cfg = ESP_ZB_DEFAULT_ON_OFF_LIGHT_CONFIG();
  esp_zb_ep_list_t *esp_zb_on_off_light_ep = esp_zb_on_off_light_ep_create(HA_ESP_LIGHT_ENDPOINT, &light_cfg);
  esp_zb_device_register(esp_zb_on_off_light_ep);
  esp_zb_core_action_handler_register(zb_action_handler);
  esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
  //Erase NVRAM before creating connection to new Coordinator
  esp_zb_nvram_erase_at_start(true);  //Comment out this line to erase NVRAM data if you are conneting to new Coordinator
  ESP_ERROR_CHECK(esp_zb_start(false));
  esp_zb_main_loop_iteration();
}

However as commented in the code, the function esp_zb_enable_joining_to_distributed(true) is not declared in scope. I checked the docs here: components/esp-zigbee-lib/include/esp_zigbee_core.h and seems like the function is only declared when the constant ZB_DISTRIBUTED_SECURITY_ON is defined. But still with this constant defined in the Zigbee_Light_Bulb.ino the compiler throws the same error.

To summarize I'd like to know what I'm doing wrong when trying to connect the ESP to the Hue Bridge.

Additional context.

I am using the Arduino IDE 2.3.2 and the esp32 3.0.0 Board Package

@github-actions github-actions bot changed the title Connecting an ESP32-C6 with "Zigbee_Light_Bulb" example to the Philips Hue Bridge Connecting an ESP32-C6 with "Zigbee_Light_Bulb" example to the Philips Hue Bridge (TZ-919) Jun 5, 2024
@xieqinan
Copy link
Contributor

xieqinan commented Jun 6, 2024

@m4nu-el ,

Which version of the library are you using in your project? I tested the esp_zb_enable_joining_to_distributed(true); API on my side with the esp-zigbee-sdk v1.3.2, and it worked as expected. The issue may be triggered by the use of the Arduino IDE 2.3.2 and the esp32 3.0.0 Board Package. Could you please confirm the version of the libraries you are using first?

@m4nu-el
Copy link
Author

m4nu-el commented Jun 6, 2024

@xieqinan, I haven't included the libraries by myself so they don't appear in the Library Manager. I was just using the example that was included in the esp32 Board Backage. I wanted to try it with the esp-idf in vs code but I haven't got it running yet. Still trying to understand it :-)

@MakMaciej
Copy link

have you figured something out? trying to and running the code but its till just displays "ZDO signal: ZDO Leave (0x3)"

@m4nu-el
Copy link
Author

m4nu-el commented Jun 18, 2024

Nope, unfortunately nothing new. @MakMaciej have you used the Arduino IDE or the esp-idf? Maybe anyone who contributed to the arduino implementation got an idea?

@MakMaciej
Copy link

@m4nu-el I used the esp-idf.

@Haerteleric
Copy link

you got the wrong key mate. check out this post :

https://blog.smartere.dk/2019/03/sniffing-philips-hue-zigbee-traffic-with-wireshark/

@m4nu-el
Copy link
Author

m4nu-el commented Dec 25, 2024

Thanks man for your answer, I already thought this issue is already dead. I checked out the post again and tried all the 3 different Key-Transport keys for the uint8_t secret_zll_trust_center_key[] but unfortunately no better result.

@xieqinan
Copy link
Contributor

Hi @m4nu-el,

I believe the issue is caused because esp_zb_enable_joining_to_distributed(true); cannot be called in Arduino IDE 2.3.2. Since the Philips Hue Bridge acts as a distributed router, this function is essential. Could you also submit an issue to Arduino to confirm this? If the API is available, I think the code should work fine. Or combine the esp-zigbee-sdk and esp-idf to run the code.

@MakMaciej
Copy link

you got the wrong key mate. check out this post :

https://blog.smartere.dk/2019/03/sniffing-philips-hue-zigbee-traffic-with-wireshark/

so i need to get the Key-Transport Key? or what do you mean? use the first or third key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants