本文章主要记录下linux上移植bluez的一些要点流程,以rv1109设备为例说明,蓝牙芯片为rtl8723ds。
insmod hci_uart.ko
。/mnt/# dbus-daemon --print-address --system
Failed to start message bus: Failed to open "/usr/local/etc/dbus-1/system.conf": No such file or directory(需要拷贝此文件)
/mnt/# dbus-daemon --print-address --system
Failed to start message bus: Failed to read directory "/usr/local/etc/dbus-1/system.d": No such file or directory(需要创建此目录/usr/local/etc/dbus-1/system.d/)
/mnt/outdir# dbus-daemon --print-address --system
Failed to start message bus: Failed to bind socket "/usr/local/var/run/dbus/system_bus_socket": No such file or directory(需要创建/usr/local/var/run/dbus/)
/mnt/# dbus-daemon --print-address --system
Unknown group "lp" in message bus configuration file
unix:path=/usr/local/var/run/dbus/system_bus_socket,guid=4c34eaaa4681006ae29c7791386d99d8
或者
~ # dbus-daemon --config-file=/usr/local/etc/dbus-1/system.conf
Unknown group "lp" in message bus configuration file
上述过程中若提示/mnt/outdir # dbus-daemon --print-address --system
Failed to start message bus: The pid file "/usr/local/var/run/dbus/pid" exists, if the message bus is not running, remove this file
则删除/usr/local/var/run/dbus/pid,每次开机都需要删除这个/mnt/outdir # bluetoothd -d -n -E&
/mnt/outdir # bluetoothd[7028]: Bluetooth daemon 5.44
D-Bus setup failed: Connection ":1.0" is not allowed to own the service "org.bluez" due to security policies in the configuration file
bluetoothd[7028]: Unable to get on D-Bus
则把第4步中生成的bluetooth.conf拷贝到/usr/local/etc/dbus-1/和/usr/local/etc/dbus-1/system.d/目录下/mnt# bluetoothctl //运行bluetoothctl
[bluetooth]# show //查看控制器的 Power 是否为 yes,如果 Power 为 no,则运行 power on
[bluetooth]# power on
[bluetooth]# agent NoInputNoOutput //可以设置其他 IO caps, 如 KeyboardDisplay
[bluetooth]# default-agent
[bluetooth]# advertise on //开启ble广播
[bluetooth]# discoverable on //允许被发现
[bluetooth]# scan on //扫描到对应的设备后,使用 scan off 关闭 scan。
[bluetooth]# pair 00:22:48:DC:89:0F //配对远端设备。
[bluetooth]# connect 00:22:48:DC:89:0F //连接远端设备
如果没有加入蓝牙音频相关协议,connect时可能会报错,使用手机上蓝牙测试助手进行无配对测试也可以
hciconfig hci0 up
hciconfig hci0 piscan
hciconfig hci0 noencrypt
hciconfig hci0 noauth
hciconfig
hcitool scan //搜索
l2ping F8:A2:D6:D4:6C:04 //简单ping测试
l2test -O 675 -s A0:9F:10:7E:5C:E3
l2test -I 675 -b 10000 -r