IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.58k stars 490 forks source link

Passive scan returns weird connectable #485

Open B03901108 opened 2 years ago

B03901108 commented 2 years ago

Hi, I was running bluepy on Raspberry Pi 3 B+. To start a passive BLE scan, I specified passive=True when calling Scanner's scan method. Then, in ScanDelegate's handleDiscovery, the input ScanEntry's connectable became always True, even when the arriving advertisement came from a MAC address that had only been giving connectable=False during active BLE scanning.

To narrow down the cause, I even modified btle.py to print out resp['flag'][0] in ScanEntry's _update method. (resp['flag'][0] is the raw material to derive the up-to-date "connetable" value.) It seems that during passive BLE scanning, resp['flag'][0] is always 0x0, while during active BLE scanning, resp['flag'][0] can be either 0x0 or 0xfffffffc. Although I am unsure if the above helps debugging, I think the above narrows down the root cause to bluepy's interaction with BLE module.

It would be great if anyone could share feedback/solutions. Great thanks.