-
Notifications
You must be signed in to change notification settings - Fork 26
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
esp_zb_sleep_now() does not wake up from gpio (TZ-268) #99
Comments
@blastrock To enable wake-up from sleep using GPIO, you should call |
Hello @kelin6 how are you?, is it possible to modify the time spent by the zigbee stack? In the Nordic zigbee sdk, it is possible to modify this time that is passed to the zb_osif_sleep function, in order to force more or less sleep time. |
@agustinebrecht In the Nordic zigbee stack, there's a function call If you wish to extend or shorten the sleep duration, you can adjust the value of ED_KEEP_ALIVE |
Thank you very much for your reply @kelin6 . I take the opportunity to ask her about the gpio wake up that she mentioned to @blastrock . How do I indicate which pins have to wake me up due to interruption and which ones don't? since I have seen that the esp32H2 does not have configurations enabled in the esp-idf to establish that gpio raises the micro |
Thanks for the answer, I experimented a bit more. Unfortunately, moving the esp_sleep_enable_gpio_wakeup call does not seem to change anything. I tried changing the value of
I am a bit surprised by this zigbee sleep API. Can't we ask the zigbee stack for how long we need to sleep (or let it set up the rtc wake up) and do the In case it helps, I pushed my code here |
|
How is it disabled? Is it the
I tried using RTC as you suggested. I completely disabled switch_driver.c's code so that the GPIO usage doesn't interfere with RTC, and I added this code to my main function:
I am using GPIO0 here. This code works when I test it with a |
Using the code above is indeed feasible, and I have tested it. The occasional |
Thanks a lot for your help! I realized that I have a couple bugs left. The first one is that when I press the button just before the zigbee task goes to sleep, the Then, I noticed that a new zigbee sdk was released, so I upgraded from 0.6.0 to 1.0.1 to see if the previous bug has been already fixed. Now, when I call
Sometimes it happens in another function like map_vram_to_pram, but I can't reproduce it anymore. I pushed my code here: https://github.com/blastrock/HA_on_off_light/blob/wip/main/esp_zb_light.c . I have disabled all the GPIO code, there is only the zigbee task left. Should I open another issue for this? EDIT: I just tried compiling the |
Hai @blastrock |
I haven't, I have no idea how I can investigate this bug. |
I have reported this as a proper issue in #148 to give it more visibility. It includes more detailed steps to reproduce the issue. |
The issue appears to be that According to your current code, When the button is pressed before the Zigbee stack can sleep, the Zigbee stack sends a sleep signal (
|
Yes, I changed that after your previous message, but didn't push my code yet, I was still experimenting.
According to this comment #148 (comment) ESP32-C6 is not supported at all...? I have just tested upgrading to 5.1.2, I can confirm that I'm using the right version:
However, I still have the exact same crash with the sleepy_end_device example. |
@blastrock Yes, as of The relevant support code for ESP32-C6 Zigbee sleep has been internally reviewed and merged. It may take a few weeks for these changes to be visible on GitHub. I will notify you promptly once the support is available on GitHub. |
I only have a C6, so I can't test on an H2. I just noticed I didn't specify I was using a C6 on this issue, sorry for that. I'll just wait for the next release then. Thanks for your help! |
@blastrock The C6 light sleep issue has been fixed in IDF master, could you update both esp-zigbee-sdk and esp-idf to the latest master? Let us know if you see any other issues. |
Thanks a lot for helping me out through this. Unfortunately I can't seem to make my code work. I have tested again my code with esp-idf's commit espressif/esp-idf@f0607f6 from master and esp-zigbee-sdk and zboss 1.0.6 which just got released. My ESP32-C6 now connects to the zigbee network and goes to sleep. I have set it up to wake up with EXT1 RTC and I use the GPIO interrupt to process the event. The problem is now that when the ESP goes back to sleep, it crashes. The stack trace does not contain my code, nor esp-zigbee-sdk's code, so I'm not sure where the bug is. Here is the log of the crash:
I pushed my latest code https://github.com/blastrock/HA_on_off_light/tree/wip . If I disable the zigbee task, my program does not crash. Also, I've made it so that the button only prints logs on the screen and commented the line that sends a zigbee command. |
@blastrock Based on your code, I have reproduced the same phenomenon. The issue lies in the fact that the task stack allocation for Below is the log during runtime and the current situation of RTC IO wakeup:
|
Thanks a lot for your help! So the short stack was indeed the cause of the crash. Are there tools to help debug that? Or was that just your intuition? Anyway, I have one last bug. When I press the button, I call It looks like |
@blastrock
Print the stack consumption in the "button_detected" task to determine that ESP_LOGI requires the most stack, almost 1 kbytes, while the "button_detected" task is allocated only 2 kbytes in total. When executing subsequent code, this leads to insufficient stack resources. Regarding the issue of "esp_zb_zcl_on_off_cmd_req waking up the Zigbee task to send the message", this is a known problem, and we are currently discussing potential solutions. |
Thanks for the tips, I'll check that next time I have a crash.
Ok, thanks for looking into it, I'll wait for your update then. |
Is there any update on this? When I try to send a button via light sleep, the behavior is still, that it sends it as soon as the task from Zigbee is woken up after the timer. I also tried to use vTaskResume with the handler of the Zigbee Main Task, but that didn't work either. |
@blastrock @susch19 @agustinebrecht , The esp-zigbee-sdk v1.2.2 now supports immediate wake up from GPIO. Could you please try using the new version to test this issue again? |
Just had the time to test it and it works wonderfully. I have an end device with 30s long poll interval, for "long" light sleeps and when I press a button the message is immediately send and received. The delay is nearly not existent / as good as with other zigbee end devices. |
Hello,
I'm trying to make my device sleep, and wake it up when a button is pressed. I am not sure what
esp_zb_sleep_now()
does. My signal handler looks like this:But when I push my button, the controller will not wake up from sleep. And when it wakes up, the cause is always 4 (the timer).
Is this supposed to work, and my issue is somewhere else? What does the
esp_zb_sleep_now()
function do? Is there a way to just callesp_light_sleep_start()
instead?The text was updated successfully, but these errors were encountered: