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

Ana*_*Ana 2 dbus bluez

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
Run Code Online (Sandbox Code Playgroud)

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

供参考,这就是d-feet显示的内容。

.

这个命令我做错了什么?

Jaa*_*alo 5

问题是 dbus-send 几乎立即退出。BlueZ 跟踪请求发现的客户端(打开适配器的 D-Bus 代理),当没有更多客户端请求它时,发现将停止。

d-feet 和 bluetoothctl 是长期存在的进程,它们使 org.bluez.Adapter1 代理与适配器保持活动状态。

我在使用 glib 客户端时遇到了同样的问题,解决方案是使适配器的 D-Bus 代理对象保持活动状态。

如果您必须坚持使用 dbus-send,这可能是个坏消息。