How to use dbus-send to call org.bluez.Adapter1.StartDiscovery?

淺唱寂寞╮ 提交于 2019-12-08 08:17:51

问题


I am trying to interact with Bluez 5.44 using the dbus-send command line tool. I cannot seem to get it to start discovery properly, although it works fine when I use bluetoothctl's scan on and scan off commands. I can also start and stop discovery using d-feet.

I've tried powering off and on prior to issuing the command, but it doesn't seem to get discovery started.

The command line I'm using is:

dbus-send --system --type=method_call --print-reply --dest=org.bluez \
    /org/bluez/hci0                                                  \
    org.bluez.Adapter1.StartDiscovery

What I usually get upon issuing this command is from dbus-monitor is that the Discovering property is false.

For reference, this is what d-feet shows.

.

What am I doing wrong with this command?


回答1:


The problem is that dbus-send exits almost immediately. BlueZ keeps track of clients that are requesting discovery (have a D-Bus proxy to the adapter open), and the discovery will stop when no more clients are requesting it.

d-feet and bluetoothctl are long-living processes that keep the org.bluez.Adapter1 proxy to the adapter alive.

I hit the same problem with a glib client I'm working on, and there the solution is to keep the D-Bus proxy object to the adapter alive.

This is probably bad news if you have to stick with dbus-send.



来源:https://stackoverflow.com/questions/43550424/how-to-use-dbus-send-to-call-org-bluez-adapter1-startdiscovery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!