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?
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