BLE scan, automatic light sleep and GPIO wakeup

JVKran
Posts: 18
Joined: Thu Mar 04, 2021 2:40 pm

BLE scan, automatic light sleep and GPIO wakeup

Postby JVKran » Fri Apr 07, 2023 1:40 pm

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
Attachments
Screenshot 2023-04-07 153740.png
Screenshot 2023-04-07 153740.png (154.57 KiB) Viewed 1952 times

JVKran
Posts: 18
Joined: Thu Mar 04, 2021 2:40 pm

Re: BLE scan, automatic light sleep and GPIO wakeup

Postby JVKran » Wed May 03, 2023 7:34 am

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

ESP_Sprite
Posts: 9580
Joined: Thu Nov 26, 2015 4:08 am

Re: BLE scan, automatic light sleep and GPIO wakeup

Postby ESP_Sprite » Thu May 04, 2023 3:54 am

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.

Saikarthik
Posts: 1
Joined: Sun Jun 09, 2024 12:19 am

Re: BLE scan, automatic light sleep and GPIO wakeup

Postby Saikarthik » Sun Jun 09, 2024 12:27 am

Hi, I think that you need to save the state of GPIO pin once triggerd , use it in a variable that changes accordingly.

Who is online

Users browsing this forum: No registered users and 114 guests