-
Notifications
You must be signed in to change notification settings - Fork 294
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
Connecting to Private Random Non-Resolvable address #363
Comments
I have no idea what “Private Random Non-Resolvable address” means and entails. Can you at least detect the device with discover or find_device_by_address? The BlueZ DBus API does not provide any public/private address distinction, so I have no idea how to solve this. |
Yes I can detect it with discover and even read the name. |
Perhaps I was wrong attributing it to the odd address scheme. Same problem after changing the device firmware to use "Private Random Resolvable address". |
Works after:
I also needed to power cycle the device. |
This dirty workaround solves it for now: from subprocess import Popen, run, PIPE
import time
def bluetoothctl(dev):
props = dev.details['props']
if not props:
loger.warning("No props")
return
logger.debug(str(props))
p = Popen("bluetoothctl", stdin=PIPE, stdout=PIPE, stderr=PIPE)
trusted = props.get("Trusted", False)
if not trusted:
cmd = "trust {}\n".format(dev.address)
p.stdin.write(cmd.encode())
time.sleep(1)
paired = props.get("Paired", False)
if not paired:
cmd = "pair {}\n".format(dev.address)
p.stdin.write(cmd.encode())
time.sleep(1)
if 1:
cmd = "quit\n"
p.stdin.write(cmd.encode())
time.sleep(1)
p.communicate()
logger.debug("bluethoothctl stdout:'%s', stderr:'%s'", str(p.stdout), str(p.stderr))
async def main():
dev = await discover(...)[0]
bluetoothctl(dev)
async with BleakClient(dev) as clnt:
... I suspect same thing could be done with the dbus interface. Still not sure if this counts as a bug or not? |
No problems connecting to same device in MacOS. |
You can pair in Bleak now as well (since 0.9.0): https://github.com/hbldh/bleak/blob/develop/bleak/backends/bluezdbus/client.py#L255-L315 First, it does a Trust call and then a Pair call to the DBus API. Try it out and see if it changes anything. |
embarrassing - pairing was needed. thanks! |
bluetoothctl -v
) in case of Linux: 5.50Description
I believe there is a issue connecting to devices with Private Random Non-Resolvable address. I have not yet excluded
other explanations, so if this address scheme is supposed to work, please close the issue. However, it seems to work with https://github.com/go-ble/ble (uses hci sockets) so looks like a bleak or bluez/dbus issue.
What I Did
The device is discovered but when trying to connect the device was "not found".
Log and traceback:
btmon (address differs from above as it is not static. it is the same device):
The text was updated successfully, but these errors were encountered: