接口 "org.bluez.Manager" 上带有签名“”的方法 "DefaultAdapter" 在 raspberry pi 中不存在 3

Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist in raspberry pi 3

我想通过这个简单的脚本在 raspberry pi 中使用 dbus

bus = dbus.SystemBus()
obj = bus.get_object('org.bluez', '/')
print "object"
print obj
manager = dbus.Interface(obj,'org.bluez.Manager')
obj = bus.get_object('org.bluez',manager.DefaultAdapter())
print "Manager"
print manager
print "object"
print obj

但是当我尝试 运行 那个代码时,我得到

Traceback (most recent call last):
  File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 350, in <module>
    ge = Paint()
  File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 125, in __init__
    self.test()
  File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 280, in test
    obj = bus.get_object('org.bluez',manager.DefaultAdapter())
  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)
DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist

我正在使用 bluez 5.43 版本。我已经检查了解决方案,但没有成功。

我该怎么办?

提前致谢。

我和 org.bluez.Manager

有同样的问题

还有org.freedesktop.DBus.ObjectManager。这应该为您提供这些对象(来自 https://github.com/Douglas6/blueplayer/blob/master/blueplayer.py):

import dbus

SERVICE_NAME = "org.bluez"
OBJECT_IFACE =  "org.freedesktop.DBus.ObjectManager"
ADAPTER_IFACE = SERVICE_NAME + ".Adapter1"
DEVICE_IFACE = SERVICE_NAME + ".Device1"
PROPERTIES_IFACE = "org.freedesktop.DBus.Properties"
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
for path, ifaces in objects.iteritems():
    adapter = ifaces.get(ADAPTER_IFACE)
    if adapter is None:
        continue
    obj = bus.get_object(SERVICE_NAME, path)
    adapter = dbus.Interface(obj, ADAPTER_IFACE)