Page 1 of 1

BLE scan, automatic light sleep and GPIO wakeup

Posted: Fri Apr 07, 2023 1:40 pm
by JVKran
Hi there!

I've taken the BLE ibeacon example and applied the configuration as described here to it to be able to reduce power consumption.

Now I'd like to add an LED with button to it. As soon as the button is pressed, the led should turn on. The use-case is slightly different, but lets just use this case as example. Because in the power configuration I configured automatic light sleep is allowed, light sleep is entered outside of the scan window, which is configured as half of the scan period.

During this light sleep, the button is ignored unless I execute the code underneath. This however, appears to stop bluetooth from scanning whenever the button is pressed. When the timing is 'just right', Bluedroid doesn't fire the ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT event, but scanning just stops and it appears light sleep is not entered again. Also check the screenshot underneath.

Code: Select all

gpio_wakeup_enable(GPIO_NUM_12, GPIO_INTR_HIGH_LEVEL);
esp_sleep_enable_gpio_wakeup();
The red part indicates the time in which scanning works, green where button is pressed, and blue where it does no longer work.

I understand that with light sleep code execution resumes from where it left off before entering light sleep, but I think there must be some way to make this possible. Please advise how to be able to use automatic light sleep with ble scan windows and a gpio wakeable button.

Kind regards,

Jochem

Re: BLE scan, automatic light sleep and GPIO wakeup

Posted: Wed May 03, 2023 7:34 am
by JVKran
Hi!

Almost a month has passed, and I still haven't found a solution. Could anyone please look into this? In the meantime, I'll try to get it to work from time to time and report back if I find any solution.

Kind regards,

Jochem

Re: BLE scan, automatic light sleep and GPIO wakeup

Posted: Thu May 04, 2023 3:54 am
by ESP_Sprite
If you can whittle this down to a small example that reproduces this, can you perhaps post an issue on the ESP-IDF Github? This sounds like something that our BT people need to take look at, and that's an easier way to make sure it reaches them.

Re: BLE scan, automatic light sleep and GPIO wakeup

Posted: Sun Jun 09, 2024 12:27 am
by Saikarthik
Hi, I think that you need to save the state of GPIO pin once triggerd , use it in a variable that changes accordingly.