问题描述
我在Linux上使用C ++开发应用程序,它与蓝牙设备(如蓝牙插座或扬声器)交互。
我使用D-Bus命令获取配对设备列表:
dbus-send --system --dest = bluez --print-reply $ BTADAPTER org.bluez.Adapter.ListDevices
它返回:
方法return sender =:1.0 - > dest =:1.90 reply_serial = 2
array [
对象路径/ org / bluez / 489 / hci0 / dev_00_1F_C5_75_45_5E
对象路径/ org / bluez / 489 / hci0 / dev_F0_13_C3_00_A1_08
object path/ org / bluez / 489 / hci0 / dev_00_11_12_30_76_21
对象路径/ org / bluez / 489 / hci0 / dev_00_11_12_30_76_22
对象路径/ org / bluez / 489 / hci0 / dev_00_11_12_30_76_23
对象路径/ org / bluez / 489 / hci0 / dev_00_11_12_30_76_24
]
这是伟大的,但我不仅需要MAC,而且还需要设备名称(例如linvor或GT-I9300)。
尝试这个命令:dbus-send --system --type = method_call --print-reply --dest = org.bluez/ org / bluez / 489 / hci0 / dev_00_1F_C5_75_45_5Eorg.bluez.Device.GetProperties,您将获得有关该设备的所有信息
I develop an application in C++ on Linux, which interacts with blueooth devices (such as bluetooth sockets or speakers).I use D-Bus command to get list of paired devices:
dbus-send --system --dest=org.bluez --print-reply $BTADAPTER org.bluez.Adapter.ListDevices
It returns:
method return sender=:1.0 -> dest=:1.90 reply_serial=2
array [
object path "/org/bluez/489/hci0/dev_00_1F_C5_75_45_5E"
object path "/org/bluez/489/hci0/dev_F0_13_C3_00_A1_08"
object path "/org/bluez/489/hci0/dev_00_11_12_30_76_21"
object path "/org/bluez/489/hci0/dev_00_11_12_30_76_22"
object path "/org/bluez/489/hci0/dev_00_11_12_30_76_23"
object path "/org/bluez/489/hci0/dev_00_11_12_30_76_24"
]
It is great, but I need not only MACs, but names of devices also (e.g. "linvor" or "GT-I9300").
Please, help me with a proper way to get those names.
Try this command: dbus-send --system --type=method_call --print-reply --dest=org.bluez "/org/bluez/489/hci0/dev_00_1F_C5_75_45_5E" org.bluez.Device.GetProperties , you will get all information about that device
这篇关于如何获取设备名称与D-Bus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!