79620871

Date: 2025-05-14 07:02:57
Score: 3
Natty:
Report link

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.

Reasons:
  • Blacklisted phrase (1): I'm having the same problem
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I'm having the same problem
  • Low reputation (0.5):
Posted by: kontextify