Skip to content
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

BLE observe fix #216

Merged
merged 4 commits into from
Jan 16, 2024
Merged

BLE observe fix #216

merged 4 commits into from
Jan 16, 2024

Conversation

dlech
Copy link
Member

@dlech dlech commented Nov 25, 2023

@coveralls
Copy link

coveralls commented Nov 25, 2023

Coverage Status

coverage: 56.508% (-0.09%) from 56.596%
when pulling 264dfae on ble-observe-fix
into 2d783d3 on master.

dlech added 4 commits January 16, 2024 08:51
This reverts commit 533ace0.

We will fix this a different way in a future commit.
The Bluetooth chip on the City and Technic hubs will stop receiving
advertisements after a while when observing. It isn't clear why this
is happening, but it seems to that there is a bug in the Bluetooth
chip firmware that causes it to start filtering out advertisements
from an individual advertiser after a while (i.e. it can still be
receiving advertisements from one device but stops receiving them
from another). Eventually it will stop receiving advertisements from
all devices.

To work around this, we restart the observation process every 10
seconds. In testing, we were never able to trigger the bug in less than
25 seconds or so. Therefore, 10 seconds should be more than enough to
ensure that we never miss an advertisement.

Fixes: pybricks/support#1096
This adds a task parameter to pbdrv_bluetooth_stop_observing(). This
allows us to partially fix a TODO of waiting for the observation to
stop before exiting the MicroPython runtime. Also in the case of the
CC2640, pbdrv_bluetooth_stop_observing() can be called from multiple
places, so to be safe, we need to make sure each caller has its own
task struct to avoid reentrancy issues.
This adds a task parameter to pbdrv_bluetooth_stop_broadcasting(). This
allows us to finish the TODO of waiting for the broadcasting to stop
before exiting the MicroPython runtime.
@laurensvalk
Copy link
Member

Thanks for this!

I'm doing a lot of Bluetooth revisions at the moment, so I'm going to bite the bullet and merge yours as-is and apply my changes on top.

@laurensvalk laurensvalk merged commit 264dfae into master Jan 16, 2024
38 checks passed
@laurensvalk laurensvalk deleted the ble-observe-fix branch January 16, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Observing eventually stops on City Hub and Technic Hub
3 participants