How to get device name with D-Bus?

匆匆过客 提交于 2019-12-23 05:15:48

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/19094897/how-to-get-device-name-with-d-bus

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