BLE scan, automatic light sleep and GPIO wakeup
Posted: 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.
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
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();
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