Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
BLE.stopScanning()
on Gen 4 is broken since 5.8.2 from inside ble scan result callback.scan()
andstopScanning()
is currently slightly different. Also different with indefinite/timed scans.Solution
hal_ble_gap_stop_scanning()
is called from inside the ble event thread (the one ble results are being notified to the application from)2.1.
BLE.scan()
is blocking no matter the timeout, but once scanning is started - BLE lock is not held, allowing other BLE operations to be performed.2.2.
BLE.stopScanning()
works correctly when called both from inside the scan result callback/other BLE callbacks and from some other thread (be that application/system/timer/custom etc).2.3. If called from a normal thread
BLE.stopScanning()
is a blocking operation and scanning MUST be stopped once its execution completes.Steps to Test
For cross-platform testing with test runner: particle-iot/device-os-test-runner#28
Example App
References
Links to the Community, Docs, Other Issues, etc..
Completeness