Fix BLE adv timeout; ESP: don't sched handler on adv finish #9395
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9359.
common_hal_bleio_adapter_start_advertising()
BLE_HS_FOREVER
for espressif. UseBLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED
for nordic._common_hal_bleio_adapter_start_advertising()
, not in the parent routinecommon_hal_bleio_adapter_start_advertising()
, because callers to the former expect zero to work as an unlimited timeout.background_callback_add_core(&bleio_background_callback()
from_advertising_event()
. Scheduling the background task caused advertising to start up again. This caused a tight loop of advertising starting, finishing, and restarting, slowing down CircuitPython greatly. The reschedule does not appear to be necessary: it is not done in the equivalent nordic code. There is other code to restart the BLE workflow advertising as needed.Tested with heart rate monitor, iBBQ, and BLE UART.
@bablokb Could you test to see if this fixes #9359 for you? Thanks. It might also prevent #9362, if that error is a side effect of the tight loop mentioned above.
(Note: I have been unsuccessful in getting BLE workflow to work with PyLeap with 9.0.5 or recent builds including this, but I might be be doing something wrong.)