树莓派3b使用蓝牙当做A2DPsink端播放音乐
使用系统为官方下载的2017-11-29-raspbian-stretch
1、需要安装一下包(时间很赶,所以不知道以下包是不是必须要装的,反正我装了后也是没问题的)
sudo apt-get install bluetooth bluez-utils bluemansudo
sudo apt-get install libbluetooth-dev
sudo apt-get install pulseaudio pulseaudio-module-bluetooth
2、修改/etc/systemd/system/bluetooth.target.wants/bluetooth.service
在这一句后面加上一个-C ExecStart=/usr/lib/bluetooth/bluetoothd -C
3、sudo systemctl restart bluetooth
4、让服务随系统启动
sudo systemctl enable bluetooth
5、使用bluetoothctl来信任手机
如果没有自己的手机就输入scan on
trust 蓝牙地址 //来信任手机
输入exit退出即可
6、手机蓝牙直接连接,如果找不到树莓派的蓝牙,桌面右上角,点蓝牙的图标(注:必须用手机连接树莓派哦)
查看bluetooth状态
成功播放手机的声音
时间赶,不知道这样会不会有缺陷,后期有空详细看的时候再补充好了
每次重启后就再运行一次重启蓝牙的命令systemctl restart bluetooth
树莓派3b是自带蓝牙设备的,这个蓝牙和wifi是共用的,如果使用wifi时候,也用蓝牙就会卡
所以我是插上了一个csr 4.0的蓝牙适配器。
执行命令rfkill unblock all
设置蓝牙适配器为蓝牙设备
使用hciconfig命令来查看蓝牙设备
可以看出适配器是hci0,所以我关掉hci1
sudo hciconfig hci1 down
然后在bluetoothctl命令里
输入 discoverable on 手机设备即可搜索到蓝牙适配器了
同样也要先trust 信任一下自己的连接设备同上第五条