More Related Content Similar to BlueZで遊んでみる - BLE大阪勉強会 Similar to BlueZで遊んでみる - BLE大阪勉強会 (20) BlueZで遊んでみる - BLE大阪勉強会8. 近くのデバイスを
検索してみる
$ hciconfig -a
hci0: Type: BR/EDR Bus: USB
BD Address: 00:1B:DC:06:2C:AD ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN
… 省略
$ sudo hcitool lescan
LE Scan ...
44:13:19:02:E1:D9 LBT-VRU01
… 省略
◀ DOWNだったら hciconfig up する
◀ なんか見えた!!
9. 接続してみる
$ sudo hcitool lecc 44:13:19:02:E1:D9
Connection handle 71
$ sudo gatttool -i hci0 -b 44:13:19:02:E1:D9 -t random -I
[44:13:19:02:E1:D9][LE]> connect
Attempting to connect to 44:13:19:02:E1:D9
Connection successful
[44:13:19:02:E1:D9][LE]> primary
attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-….
attr handle: 0x0008, end grp handle: 0x000a uuid: 00001803-….
attr handle: 0x000b, end grp handle: 0x000d uuid: 00001802-….
attr handle: 0x000e, end grp handle: 0x0010 uuid: 00001804-….
attr handle: 0x0011, end grp handle: 0xffff uuid: 0000180f-….
◀ なにこれ??
15. Device Nameを見てみる。
[44:13:19:02:E1:D9][LE]> primary
attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-….
…省略
[44:13:19:02:E1:D9][LE]> char-desc 0x0001 0x0007
handle: 0x0001, uuid: 2800
handle: 0x0002, uuid: 2803
handle: 0x0003, uuid: 2a00
handle: 0x0004, uuid: 2803
handle: 0x0005, uuid: 2a01
handle: 0x0006, uuid: 2803
handle: 0x0007, uuid: 2a04
[44:13:19:02:E1:D9][LE]> char-read-hnd 0x0003
Characteristic value/descriptor: 4c 42 54 2d 56 52 55 30 31
◀ これがDevice Name.
ASCII表記「LBT-VRU01」
18. ぶるタグを鳴らしてみる
[44:13:19:02:E1:D9][LE]> primary
attr handle: 0x000b, end grp handle: 0x000d uuid: 00001802-….
[44:13:19:02:E1:D9][LE]> char-desc 0x000b 0x000d
handle: 0x000b, uuid: 2800
handle: 0x000c, uuid: 2803
handle: 0x000d, uuid: 2a06
[44:13:19:02:E1:D9][LE]> char-write-cmd 0x000d 02
◀ これがAlert Level.
21. Advertizeを投げてみる
$ sudo hciconfig hci0 leadv 3
0x02 0x01 0x0a 0x02 0x0a 0x08 0x0c 0x09
0x43 0x53 0x52 0x38 0x35 0x31 0x30 0x20
0x41 0x31 0x30 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00
◀ [CSR8510 A10] Androidがデバイス名として
認識してるのはこの辺りぽいけど?
22. Advertizeパケット
Preamble
1 octet 4 octet
Access Address Protocol Data Unit
2 ∼ 39 octet
CRC
3 octet
▼先のAPIが取得できてたのはココ。
Header
2 octet
Payload
6 ∼ 37 octet
AdvA Adv Data
Length AD Type Data
6 octet 0 ∼ 31 octet
1 octet 1 octet N octet