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

Performance issue with connectToAdvertisingDevice #873

Open
1 task
maBarabas opened this issue Jun 14, 2024 · 0 comments · May be fixed by #874
Open
1 task

Performance issue with connectToAdvertisingDevice #873

maBarabas opened this issue Jun 14, 2024 · 0 comments · May be fixed by #874

Comments

@maBarabas
Copy link

Describe the bug

connectToAdvertisingDevice always waits for prescanDuration before attempting to connect to a device. It causes every connection attempt to take at least prescanDuration.

The scan sessions is set up to end in prescanDuration here: https://github.com/PhilipsHue/flutter_reactive_ble/blame/96e083ac9edd2b6cb070f6534bb2309057257aa0/packages/flutter_reactive_ble/lib/src/device_connector.dart#L127, and the return below waits for the entire session to end before deciding if it should connect to the device or not.

If the device is scanned before prescanDuration, then we should connect to it immediately, instead of waiting out the prescanDuration to speed up connections.

To Reproduce
Steps to reproduce the behavior:

  1. Start a stopwatch
  2. Connect to one device using connectToAdvertisingDevice(), prescanDuration = 5 seconds
  3. Wait until connected
  4. End stopwatch

Observe measured time is about 5 seconds.

Expected behavior
A clear and concise description of what you expected to happen.

If the device is scanned in 100ms, then start connecting after 100ms instead of waiting for the full prescanDuration.

  • I tried doing the same with a general BLE scanner application (e.g. nRF Connect) and it exhibits the expected behavior as described above not a feature in a BLE scanner app

Smartphone / tablet

  • Device: any
  • OS: any
  • Package version: any

Peripheral device

  • Vendor, model: [e.g. Fitbit Versa, iPhone SE, or CUSTOM]
  • Does it run a custom firmware / software: yes / no

Additional context
Add any other context about the problem here.

@maBarabas maBarabas linked a pull request Jun 14, 2024 that will close this issue
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 a pull request may close this issue.

1 participant