パスワードを忘れた? アカウント作成
12144678 journal
日記

shimashimaの日記: [Edison][IoT]EdisonのBluetoothでTI SensorTagと接続する

日記 by shimashima

Intel EdisonとTI SensorTagをBluetooth LEで接続してみたので手順を載せる。
Intel® Edison Products Bluetooth* User Guideが公式資料として配布されており、こちらにはBluetoothに関する情報が載っているので目を通しておくとよいだろう。

1. EdisonでのBluetooth有効化

初期状態ではEdisonのBluetoothがソフトウェア的に無効化されているので有効化を行う。
ここでいう初期状態とは、

# uname -a
  Linux edison-01 3.10.17-poky-edison+ #1 SMP PREEMPT Wed Apr 29 03:54:01 CEST 2015 i686 GNU/Linux

の導入直後の状態をさす。

Bluetoothの有効/無効の状態は以下のようにして識別する。

# rfkill list
0: phy0: wlan
                Soft blocked: no
                Hard blocked: no
1: brcmfmac-wifi: wlan
                Soft blocked: no
                Hard blocked: no
2: bcm43xx Bluetooth: bluetooth
                Soft blocked: yes
                Hard blocked: no
3: hci0: bluetooth
                Soft blocked: no
                Hard blocked: no

のように出力される。ここで、

2: bcm43xx Bluetooth: bluetooth
                Soft blocked: yes

と、ソフトウェア的に無効化されていることがわかる。有効化するためには

# rfkill unblock bluetooth
# rfkill list
0: phy0: wlan
                Soft blocked: no
                Hard blocked: no
1: brcmfmac-wifi: wlan
                Soft blocked: no
                Hard blocked: no
2: bcm43xx Bluetooth: bluetooth
                Soft blocked: no
                Hard blocked: no
3: hci0: bluetooth
                Soft blocked: no
                Hard blocked: no

となり、Bluetoothが有効化される。

2. SensorTagとの接続

Bluetoothで機器と接続する方法はいくつかあるようだが、ここではbluetoothctlを使ってみる。

# bluetoothctl
[NEW] Controller XX:XX:XX:XX:XX:XX --help [default]
[bluetooth]#

と出力され、専用コンソールに切り替わる。

[bluetooth]# agent KeyboardDisplay
[bluetooth]# default-agent

として、デフォルトエージェントの設定を行った後、(実は自分もここは意味が分かっていない)

[bluetooth]# scan on

としてBluetoothの機器スキャンを始める。

このとき、SensorTagの電源が入っていると

[bluetooth]# scan on
Discovery started
[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
[NEW] Device ZZ:ZZ:ZZ:ZZ:ZZ:ZZ SensorTag

とSensorTagを発見してもらえる。

まずペア認識を行う。

[bluetooth]# pair ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
Attempting to pair with ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
[CHG] Device ZZ:ZZ:ZZ:ZZ:ZZ:ZZ Connected: yes
[CHG] Device ZZ:ZZ:ZZ:ZZ:ZZ:ZZ UUIDs:
                00001800-0000-1000-8000-00805f9b34fb
                00001801-0000-1000-8000-00805f9b34fb
                0000180a-0000-1000-8000-00805f9b34fb
                0000ffe0-0000-1000-8000-00805f9b34fb
                f000aa00-0451-4000-b000-000000000000
                f000aa10-0451-4000-b000-000000000000
                f000aa20-0451-4000-b000-000000000000
                f000aa30-0451-4000-b000-000000000000
                f000aa40-0451-4000-b000-000000000000
                f000aa50-0451-4000-b000-000000000000
                f000aa60-0451-4000-b000-000000000000
                f000ccc0-0451-4000-b000-000000000000
                f000ffc0-0451-4000-b000-000000000000
[CHG] Device ZZ:ZZ:ZZ:ZZ:ZZ:ZZ Paired: yes
Pairing successful
[CHG] Device ZZ:ZZ:ZZ:ZZ:ZZ:ZZ Modalias: bluetooth:v000Dp0000d0110

とでてペアができる。
そののち、

[bluetooth]# connect ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
Attempting to connect to ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
Connection successful

となり接続が完了する。

実は接続後の情報取得についてはまだ調査中。
BlueZに含まれるgetttoolを使うとBluetoothLEのGATTの情報を取得できるのだが、EdisonにはBlueZ自体は含まれているもののgatttoolはなぜか入っていないのでBlueZをソースからmakeする必要がありそうだ。

とりあえず、疎通確認は以上。

3. 参考

http://martinkronberg.com/new-blog/2015/4/10/ti-sensortag-with-intel-edison-and-gatttool
こちらはgatttoolを使ってSensorTagのセンサーデータを取得するところまで行っている。

この議論は賞味期限が切れたので、アーカイブ化されています。 新たにコメントを付けることはできません。
typodupeerror

クラックを法規制強化で止められると思ってる奴は頭がおかしい -- あるアレゲ人

読み込み中...