bluetoothドングルの余っているのを、再活用しようとチャレンジ。 ただ、管理用のソフトが日進月歩なのか、CUIで操作する方法は、 参考にならない記事ばかり。(この記事もいつまで使えるやら...)
サーバで活用したいので、gnomeやkdeを使った設定も使いたくないので、 調べると、bluetooth-agent(bluez) を使ってという記事があるけど、 jessie では入っていない。
bluetoothなんちゃら...だろうと、shellの補完させると、 bluetoothctl なんていうコマンドがある。
インストールとbluetoothドングルの確認
((bluetooth関連のインストール)) $ sudo aptitude install bluetooth $ sudo /etc/init.d/bluetooth start
次にbluetoothの認識されている状態を確認。 buffaloのメジャーなbluetoothドングルなのか、普通に認識している。
((bluetoothの認識状態))
$ sudo /etc/init.d/bluetooth status
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled;
vendor preset: enabled)
Active: active (running) since 木 2015-10-15 18:12:51 JST; 17min ago
Docs: man:bluetoothd(8)
Main PID: 9999 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─9999 /usr/lib/bluetooth/bluetoothd
bluetoothctlコマンドでペアリング
bluetooth-agent の変わりに、bluetoothctlを使う。 "[bluetooth]#" のプロンプトが出たら、様々なコマンドが対話的に使える。 "help"で命令も見れるので、見ながら適当にやってみる。
((bluetoothctl))
$ sudo bluetoothctl
[NEW] Controller 00:1B:DC:xx:xx:xx host [default]
[bluetooth]# list
Controller 00:1B:DC:xx:xx:xx host [default]
[bluetooth]# show
Controller 00:1B:DC:xx:xx:xx
Name: host
Alias: host
Class: 0x000104
Powered: yes
Discoverable: no
Pairable: yes
UUID: Generic Attribute Profile...
肝心のペアリングだけど、"pair"なんてコマンドがあるし、試してみる。 BT番号を入力したら簡単に成功。ろくにマニュアル見ていないけど、 ここまではスムーズ。
((bluetoothのペアリング)) [bluetooth]# power on ←ドングルを使えるように [bluetooth]# scan on ←デバイスを探す Discovery started [CHG] Controller 00:1B:DC:xx:xx:xx Discovering: yes [NEW] Device 70:3E:AC:xx:xx:xx iphone6-user デバイスを見つけるたびに情報が表示される [bluetooth]# scan off ←デバイス探しを止める [bluetooth]# pair 70:3E:AC:xx:xx:xx ←見つけたデバイスのアドレス : ((ここでペアリング相手にメッセージが出るのでOKを押す)) [CHG] Device 70:3E:AC:94:73:34 Paired: yes Pairing successful ←ペアリング成功 ((ペアリングで信用登録が必要な場合)) [bluetooth]# trust 70:3E:AC:xx:xx:xx ←デバイスを信用 [bluetooth]# connect 70:3E:AC:xx:xx:xx ←デバイスを接続
再起動後にも接続するための設定
この記事によると、udev で対応をとるらしい。
(( /etc/udev/rules.d/10-local-bluetooth.rules )) $ sudo vi /etc/udev/rules.d/10-local-bluetooth.rules # Set bluetooth power up ACTION=="add", KERNEL=="hci0″, RUN+="/usr/bin/hciconfig hci0 up"