hbldh / bleak

A cross platform Bluetooth Low Energy Client for Python using asyncio
MIT License
1.82k stars 300 forks source link

Bleak returns a mac address that is 00:00:00:00:00:00 #1490

Open ZeldricTom opened 10 months ago

ZeldricTom commented 10 months ago

Description

I'm trying to get the mac address from a BLE device. But it returns a mac address equal to -> 00:00:00:00:00:00

What I Did

Of course I tried to restart the rasp, I also tried to see if there bluetooth drivers I needed to install, but didn't find any. I was unable to find any good thread for this type of problem.

My code

Here is the code I use to get the mac addresses.

import asyncio from bleak import BleakScanner

async def discover_devices(): devices = await BleakScanner.discover(timeout=20) for device in devices: print(f"Device: {device.name}, Address: {device.address}")

asyncio.run(discover_devices())

ZeldricTom commented 10 months ago
Sans titre

Here is what my pc sees. Also, only this BLE device has this mac address. Every other bluetooth device has a correct mac address.

dlech commented 10 months ago

Please see https://bleak.readthedocs.io/en/latest/troubleshooting.html to enable debug logging and how to log Bluetooth packets.

Bleak only reports the value returned by BlueZ so this is likely a BlueZ issue or an issue with the Bluetooth adapter.

ZeldricTom commented 10 months ago

@dlech Here are the logs https://pastebin.com/dGWPBpn4

dlech commented 10 months ago

As seen in the second line of the logs:

2024-01-05 14:22:14,983 bleak.backends.bluezdbus.manager MainThread DEBUG: received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_00_00_00_00_00_00):

BlueZ thinks the device address is all 0s.

Nilon123456789 commented 10 months ago

Is there a way to fix the issue? Do we need to downgrade BlueZ to an earlier version?

dlech commented 10 months ago

I would start with logging Bluetooth packets. If the device is actually sending the address 00:00:00:00:00:00 then there is nothing wrong with the software.

Nilon123456789 commented 10 months ago

The device is sending a MAC address since I can see it on MacOS