ubuntu藍牙連接問題
- ubuntu藍牙連接問題
- 1、安裝驅動
- 2、優化藍牙配置文件
- 3、解決 Failed to connect: org.bluez.Error.Failed
ubuntu藍牙連接問題
之前我發現電腦有藍牙圖標,且能打開關閉,就以為藍牙默認已經配置好了,直到有一天我嘗試連接我的藍牙耳機才發現,電腦根本搜不到藍牙設備。于是我在網上搜了一些資料,現在終于解決了。
1、安裝驅動
當你的藍牙搜索不到設備,可以檢查一下你的藍牙是否安裝驅動。
參考:https://blog.csdn.net/Xiaoyao_Ma/article/details/136146043
在終端輸入:
dmesg | grep -i blue
我的問題和參考博客一致,有錯誤信息:
Bluetooth: hci0: RTL: unknown IC info, lmp subver 8852, hci rev 000b, hci ver 000b
此時可以得知,我的電腦確實是缺少藍牙驅動。
查詢藍牙芯片設備信息:
lsusb
Bus 001 Device 005: ID 0bda:4853 Realtek Semiconductor Corp. Bluetooth Radio
下載驅動
https://gitcode.com/HRex39/rtl8852be_bt/overview?utm_source=csdn_github_accelerator&isLogin=1
按照readme中的步驟即可。
2、優化藍牙配置文件
參考:
ubuntu18.04已匹配藍牙耳機但是連接不上
如何修復 Ubuntu Linux 中的藍牙連接問題
sudo vim /etc/bluetooth/main.conf
大致修改
- 取消AutoEnable注釋,并設置為true
- 取消ReconnectAttempts=7注釋
- 取消FastConnectable注釋,并設置為true
- 取消ControllerMode的注釋,并設置為bredr
注:vim操作方式
i
插入esc
退出編輯模式:wq
保存并退出
3、解決 Failed to connect: org.bluez.Error.Failed
安裝驅動后,電腦已經可以搜索到藍牙設備了,但是此時我的藍牙耳機依然連接不上。
參考博客:
https://blog.csdn.net/qq_34548075/article/details/107062005
https://blog.csdn.net/weixin_48120620/article/details/126229978
按照參考博客的說法可能是因為耳機不能在MAC地址和多個設備聯系的情況下工作。
// 進入bluetooth命令行交互模式
$ bluetoothctl
// 列出設備及其mac地址
[bluetooth]# devices
// 移除設備
[bluetooth]# remove XX:XX:XX:XX:XX:XX
mac地址可以在藍牙設置里面找到,只要能搜索到設備。
// 進入bluetooth命令行交互模式
$ bluetoothctl
// 掃描設備:
[bluetooth]#scan on
[bluetooth]#devices
// 與設備配對:
[bluetooth]#pair device_mac_address
// 如果出現提示,請輸入PIN:
[agent]PIN code: ####
// 如果需要,請允許服務授權:
[agent]Authorize service service_uuid (yes/no): yes
// 信任設備:
[bluetooth]#trust device_mac_address
// 連接到設備:
[bluetooth]#connect device_mac_address
// 顯示有關設備的信息:
[bluetooth]#info device_mac_address
// 退出:
[bluetooth]#quit
感覺對我起作用的是trust mac_address
這一步驟。