BAESLab / Python-BLE

6 stars 6 forks source link

RuntimeError: Set scan parameters failed (are you root?). Maybe someone bumps into this variant. #3

Open franciscojosej opened 4 years ago

franciscojosej commented 4 years ago

coode:

bluetooth low energy scan

from bluetooth.ble import DiscoveryService

service = DiscoveryService("hci0") devices = service.discover(2)

for address, name in devices.items(): print("name: {}, address: {}".format(name, address))

Error: Traceback (most recent call last): File "/home/pi/Documents/python/HolaMundo.py", line 5, in devices = service.discover(2) RuntimeError: Set scan parameters failed (are you root?)

Solution: https://www.home-assistant.io/integrations/bluetooth_le_tracker

summarize solution : sudo apt-get install libcap2-bin sudo setcap 'cap_net_raw,cap_net_admin+eip' readlink -f \which python3` sudo setcap 'cap_net_raw+ep'readlink -f `which hcitool``

Have Fun