macOS 12+: Accept service UUIDs when scanning for devices #88
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.
Issue
In macOS 12 Monterey, developers have been reporting issues with CoreBluetooth device discovery. This issue manifests as a BLE scan returning no device results. This currently affects lots of BLE projects that use CoreBluetooth under the hood, such as Python Bleak.
Fix
The fix for this issue is to provide a non-empty list of service UUIDs to
scanForPeripheralsWithServices:options:
.More context
This issue (feature?) has not yet been officially acknowledged by Apple. In the meantime, other projects are working to add user ergonomics around this issue. Bleak warns users who do not provide a list of advertised service UUIDs that MacOS will not return any results for their scan.
To serve macOS users, I would like to add support for tinygo Bluetooth to take a list of advertised service UUIDs when starting to scan. This is a first attempt at adding support for this to the Darwin adapter.
I know this breaks the interface and will not compile, but I'd like to start a conversation with this first draft of code. I'm totally OK with maintainers editing this PR however they like. I'm not familiar with this codebase and want to help fit this fix into tinygo – how can I help?