MYD-C8MMX开发板上板载的WiFi模块AP6212,是集成了WiFi和蓝牙功能的模块。蓝牙功能是通过串口和连接到模块的。

配置蓝牙

检查Bluetooth设备初始化

系统启动的时候,会自动加载Bluetooth的驱动和固件,并且初始化。如果初始化正常,会显示如下的结果。

root@i2cmp15xbe:~# dmesg| grep Bluetooth
[    6.702373] Bluetooth: Core ver 2.22
[    6.742181] Bluetooth: HCI device and connection manager initialized
[    6.774115] Bluetooth: HCI socket layer initialized
[    6.853345] Bluetooth: L2CAP socket layer initialized
[    6.857072] Bluetooth: SCO socket layer initialized
[    6.935002] Bluetooth: HCI UART driver ver 2.3
[    6.960363] Bluetooth: HCI UART protocol H4 registered
[    7.006237] Bluetooth: HCI UART protocol Broadcom registered
[    7.220101] Bluetooth: hci0: BCM: chip id 94
[    7.224381] Bluetooth: hci0: BCM: features 0x2e
[    7.228842] Bluetooth: hci0: BCM43430A1
[    7.231311] Bluetooth: hci0: BCM43430A1 (001.002.009) build 0000
[    7.909924] Bluetooth: hci0: BCM43430A1 (001.002.009) build 0264

启用Bluetooth设备

root@i2cmp15xbe:~# hciconfig hci0 up

管理Bluetooth设备

root@i2cmp15xbe:~# bluetoothctl
[bluetooth]#agent on
[bluetooth]#scan on
[bluetooth]#trust MAC_ADDRESS
[bluetooth]#pair MAC_ADDRRESS
[bluetooth]#connect MAC_ADDRESS

如果需要退出bluetoothctl,可以输入exit命令。此时bluetooth会保持在连接状态,断开连接的操作如下

bluetoothctl disconnect MAC_ADDRESS

通过蓝牙播放音频文件

PulseAudio

paplay piano2.wav

ALSA

# systemctl stop pulseaudio
# systemctl start bluez-alsa
# aplay -D bluealsa:SRV=org.bluealsa,DEV=86:5F:50:0F:18:7E,PROFILE=a2dp piano2.wav

上面aplay的参数,可以写入配置文件,方便使用。

root@pangu:~# vi .asoundrc
defaults.bluealsa.service "org.bluealsa"
defaults.bluealsa.device "86:5F:50:0F:18:7E"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000

".asoundrc"文件是在/home/root目录下,即root用户的家目录。
因此前面的命令可以简化为如下

aplay -D bluealsa piano2.wav
作者:SteveChen  创建时间:2024-09-18 16:35
最后编辑:SteveChen  更新时间:2024-09-18 16:35
上一篇:
下一篇: