-
Notifications
You must be signed in to change notification settings - Fork 306
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
Method "Connect" with signature "" doesn't exist -> cannot pair device #150
Comments
I have been under the impression that pairing should not be required, and I have personally never needed it for my own usecases. When you say "custom BLE Device" what do you mean by that? The import asyncio
from bleak import discover
async def run():
devices = await discover()
for d in devices:
print("{0}: Address type: {1}".format(d, self.details["props"].get("AddressType", "Not Available")))
loop = asyncio.get_event_loop()
loop.run_until_complete(run()) I have been pondering adding a |
I work for a company and we are currently developing a new BLE smart home device. My task at the moment is to write a python script which connects the device to Windows and Linux machines. The device itself has an nrf52 Bluetooth controller. This device needs to be paired to the machine to actually read the characteristics. Under Windows, I managed to pair the device not via Bleak but rather with the UWP Bluetooth Samples (Scenario 8 to be precise). Which is not ideal but a story another issue :P And as I said, on Linux the pairing work via gatttool but only when SPECIFICALLY setting the address type to random. Otherwise it will not even connect. (Quick fix of your code in case someone else needs it:) import asyncio
from bleak import discover
async def run():
devices = await discover()
for d in devices:
print("{0}: Address type: {1}".format(d, d.details["props"].get("AddressType", "Not Available")))
loop = asyncio.get_event_loop()
loop.run_until_complete(run()) It seems like the address type is INDEED set to random. Which makes me curious why I needed to SPECIFICALLY set it in the gatttool. But anyway... We tried to implement the pairing into bluezdbus/client.py, which looks like this: async def pair(self, **kwargs) -> bool:
if await self.is_paired():
logger.debug("Device is already paired")
return True
logger.debug(
"Pairing with BLE device @ {0} with {1}".format(self.address, self.device)
)
try:
await self._bus.callRemote(
self._device_path,
"Pair",
interface="org.bluez.Device1",
destination="org.bluez",
).asFuture(self.loop)
except RemoteError as e:
raise BleakError(str(e))
if await self.is_paired():
logger.debug("Pairing successful.")
else:
raise BleakError(
"Pairing to {0} was not successful!".format(self.address)
)
return True That seemed to work but after the pairing we were not able to read the characteristics anymore. And some of our test devices wont be found at all anywhere in the hci0 adapter after that. Others work fine until trying to read a characteristic, then they are instantly disconnected. So I fear we ran into a problem where we are set on our own and you cannot help us any further in the paring process, am I right :/ ? |
@BlackHawk1912 have you tried to reproduce your issue with |
@5frank I just checked btmon and unfortunatly noticed the same behavior. The pairing SEEMS to work but as soon as I try to read something, the pairing AND the conenction are no more. I am now certain that I am facing a problem with the BlueZ stack or the DBus, rather than bleak themself. |
I have been experiencing the same problems with a new device I have obtained. It only occurs in the BlueZ backend, unpaired. I can connect just fine to it from Windows without pairing, so it should not be needed. I will keep investigating, but I have no idea as to a solution right now... |
Wow okay. Meanwhile we assumed it is a problem with the firmware on our device (which is currently in development to but works on all other devices) but we keep investigating the next days. I'll keep you updated if we find something. |
Okay, we seem to found the issue on our side. It was something with the firmware on our device not sending the right connection parameter i think. Unfortunately I can't point out what exactly was going on because I am not working on the firmware. @hbldh I have another question regarding how to get the alias name of the device I connected to. Should I open a new issue? Or can you give me a quick tip on how to get it without using the discovery? |
@BlackHawk1912 Curios if your issue was because bluez rejected a "Update connection parameter request" from the BLE device/server? In that case I would gladly discuss it in more details. |
@5frank Yes, it was an issue with the exchange of the connection parameter. It seems like If you want to start discussing, get in contact with me via mail. |
Hi, I am trying to connect a Huawaei Band 4 similar to the honor band 3 mentioned by @zyv using his script. I fail with the same error messages when using the bleak example code. Using bleak (0.5.1), bluez (5.50-1+b1) on debian.
with adjusted examples from: https://bleak.readthedocs.io/en/latest/usage.html Any ideas in which direction i should look for solutions? |
I will not look at this in the foreseeable future I am afraid. I am swamped with other (paid) work and cannot guarantee doing anything with this project for quite some time. I will still address PRs to |
@wompydomp I was having the same issue, in my case, reversing the order of bytes in the mac address fixes the issue. The MAC of the device is AA:01:01:E1:80:02 but the Dbus object path is "/org/bluez/hci0/dev_02_80_E1_01_01_AA" |
@Illule Is that so. If you send in an address |
bluetoothctl -v
) in case of Linux: 5.50Description
When trying to connect a custom BLE Device, I get the same error as in #55
org.freedesktop.DBus.Error.UnknownObject: Method "Connect" with signature "" on interface "org.bluez.Device1" doesn't exist
I use the discover beforehand but still get the error.
With the gatttool itself the connection is also not working. EXCEPT when I use the gatttool and set the addresstype to random (
sudo gatttool -t random -b D8:80:05:21:2F:99 -I
). Then it works.My idea was to use the BlueZ adapter-api call for ConnectDevice which can receive an AddressType of "random". But further investigation showed me, that you didn't implement this methode. And because I am trying to pair a device, I searched for the "Pair"-methode of the BlueZ device-api which is also not called from Bleak.
Can you please explain why that is and you online use the "Connect"-methode, and what can cause the Connect-signature problem?
The text was updated successfully, but these errors were encountered: