bleak icon indicating copy to clipboard operation
bleak copied to clipboard

Pair with devices that are not connected

Open hbldh opened this issue 5 years ago • 3 comments

Pairing was added in version 0.8.0. It still requires connect to be called first, due to that the OS native device communication objects being created in the connect methods (setting of the self._requester attributes). One could refactor this so that pair and unpair could be called on unconnected BleakClients as well.

hbldh avatar Sep 25 '20 09:09 hbldh

Since pairing requires communicating with the remote device, I don't see how pairing could be done without connecting first.

dlech avatar Sep 03 '22 01:09 dlech

The BlueZ D-Bus API docs for "Pair" says:

This method will connect to the remote device, initiate pairing and then retrieve all SDP records (or GATT primary services).

And the Windows API doesn't really have a notion of being "connected", so it seems like it should be possible to pair without an active gatt session.

macOS doesn't allow explicit pairing, but rather prompts for it automatically the first time you try to access a characteristic that requires authentication.

The Android API doesn't say one way or the other. https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createBond()

dlech avatar Sep 20 '22 15:09 dlech

And the Windows API doesn't really have a notion of being "connected", so it seems like it should be possible to pair without an active gatt session.

This is correct at least for BlueZ, tested with https://github.com/hbldh/bleak/pull/1133/commits/dd50aa66730f80e95ca43acd69b2e7a9f2e67043#diff-dca4aa1d374b221291b543a5d1296bbf912b43d1e2ebc51ed11c1eb153fbb89bR193-R196

bojanpotocnik avatar Nov 25 '22 11:11 bojanpotocnik