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

Implement delay to avoid system scanning throttling #6

Open
LouisCAD opened this issue Jun 6, 2019 · 0 comments
Open

Implement delay to avoid system scanning throttling #6

LouisCAD opened this issue Jun 6, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@LouisCAD
Copy link
Collaborator

LouisCAD commented Jun 6, 2019

Since API 24 (Android 7.0), only 5 scan starts are allowed for the app in windows of 30 seconds.

This gotcha is among the not well documented parts of Android BLE.

This should be easy to achieve with Flow (relates to #5).

Different scan throttling strategies might be allowed.

  • A "cautious" one could ensure all scan starts are spaced by 6 seconds delaying any start happening sooner.
  • An eager one could delay the 6th scan of the 30 seconds window.
  • A middle ground (possibly configurable) one could allow to be eager, but not too much to avoid delay if the scan starts count exceeds the 30s window limit. Could delay with a growing backoff (linear, exponential, or custom).
  • Finally, there could be a strategy to keep the started scans alive after flow cancellation for up to the duration of the 30s window, so if a new scan with the same filter is requested, it can be reused without counting in the scan starts quota.

This will need an instrumented test and/or a test app so we can rest assured all the strategies work as expected with the full range of their allowed parameters.

The reference test advertising device, its software and its config are yet to be determined.
A Raspeberry Pi 3 B running Android Things might be a good choice because of the low price point, and the Android APIs usable from Kotlin.

Last note: It might be interesting to see if we can handle a continuous scan by restarting frequently the scan as it should be easier with Flow (maybe using old BLE API if it works better), for devices that have malfunctioning bluetooth low energy (can often be determined with ease with Wi-Fi enabled).

@LouisCAD LouisCAD added the enhancement New feature or request label Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant