-
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
HA_color_dimmable_light example does not properly rejoin network after reboot (TZ-49) #1
Comments
@jurriaan could you explain little more about how you make color dimmable light example to first joined and then failed to rejoin later? How the zigbee devices and roles you are setting? It would be good from my side to duplicate your failure situation. |
@jurriaan also, how do you make the color_dimmable_light example int to err_status !=OK when in the case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START/ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT? Maybe you could try to do the |
I will do some more tests tomorrow, but what I did was I paired the color dimmable light to my existing zigbee network. When I press reset/restart the ESP it disconnected and didn't rejoin the network. I had to permit joining to the network and pair the device again. I found this behavior weird, so I started to look into the other examples, that's when I noticed that In the HA_color_dimmable_light, on a When I changed the |
It is weird that when you reset/restart the ESP it always cause the I will check from my side to duplicate failure condition for the status !=ESP_OK, also check rejoin process if I could find. |
I'm going to do some more test with the original color_dimmable_light, since I just noticed I have changed more of the original example during my tests. It seems that calling esp_zb_start with true (auto_start enabled) also changes the behavior of the statuses returned. I enabled auto_start, since that's also what
I also modified the example to run in router mode instead of end device (since router mode is the common thing to use for powered lights). I will do new tests with the original example and report back! |
This shouldn't be a issue. You can choose light to be a router or end-device |
Report of my findings using the original exampleTested on esp-zigbee-sdk 1a52786, esp-idf 732df630cd56826bbf79da6643f9aa18c33a17cca with esp-zboss-lib 0.3.1. Initially I couldn't add the device to my network, noticed the default channel was 13, but my network is on 15. I updated the zb_fct partition with an updated channel mask of 0x8000, and now it seems like it starts to join in the ZHA integration of home assistant (which manages my zigbee network), however, during the initial phase of joining (device found - starting interview in home assistant) the esp crashes on the assert issue. This means it continuously tries to join my network, with a different NWK value. Then I added
When I restart the device, I do get a similar output to the above, which does give me the idea that it tries to fully rejoin the network every boot (please correct me if I'm wrong). I disable permit join on my network, since the device should've been joined successfully now and restart the device again. Now it stays in a loop of trying to join the network and crashing on the assert issue:
I'm not fully aware of how this works internally, but I do get the idea that this example does not properly persist the network parameters (or something) and just tries to join a new network every boot. Next thing I tried is using I rejoin the device to the network:
Which worked just fine, so I disable permit join on my network and then try to reboot the device. After the reboot the device becomes available immediately in my network!
The error I still see the assert issue happening a few times, it did connect properly a few times, but after some reboots it ended up with this state again unfortunately:
Just a guess here, but can it be that after a connection issue it forgets to connect to the network and tries to join a new network? This is the final diff of the example: diff --git a/examples/esp_zigbee_HA_sample/HA_color_dimmable_light/main/esp_zb_light.c b/examples/esp_zigbee_HA_sample/HA_color_dimmable_light/main/esp_zb_light.c
index 7f66485..2df9a85 100644
--- a/examples/esp_zigbee_HA_sample/HA_color_dimmable_light/main/esp_zb_light.c
+++ b/examples/esp_zigbee_HA_sample/HA_color_dimmable_light/main/esp_zb_light.c
@@ -86,7 +86,7 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
break;
case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
- if (err_status == ESP_OK) {
+ if (err_status != ESP_OK) {
ESP_LOGI(TAG, "Start network steering");
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
} else {
@@ -117,12 +117,13 @@ static void esp_zb_task(void *pvParameters)
/* initialize Zigbee stack with Zigbee end-device config */
esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
esp_zb_init(&zb_nwk_cfg);
+ esp_zb_set_network_channel(15);
/* set the color dimmable light device config */
esp_zb_color_dimmable_light_cfg_t light_cfg = ESP_ZB_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG();
esp_zb_ep_list_t *esp_zb_color_dimmable_light_ep = esp_zb_color_dimmable_light_ep_create(HA_ESP_LIGHT_ENDPOINT, &light_cfg);
esp_zb_device_register(esp_zb_color_dimmable_light_ep);
esp_zb_device_add_set_attr_value_cb(attr_cb);
- ESP_ERROR_CHECK(esp_zb_start(false));
+ ESP_ERROR_CHECK(esp_zb_start(true));
esp_zb_main_loop_iteration();
} |
This is what I am checking for.
Good to hear it works. For the assert failed as I mentioned in the esp-zboss-lib, we will fix that. |
It does work initially in that configuration, but it does unfortunately lose connection again a few reboots/crashes later. As mentioned can it be that also after a connection issue it forgets how to connect to the network and tries to join a new network? Thanks for the quick responses! :) |
Rejoin issue has been fixed in the latest release, please take a look |
Nice! it seems like the issue is fixed! |
Could you close the issue if you see this is fixed |
I'm currently trying the examples on a ESP32-C6, and it seems like the HA_color_dimmable_light does not properly rejoin the network after joining for the first time.
I do have the idea that it is due to the following code:
esp-zigbee-sdk/examples/esp_zigbee_HA_sample/HA_color_dimmable_light/main/esp_zb_light.c
Lines 87 to 95 in b8dd9c5
Which is the opposite way of handling compared to the
esp_HA_customized_switch
:esp-zigbee-sdk/examples/esp_zigbee_customized_devices/customized_client/main/esp_HA_customized_switch.c
Lines 189 to 209 in b8dd9c5
After replacing the code in HA_color_dimmable_light with that setup (so that it starts network steering when the err_status != ESP_OK), it properly rejoins (except for some crashes on
assert failed: zb_esp_radio_process zb_esp_mac.c:290 (false)
panics, see espressif/esp-zboss-lib#1).The text was updated successfully, but these errors were encountered: