I'm having the same problem with Bleak and the Pi 5 Bluetooth stack, opened an issue on GitHub. Devices appear in btmon
and bluetoothctl
but not Bleak.
What does work for me is explicitly scanning in passive mode like this:
from bleak.backends.bluezdbus.scanner import BlueZScannerArgs
from bleak.backends.bluezdbus.advertisement_monitor import OrPattern
from bleak.assigned_numbers import AdvertisementDataType
PASSIVE_SCANNER_ARGS = BlueZScannerArgs(
or_patterns=[
OrPattern(0, AdvertisementDataType.FLAGS, b"\x06"),
OrPattern(0, AdvertisementDataType.FLAGS, b"\x1a"),
]
)
devices = await BleakScanner.discover(
return_adv=True,
scanning_mode="passive",
bluez=PASSIVE_SCANNER_ARGS
)
This requires Experimental = true
in /etc/bluetooth/main.conf. Those or_patterns
should actually accept all devices, they're required for passive mode.