本文主要是介绍dbus-send控制蓝牙的一些操作,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
(测试过程中注意检查一下复制黏贴的字符是否有误,最好到Notepad++ 下重新编辑检查一遍)
摘自
dbus 拿属性:
https://stackoverflow.com/questions/48648952/set-get-property-using-dbus-send
dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
org.freedesktop.DBus.Properties.Get string:com.pgaur.GDBUS string:Status
写属性:
dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \org.freedesktop.DBus.Properties.Set string:com.pgaur.GDBUS string:Status variant:uint32:10
dbus-send --system --dest=org.bluez --type=method_call --print-reply /org/bluez/hci0 org.freedesktop.DBus.Introspectable.Introspect
基于bluez5.38
获取连接的设备信息:
拿到当前 入口
dbus-send --system --dest=org.bluez --type=method_call --print-reply /org/bluez/hci0 org.freedesktop.DBus.Introspectable.Introspect
查看接口和连接参数信息:
dbus-send --system --print-reply --type=method_call --dest=org.bluez / org.freedesktop.DBus.ObjectManager.GetManagedObjects
dbus-send --system --print-reply --type=method_call --dest=org.bluez / org.freedesktop.DBus.Introspectable.Introspect
获取设备详情:
dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/hci0/dev_BC_A5_A9_68_0F_D4 org.freedesktop.DBus.Introspectable.Introspect
获取设备名:
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0/dev_BC_A5_A9_68_0F_D4 org.freedesktop.DBus.Properties.Get string:org.bluez.Device1 string:Alias
获取player序号:
dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/hci0/dev_B8_63_4D_4F_CE_E4 org.freedesktop.DBus.Properties.Get string:org.bluez.MediaControl1 string:Player
返回:
method return time=1604071730.769876 sender=:1.1 -> destination=:1.3347 serial=4250 reply_serial=2
variant object path "/org/bluez/hci0/dev_B8_63_4D_4F_CE_E4/player2"
获取歌曲名信息和进度:
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0/dev_C8_C2_FA_46_DE_C7/player0 org.freedesktop.DBus.Properties.Get string:org.bluez.MediaPlayer1 string:Track
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0/dev_C8_C2_FA_46_DE_C7/player0 org.freedesktop.DBus.Properties.Get string:org.bluez.MediaPlayer1 string:Position
上一首下一首暂停:
dbus-send --system --print-reply --dest=org.bluez /org/bluez/hci0/dev_C4_86_E9_B9_E3_4C org.bluez.MediaControl1.Play
dbus-send --system --print-reply --dest=org.bluez /org/bluez/hci0/dev_C4_86_E9_B9_E3_4C org.bluez.MediaControl1.Pause
dbus-send --system --print-reply --dest=org.bluez /org/bluez/hci0/dev_C4_86_E9_B9_E3_4C org.bluez.MediaControl1.Next
dbus-send --system --print-reply --dest=org.bluez /org/bluez/hci0/dev_C4_86_E9_B9_E3_4C org.bluez.MediaControl1.Previous
这篇关于dbus-send控制蓝牙的一些操作的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!