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:
Scan for devices
Connect to device using connectToAdvertisingDevice() while keeping the scan going
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
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:
connectToAdvertisingDevice()
while keeping the scan goingExpected 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 aboveThis issue is related to the library codeSmartphone / tablet
Peripheral device doesn't matter
Additional context