BlueZ backend always thinks device is paired? #503
-
Hello all. Firstly, amazing work on this package! I've been making an app and testing on all platforms and it has been going pretty smoothly. However, I think I must be missing something obvious with the BlueZ backend. Maybe it's a bug but I think it's more likely I'm doing something dumb. The problem is I can never get it to attempt pairing. I first connect, then I try to pair but pair() always returns True because it thinks it is already paired. That is, the below code path is always followed (from bleak/backends/bluezdbus/client.py). async def pair(self, *args, **kwargs) -> bool:
"""Pair with the peripheral.
You can use ConnectDevice method if you already know the MAC address of the device.
Else you need to StartDiscovery, Trust, Pair and Connect in sequence.
Returns:
Boolean regarding success of pairing.
"""
# See if it is already paired.
reply = await self._bus.call(
Message(
destination=defs.BLUEZ_SERVICE,
path=self._device_path,
interface=defs.PROPERTIES_INTERFACE,
member="Get",
signature="ss",
body=[defs.DEVICE_INTERFACE, "Paired"],
)
)
assert_reply(reply)
if reply.body[0]:
return True I know that I'm not actually paired because there are no devices when running "paired-devices" from bluetoothctl. Before I do this, I am ensuring that the device (and in fact no devices) are paired via bluetoothctl. Also, I am able to pair with bluetoothctl and after doing so, the rest of the program is running as expected. I've attached a relevant log if that helps. So am I missing some pairing step for the BlueZ backend? FYI this is on the 0.11.0 release Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I have a feeling that At the very least, I think we can get rid of the bus call here. Since v0.11.0, Bleak has a cache of all property values, so we could read the |
Beta Was this translation helpful? Give feedback.
-
As of bleak 0.13.0a1, I no longer see this exact problem. I am still having problems programmatically pairing on Linux without CLI interaction but it looks like this is being handled in an open PR |
Beta Was this translation helpful? Give feedback.
As of bleak 0.13.0a1, I no longer see this exact problem. I am still having problems programmatically pairing on Linux without CLI interaction but it looks like this is being handled in an open PR