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

Adapter selection #86

Closed
Jakeler opened this issue Jun 27, 2022 · 1 comment · Fixed by #94
Closed

Adapter selection #86

Jakeler opened this issue Jun 27, 2022 · 1 comment · Fixed by #94
Assignees
Labels
enhancement New feature or request

Comments

@Jakeler
Copy link
Contributor

Jakeler commented Jun 27, 2022

Describe the solution you'd like
If there are multiple BLE adapters on the host it should be possible to specify which one is used for the server. Currently it picks just the first it finds on dbus: https://github.com/kevincar/bless/blob/v0.2.4/bless/backends/bluezdbus/dbus/utils.py#L33

I would keep the API similar to bleak, like BleakClient(adapter="hci1") or BleakScanner(adapter="hci1") it could be BlessServer(adapter="hci1").

Describe alternatives you've considered
Instead of just receiving a string, bless could offer a list_adapters() function. That would allow to get and pass objects with more data, for example the full bluez path, but I am not sure if this is really needed or helpful.
In any case such a function could be useful for users to find out adapter names.

Additional context
Seems to only be relevant for Linux (including Android on bleak).
More info about how this is handled on Mac or Windows is appreciated.

@kevincar kevincar added the enhancement New feature or request label Sep 7, 2022
@kevincar kevincar self-assigned this Nov 9, 2022
@kevincar
Copy link
Owner

kevincar commented Nov 9, 2022

Apologies for the delay. Linux implementation was a quick fix. Implemented a list_adapters() function as suggested.

As mentioned, the macOS and Windows implementations seem to be more involved. macOS previously provided a developer app called Bluetooth Explorer that allowed users to select the primary HCI adapter to use. With updates to BigSur and Monterey, this is no longer seems possible.

For Windows, there are UWP BluetoothAdaptor classes that represent BLE adapters but currently there is not a clear way to dictate which adapter supplies the GattServiceProvider for building the Gatt tree.

One approach I've started diving into is building compiled binaries that utilize the GattServiceProvider for windows and the CBPeripheralManager on macOS and running debuggers to pinpoint how the underlying API access and select the internal BLE adapters, but this is proving to take a bit more time than I have available for this issue at the moment.

Will merge updates to develop soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants