pygattlib
pygattlib copied to clipboard
Scan not working on HCI > 5.x
System
Software
- Operating System: Debian GNU/Linux 11 (bullseye)
- Python Version: 3.9.2
- gattlib Version: 0.20201113
Hardware
hci0: Type: Primary Bus: USB
UP RUNNING
RX bytes:337531 acl:0 sco:0 events:13225 errors:0
TX bytes:828464 acl:0 sco:0 commands:7186 errors:0
Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Class: 0x3c010c
Service Classes: Rendering, Capturing, Object Transfer, Audio
Device Class: Computer, Laptop
HCI Version: 5.2 (0xb) Revision: 0x2279
LMP Version: 5.2 (0xb) Subversion: 0x2279
Manufacturer: Intel Corp. (2)
Issue
I am using the example code as root:
#!/usr/bin/env python3
"""Tool for interfacing the sensor with Bluetooth Low Energy"""
from gattlib import DiscoveryService
service = DiscoveryService("hci0")
devices = service.discover(2)
for address, name in devices.items():
print("name: {}, address: {}".format(name, address))
but I get this error:
Traceback (most recent call last):
File "example.py", line 7, in <module>
devices = service.discover(2)
RuntimeError: Set scan parameters failed (are you root?)
When I plugin a Bluetooth Dongle with HCI version 4.x it works fine.
@mbrunnen is there a workaroud for this ?
Unfortunately not. I am using https://github.com/LeBlue/pydbus-bluez, which uses the dbus service of BlueZ and I am also directly using the dbus message bus org.bluez
within python.
You could also take an old enough bluetooth dongle :shrug:
Thanks