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
dev_xx_xx_xx_xx_xx_xx蓝牙是设备地址是用手机的mac地址,而不是板子端蓝牙的地址
获取设备详情:
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
————————————————
版权声明:本文为CSDN博主「TE_ET」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/tianlai1009/article/details/112870777