【发布时间】:2018-05-05 04:42:51
【问题描述】:
我是 dbus 的初学者,并尝试使用 bash dbus-send 命令执行蓝牙扫描。我用这条线:
$dbus-send --system --type=method_call --dest=org.bluez --print-reply /org/bluez/hci0 org.bluez.Adapter1.StartDiscovery
但没有发现开始......
在 dbus-monitor 中我看到了:
method call time=1511273024.833459 sender=:1.55 -> destination=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
method return time=1511273024.921444 sender=org.freedesktop.DBus -> destination=:1.55 serial=1 reply_serial=1
string ":1.55"
signal time=1511273024.923719 sender=org.freedesktop.DBus -> destination=(null destination) serial=101 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
string ":1.55"
string ""
string ":1.55"
signal time=1511273024.926411 sender=org.freedesktop.DBus -> destination=:1.55 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
string ":1.55"
method call time=1511273024.927109 sender=:1.55 -> destination=org.bluez serial=2 path=/org/bluez/hci0; interface=org.bluez.Adapter1; member=StartDiscovery
method call time=1511273024.927628 sender=:1.1 -> destination=org.freedesktop.DBus serial=69 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
string "type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.55'"
method return time=1511273024.928272 sender=org.freedesktop.DBus -> destination=:1.1 serial=43 reply_serial=69
method return time=1511273024.928729 sender=:1.1 -> destination=:1.55 serial=70 reply_serial=2
signal time=1511273024.929236 sender=org.freedesktop.DBus -> destination=:1.55 serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
string ":1.55"
signal time=1511273024.929945 sender=org.freedesktop.DBus -> destination=(null destination) serial=44 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
string ":1.55"
string ":1.55"
string ""
method call time=1511273024.930956 sender=:1.1 -> destination=org.freedesktop.DBus serial=71 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
string "type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.55'"
method return time=1511273024.931635 sender=org.freedesktop.DBus -> destination=:1.1 serial=45 reply_serial=71
signal time=1511273024.932142 sender=:1.1 -> destination=(null destination) serial=72 path=/org/bluez/hci0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.bluez.Adapter1"
array [
dict entry(
string "Discovering"
variant boolean false
)
]
array [
]
当我使用bluetoothctl 和scan on 时,我可以执行蓝牙扫描。我试图比较 bluetoothctl 工具和我的 bash 之间的 dbus 消息。当我在 bash 中使用 dbus 时,我会收到很多信号 NameOwnerChanged,后面总是跟着 RemoveMatch,这让我很感兴趣....
其他 dbus 方法有效(ListNames、GetManagedObjects、Connect、RemoveDevice)
我看到这个帖子有同样的问题:How to use dbus-send to call org.bluez.Adapter1.StartDiscovery?
但我不知道如何“让适配器的 D-Bus 代理对象保持活动状态。”
你有线索吗?
我使用:dbus-daemon 1.10.10、Bluez 5.41
感谢您的宝贵时间
【问题讨论】: