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

connectToAdvertisingDevice while already scanning #872

Open
1 task
maBarabas opened this issue Jun 14, 2024 · 0 comments
Open
1 task

connectToAdvertisingDevice while already scanning #872

maBarabas opened this issue Jun 14, 2024 · 0 comments

Comments

@maBarabas
Copy link

Describe the bug

When connecting to a device while a scan is in progress, TimeoutException is thrown.

It looks like the intention was that the existing scan results can be reused for the connection and the connection should work. However, this only happens if the existing scan ends within the timeout here. If the scan ends early, then connection is attempted before prescanDuration has elapsed, so it seems like it doesn't work as intended. If the scan doesn't end within the timeout, then the connection is never attempted even if the device was scanned by the existing scan session.

To Reproduce
Steps to reproduce the behavior:

  1. Scan for devices
  2. Connect to device using connectToAdvertisingDevice() while keeping the scan going
  3. Connection fails with a prescanDuration + 1s timeout, and no stack trace

Expected behavior
Existing scan results are used to connect to the advertising device, instead of waiting for the existing scan to end in prescanDuration + 1s, then failing if it doesn't end.

  • I tried doing the same with a general BLE scanner application (e.g. nRF Connect) and it exhibits the expected behavior as described above This issue is related to the library code

Smartphone / tablet

  • Device: any, issue is in Dart code
  • OS: any, issue is in Dart code
  • Package version: any, same code exists in the initial commit

Peripheral device
doesn't matter

Additional context

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

No branches or pull requests

1 participant