라즈베리파이에서, ble 사용시 dbus 에러가 발생할 경우

ERROR:dbus.proxies:Introspect error on :1.5:/: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.16" (uid=1000 pid=2709 comm="/usr/bin/python ./example_advertisement.py ") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination=":1.5" (uid=0 pid=522 comm="/usr/lib/bluetooth/bluetoothd ")
Traceback (most recent call last):
  File "./example_advertisement.py", line 204, in <module>
    main()
  File "./example_advertisement.py", line 180, in main
    adapter = find_adapter(bus)
  File "./example_advertisement.py", line 164, in find_adapter
    objects = remote_om.GetManagedObjects()
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.16" (uid=1000 pid=2709 comm="/usr/bin/python ./example_advertisement.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination=":1.5" (uid=0 pid=522 comm="/usr/lib/bluetooth/bluetoothd ")

 

라즈비안이 lite 버전인지 확인한다.

lite 버전에서는 pi에 default로 일부 bt 제어 권한이 없기 때문에 다음과 같이 해결할 수 있다.

 

sudo usermod -G bluetooth -a pi
sudo reboot now