10.2. bluetoothctl で Bluetooth デバイスを接続する
bluetoothctl は
、グラフィカルユーザーインターフェイスに依存せずに、接続をスキャン、ペアリング、接続、管理するためのコマンドラインユーティリティーです。
前提条件
-
bluetooth.service
ユニットが有効になっています。
手順
bluetoothctl
対話型プロンプトに入力します:bluetoothctl
$ bluetoothctl
Copy to Clipboard Copied! システムの Bluetooth のステータスを確認します。
show
[bluetoothctl]# show Powered: no Discoverable: no DiscoverableTimeout: 0x000000b4 Pairable: no
Copy to Clipboard Copied! bluetoothctl が
電源オンになっていない場合は、次のように入力します。power on
[bluetoothctl]# power on
Copy to Clipboard Copied!
システムの範囲内で接続するデバイスをペアリングモードに設定し、システムを検出およびペアリング可能にします。
discoverable on
[bluetoothctl]# discoverable on
Copy to Clipboard Copied! pairable on
[bluetoothctl]# pairable on
Copy to Clipboard Copied! Bluetooth デバイスのスキャンを開始します:
scan on
[bluetoothctl]# scan on
Copy to Clipboard Copied! 検出されたデバイスのリストが、MAC アドレスと名前 (存在する場合) とともに表示されます。
デバイスが見つかったら、スキャンを停止します。
scan off
[bluetoothctl]# scan off
Copy to Clipboard Copied! - 接続するデバイスの MAC アドレスをメモします。
デバイスをペアリングします:
pair XX:XX:XX:XX:XX:XX
[bluetoothctl]# pair XX:XX:XX:XX:XX:XX
Copy to Clipboard Copied! システム上でペアリングコードの確認を求められる場合があります。
ペアリングしたデバイスを信頼します:
trust XX:XX:XX:XX:XX:XX
[bluetoothctl]# trust XX:XX:XX:XX:XX:XX
Copy to Clipboard Copied! オプション: このデバイスを今後自動的に接続したい場合は、デフォルトとして設定できます。
default XX:XX:XX:XX:XX:XX
[bluetoothctl]# default XX:XX:XX:XX:XX:XX
Copy to Clipboard Copied! 完了したら、
bluetoothctl を
終了します。quit
[bluetoothctl]# quit
Copy to Clipboard Copied!
検証
接続したデバイスのステータスを確認します。
devices
[bluetoothctl]# devices Device AA:BB:CC:DD:EE:FF Headphones (Connected: yes) Device 11:22:33:44:55:66 Keyboard (Connected: no)
Copy to Clipboard Copied! info AA:BB:CC:DD:EE:FF
[bluetoothctl]# info AA:BB:CC:DD:EE:FF <device information> Connected: yes
Copy to Clipboard Copied!