Linux 驱动蓝牙

  1. 1. Linux 驱动蓝牙
    1. 1.1. 安装驱动
    2. 1.2. 设备控制

Linux 驱动蓝牙

搞了台新设备,设备带一个AX200网卡,又有Wi-Fi又有蓝牙,Wi-Fi直接免驱,蓝牙却无法驱动,经过研究搞定了这个事情,记录下。

安装驱动

  • 检查蓝牙服务
1
2
3
service bluetooth status
# 如果显示 masked 就输入下面的命令
systemctl unmask bluetooth.service
  1. 安装蓝牙控制套件
1
apt install bluez -y
  1. 获取蓝牙设备
1
2
bluetoothctl show
# 如果显示 No default controller available 则表示没有驱动起来
  1. 安装缺少的驱动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 查看蓝牙情况
dmesg | grep blue
# 我这里显示
# bluetooth hci0: Direct firmware load for intel/ibt-20-1-3.sfi failed with error -2
# 表示缺少 ibt-20-1-3.sfi 驱动文件

# 进入驱动文件夹
cd /lib/firmware/intel
# 下载缺失的驱动,如果你缺少的是别的驱动,则替换掉文件名即可
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/intel/ibt-20-1-3.sfi
# 下载完毕后重启设备
reboot now
# 再次查看蓝牙设备
bluetoothctl show
# 此时应该已经有内容了
# root@vm:~# bluetoothctl show
# Controller **:**:**:**:**:** (public)
# Name: vm
# Alias: vm
# Class: 0x00000104
# Powered: yes
# Discoverable: no
# Pairable: yes
# UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
# UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
# UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
# UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
# UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
# Modalias: usb:v1D6Bp0246d0532
# Discovering: no

设备控制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 进入蓝牙控制 如果进入了,应该是这样的 [bluetooth]# 
bluetoothctl

# 开启扫描 屏幕上会出现一堆设备的 MAC 地址
scan on
# Discovery started
# [CHG] Controller E0:D4:E8:94:07:86 Discovering: yes
# [NEW] Device 54:21:C3:BC:77:1A 54-21-C3-BC-77-19
# [NEW] Device E9:33:F9:B9:6B:AF MX Keys
# [NEW] Device 48:AB:38:E9:67:89 48-AB-38-E9-67-84
# [NEW] Device F4:5C:89:AB:57:61 F4-5C-89-AB-57-66

# 关闭扫描
scan off

# 连接指定设备,屏幕上会出现不少内容,主要看
# 出现 Connection successful 则连接成功
connect E9:33:F9:B9:6B:AF

# 在蓝牙控制中 如果链接了蓝牙设备,或者断开了蓝牙设备都会有提示

# 有设备链接
# [CHG] Device E9:33:F9:B9:6B:AF Connected: yes
# [CHG] Device E9:33:F9:B9:6B:AF ServicesResolved: yes

# 有设备断开
# [CHG] Device E9:33:F9:B9:6B:DE ServicesResolved: no
# [CHG] Device E9:33:F9:B9:6B:DE Connected: no