首先安装蓝牙服务
pacman -S bluez bluez-utils pulseaudio-bluetooth
bluez提供bluetooth服务bluez-utils提供bluetoothctl工具bluez-utils-compat(开机后无法NOT Default controller available)使用这个包据说可以修复这个问题.- (optional)
blueman显示systray pulseaudio-bluetooth可以连接蓝牙耳机
启动连接设备
sudo systemctl start bluetooth.service开启bluetooth服务.sudo systemctl enable bluetooth.service设置为开机启动.- 然后使用
bluetoothctl进行蓝牙的连接. - 将用户添加到
lp用户组中, 添加方法usermod -G Groupname Username, 或直接修改/etc/group文件.
首次启动蓝牙
- 使用
help查看帮助. - 首先选择设备
select MAC_address - 然后使用
power on开启蓝牙设备- 如果开启失败检查是否是蓝牙设备被block了. 使用
rfkill list观察. - 如果是可以
rfkill unblock allorconnmanctl enable bluetooth来取消所有的被block的设备. 详细使用man rfkill.
- 如果开启失败检查是否是蓝牙设备被block了. 使用
- 然后使用
devices查看可以使用的设备. - (optional)如果devices没有可用的设备. 使用
scan on来扫描附近可连接的蓝牙设备. - (optional)
agent on或选择其他的模式(DisplayOnly KeyboardDisplay NoInputNoOutput DisplayYesNO KeyboardOnly off on)如果你清楚的话. pair MAC_address开始配对设备.- 如果设备没有PIN, 可能还需要手动
trust MAC_address在重新连接之前. connect MAC_address来连接蓝牙设备.- 如果连接失败, 可能是
pulseaudio-bluetooth没有安装. 具体使用systemctl status bluetooth.service查看错误信息. - 然后在
/etc/pulse/system.pa中加入以下内容:
- 如果连接失败, 可能是
### Enable bluetooth daemon
load-module module-bluetooth-policy
load-module module-bluetooth-discover
之后每次启动bluetoothctl
sudo systemctl start bluetooth.service如果不想每次reboot输入可以sudo systemctl enable bluetooth.servicepower on开启蓝牙服务.- 如果想要开机启动
nvim /etc/bluetooth/main.conf
[General] AutoEnable=true- 如果想要开机启动
然后使用
devices查看可用设备,connect MAC_address连接即可.
之后使用遇到问题解决
1. 开始连接后等会出现连接失败
- 使用
systemctl status bluetooth.service或journalctl查看关于bluetooth的错误信息, 得到如下输出:
bluetoothd: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
bluetoothd: connect error: Connection refused (111)
或
Unable to get Headset Voice gateway SDP record: Host is down
这可能是因为MAC_address冲突(蓝牙的单耳机模式和双耳机模式切换后容易发生这种情况), 解决方法如下:
devices查看添加的设备.remove移除冲突设备的MAC_address.- 然后使用以上步骤重新连接即可.