Ubuntu連接AirPods耳機

有時想讓Ubuntu電腦連接AirPods2耳機,最近重裝系統後,遇到無法配對耳機的情況,特此記錄下摸索過程,AirPods其他型號沒有試過,沒設備測試(最近新購買了AirPods Pro 2nd Generation,經測試,二代照這方法也是可以匹配到的),方法應該大同小異。

首先,更改控制模式爲ControllerMode = bredr,可能值爲: "dual", "bredr", "le", 一種不行的話,換其它模式試試

1    ➜  ~ egrep -v '^#|^$' /etc/bluetooth/main.conf
2    [General]
3    ControllerMode = bredr
4    [Policy]
5    AutoEnable=true

其次,重啓bluetooth服務

1    sudo systemctl restart bluetooth.service

此時,如果你的設備,可通過Gnome Settings的bluetooth頁直接識別並匹配的話,下面的步驟作用不大,看看就好。

圖形界面無法匹配時,終端操作

1. 開啓藍牙交互控制工具(interactive bluetooth control tool)

1    ➜  ~ bluetoothctl 
2    Agent registered
3    [CHG] Device F4:F5:DB:65:B0:3B RSSI: -73
4    [CHG] Device 4C:D1:A1:3F:B2:55 RSSI: -79
5    [CHG] Device 94:87:E0:A1:89:49 RSSI: -72
6    [CHG] Device A0:A4:C5:04:43:17 RSSI: -77
7    [CHG] Device B4:CB:57:16:D5:80 RSSI: -82

2. 掃描設備 scan on, 掃描的時候按住AirPods2背後的匹配按鈕

when you begin scan devices, remeber press the AirPods2 button on the back

1    [bluetooth]# scan on
2    Discovery started
3    [NEW] Device 44:66:FC:9C:CC:FC 44-66-FC-9C-CC-FC
4    [NEW] Device C4:E1:A1:AC:C0:6A C4-E1-A1-AC-C0-6A
5    [CHG] Device 00:A6:19:18:52:86 RSSI: -69
6    [NEW] Device 7C:9A:1D:B0:62:02 AirPods
7    [NEW] Device A4:50:46:BA:7F:49 A4-50-46-BA-7F-49

所在環境設備很多的時候,貌似沒有什麼好的辦法過濾,需要仔細觀察自己的設備名,如上所示,我的airpod2設備已經成功識別

1    [NEW] Device 7C:9A:1D:B0:62:02 AirPods

3. 連接AirPods2 (connect AirPods2)

1    [bluetooth]# connect 7C:9A:1D:B0:62:02
2    Attempting to connect to 7C:9A:1D:B0:62:02
3    [CHG] Device 7C:9A:1D:B0:62:02 ServicesResolved: yes
4    [CHG] Device 7C:9A:1D:B0:62:02 Paired: yes
5    Connection successful
6    [AirPods]# 

connect 貌似會自動 pair,有需要的可以trust。

Haha, it works !

如果報錯:

1[bluetooth]# connect C0:95:6D:C0:A3:92
2Attempting to connect to C0:95:6D:C0:A3:92
3Failed to connect: org.bluez.Error.NotReady br-connection-adapter-not-powered

表明你的Ubuntu上的藍牙開關沒打開。

4. 看看設備信息(AirPods2 info)

 1    [AirPods]# info 7C:9A:1D:B0:62:02
 2    Device 7C:9A:1D:B0:62:02 (public)
 3        Name: AirPods
 4        Alias: AirPods
 5        Class: 0x00240418
 6        Icon: audio-headphones
 7        Paired: yes
 8        Trusted: no
 9        Blocked: no
10        Connected: yes
11        LegacyPairing: no
12        UUID: Service Discovery Serve.. (00001000-0000-1000-8000-00805f9b34fb)
13        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
14        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
15        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
16        UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
17        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
18        UUID: Vendor specific           (74ec2172-0bad-4d01-8f77-997b2be0722a)
19        Modalias: bluetooth:v004Cp200Fd9047

info 信息裏面顯示 Paired: yesConnected: yes 可以確認已經連上了。

5. 下次再連時,先通過devices命令查詢設備地址,地址會被記住一段時間(此時圖形界面連接的方式應該也可以使用)

next time, if your devices offline, just get device address, connect it again

1    [AirPods]# devices
2    Device 7C:9A:1D:B0:62:02 AirPods
3    Device AC:49:DB:4E:39:41 mephisto

查看幫助信息,可以試試額外的控制功能,這裏不再演示:

 1    [AirPods]# help
 2    Menu main:
 3    Available commands:
 4    -------------------
 5    advertise                                         Advertise Options Submenu
 6    monitor                                           Advertisement Monitor Options Submenu
 7    scan                                              Scan Options Submenu
 8    gatt                                              Generic Attribute Submenu
 9    admin                                             Admin Policy Submenu
10    list                                              List available controllers
11    show [ctrl]                                       Controller information
12    select <ctrl>                                     Select default controller
13    devices                                           List available devices
14    paired-devices                                    List paired devices
15    system-alias <name>                               Set controller alias
16    reset-alias                                       Reset controller alias
17    power <on/off>                                    Set controller power
18    pairable <on/off>                                 Set controller pairable mode
19    discoverable <on/off>                             Set controller discoverable mode
20    discoverable-timeout [value]                      Set discoverable timeout
21    agent <on/off/capability>                         Enable/disable agent with given capability
22    default-agent                                     Set agent as the default one
23    advertise <on/off/type>                           Enable/disable advertising with given type
24    set-alias <alias>                                 Set device alias
25    scan <on/off/bredr/le>                            Scan for devices
26    info [dev]                                        Device information
27    pair [dev]                                        Pair with device
28    cancel-pairing [dev]                              Cancel pairing with device
29    trust [dev]                                       Trust device
30    untrust [dev]                                     Untrust device
31    block [dev]                                       Block device
32    unblock [dev]                                     Unblock device
33    remove <dev>                                      Remove device
34    connect <dev>                                     Connect device
35    disconnect [dev]                                  Disconnect device
36    menu <name>                                       Select submenu
37    version                                           Display version
38    quit                                              Quit program
39    exit                                              Quit program
40    help                                              Display help about this program
41    export                                            Print environment variables

以上主要針對圖形界面操作無效時的狀況,希望對你有所幫助

最後修改於: Monday, August 28, 2023

相關文章:

翻譯: