裝置「掃描」時可以找到要手機,但是「配對」時卻出現錯誤,
這問題也太嚴重了。(註:另一台電腦在前一陣子的某更新版本時,曾經成功配對。)
1. 「文字命令列介面」的管理程式
當 GUI 管理程式有問題時,用「命令列」的文字命令通常可以正常操作。開啟「終端機」,在「使用者」權限下輸入『bluetoothctl』進入管理操作介面[SiB@Celeron-D ~]# bluetoothctl由上例可以看到兩個 Bluetooth 裝置,前者是電腦上的「藍牙收發器」,而後者是一支已開啟藍牙功能,並已被「掃描」到的手機。
[NEW] Controller 00:0B:DD:69:CC:F1 Celeron-D [default]
[NEW] Device B8:D9:CC:7F:3A:A3 GT-I9100
[bluetooth]#
[bluetooth]# pair B8:D9:CC:7F:3A:A3由結果可以看到,仍然出現「配對」錯誤的訊息。
Attempting to pair with B8:D9:CC:7F:3A:A3
[CHG] Device B8:D9:CC:7F:3A:A3 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device B8:D9:CC:7F:3A:A3 Connected: no
2. 開啟「文字命令列介面」的「代理人 (Agent)」功能
用『help』命令查詢文字介面的管理程式之可用命令,看起來『agent』和『default-agent』這兩個『代理人』設定好像比較可疑,就先用它們來試試,
[bluetooth]# help Available commands: list List available controllers show [ctrl] Controller information select <ctrl> Select default controller devices List available devices paired-devices List paired devices power <on/off> Set controller power pairable <on/off> Set controller pairable mode discoverable <on/off> Set controller discoverable mode agent <on/off/capability> Enable/disable agent with given capability default-agent Set agent as the default one set-scan-filter-uuids [uuid1 uuid2 . . .] Set scan filter uuids set-scan-filter-rssi [rssi] Set scan filter rssi, and clears pathloss set-scan-filter-pathloss [pathloss] Set scan filter pathloss, and clears rssi set-scan-filter-transport [transport] Set scan filter transport set-scan-filter-clear Clears discovery filter. scan <on/off> Scan for devices info [dev] Device information pair [dev] Pair with device trust [dev] Trust device . . . . . . version Display version quit Quit program
[bluetooth]# default-agent『agent on』這個命令註冊了『代理人』,而『default-agent』顯示『預設代理人』內容。這兩個命令看起來似乎有些作用。
No agent is registered
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
3. 「掃描 (Scan)」附近的藍牙裝置
如果之前並沒有做過「掃描 (scan)」,『list』命令只顯示 Bluetooth 「控制器 (Controller)」。[bluetooth]# list要下『scan on』命令,開始搜尋附近的 Bluetooth 裝置,先將欲「配對」的 Bluetooth 裝置開啟「可發現 (discoverable)」,才能被搜尋到。
Controller 00:0B:DD:69:CC:F1 Celeron-D [default]
[bluetooth]# scan on當 Bluetooth 裝置找到,就可以下『scan off』命令關閉搜尋。
Discovery started
[CHG] Controller 00:A0:96:1D:48:78 Discovering: yes
[NEW] Device B8:D9:CE:7F:3A:E3 GT-I9100
[bluetooth]# scan off
Discovery stopped
[CHG] Controller 00:A0:96:1D:48:78 Discovering: no
4. 與藍牙裝置「配對 (Pair)」
繼續下「配對 (pair)」命令,『pair xx:xx:xx:xx:xx:xx』命令後的 16 進位數字,就是「掃描 (scan)」時找到的藍牙裝置之 MAC 位址 (MAC Address) (註:或稱為該裝置之識別碼)。當出現『Enter PIN code:』時,輸入『配對密碼』[bluetooth]# pair B8:D9:CC:7F:3A:A3接著在 Bluetooth 裝置端,也輸入相同的密碼,密碼正確就配對成功。
Attempting to pair with B8:D9:CC:7F:3A:A3
[CHG] Device B8:D9:CC:7F:3A:A3 Connected: yes
Request PIN code
[agent] Enter PIN code: 5566
[CHG] Device B8:D9:CC:7F:3A:A3 Modalias: bluetooth:v0075p0100d0100
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 0000112d-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device B8:D9:CC:7F:3A:A3 Paired: yes
Pairing successful
[CHG] Device B8:D9:CC:7F:3A:A3 Connected: no
5. 確認「配對 (Pair)」成功
要確認是否已經配對成功,可以用『paired-devices』查詢,[bluetooth]# paired-devices若能看到剛才「配對」的藍牙裝置,就表示操作正確、「配對」成功。
Device B8:D9:CC:7F:3A:A3 GT-I9100
6. 建立與藍牙裝置間的「信任 (Trust)」關係
通常「配對」的操作都是單方向,如:PC → 藍牙裝置、藍牙裝置 → PC。當「連線 (Connect)」方向是反過來時,即使已經「配對」成功,也未必能建立「連線」。這時候,只要將已經「配對」成功的藍牙裝置,再進一步建立「信任」關係。建立「信任」關係的命令為『trust xx:xx:xx:xx:xx:xx』命令後的 16 進位數字,就是欲建立「信任」關係的藍牙裝置[bluetooth]# trust B8:D9:CC:7F:3A:A3以後,不管是什麼方向的連線都沒問題。
[CHG] Device B8:D9:CC:7F:3A:A3 Trusted: yes
Changing B8:D9:CC:7F:3A:A3 trust succeeded
已測試版本:
- Fedora: 24 + MATE Desktop 1.14.1
沒有留言:
張貼留言
感謝你耐心看完本文,歡迎留下任何指正、建議,筆者會儘快回應。(English is also welcome.)