pcduino 连接蓝牙音箱

前期准备

  • 一个usb bluetooth适配器
  • pcduino
  • 蓝牙音箱

开始

运行:

sudo apt-get install bluetooth bluez-utils bluez-alsa

安装完毕后,运行:

sudo gpasswd -a 你的用户名 bluetooth

然后运行:

sudo hciconfig hci0 up

设置你的蓝牙音箱使其处于匹配状态,然后运行:

hcitool scan

屏幕输出类似:

Scanning ...
            <hadware_id> NAME

记下hadware_id,运行:

bluez-simple-agent hci0 <hadware_id>

如果没有输入任何东西,说明匹配成功。(这个命令只需运行一次,以后不需要再次匹配除非手动删除匹配。)

然后执行:

bluez-test-audio connect <hardware_id>

将音箱连接至audio。然后运行:

bluez-test-device trusted <hardware_id> yes

设置配置文件

运行:

sudo vi /etc/asound.conf    (或者nano等文本编辑器)

添加:

pcm.!default {  #这里将默认音频输出设置为蓝牙
    type bluetooth
    device <hardware_id> # change this MAC address using the command "hcitool scan"
    profile "auto"
}

然后运行:

sudo vi /etc/bluetooth/audio.conf

令 [General] 一节仅有:

 Enable=Source 

Kauf von Cipro

,Sink,Media,Socket

最后运行:

sudo service bluetooth restart

测试

运行测试:

mplayer test.mp3

如果没有设置pcm.!default而是pcm.\<name>的话,则运行:

mplayer -ao <name> test.mp3

如果一些顺利你可以听到蓝牙音箱响起音乐啦!

后续

当pcduino重启后,仅需运行:

bluez-test-audio connect <hardware_id>

即可以连接蓝牙音箱。