【发布时间】:2015-09-02 17:14:21
【问题描述】:
我有一个有效的 dbus-send 调用:
# OBJECT INTERFACE .MEMBER CONTENT
dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
现在我正在尝试在 python 中做同样的事情,但是由于可怜的文档,尽管我尝试了所有可以想到的排列,但我得到的只是 last 步骤中的错误。
import dbus
bus = dbus.SystemBus()
hci0 = bus.get_object('org.bluez', '/org/bluez/hci0')
# everything good so far
# v1
hci0_setmode = hci0.get_dbus_method('SetMode', 'org.bluez.Adapter')
hci0_setmode('discoverable')
# v2
iface = dbus.Interface(hci0, 'org.bluez.Adapter')
iface.SetMode('discoverable')
# v3
iface = dbus.Interface(hci0, 'org.bluez.Adapter')
hci0_setmode =iface.get_dbus_method('SetMode', 'org.bluez.Adapter')
hci0_setmode('discoverable')
无论我做什么,错误是:
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "SetMode" with signature "s" on interface "org.bluez.Adapter" doesn't exist
我还没有找到一种方法来告诉我存在什么签名的方法,而且这个错误消息似乎与初始 dbus-send 调用相矛盾,这证明“org.bluez.Adapter.SetMode(s)”存在。
【问题讨论】: