LoginSignup
9

More than 5 years have passed since last update.

BlueZにてBLEのアドバタイズ送信パラメータを調整する

Last updated at Posted at 2015-12-01

Overview

・BlueZにてBLEアドバタイズパケットを送信する際の周期を変更する
・アドバタイズタイプを指定する
・自アドレスのタイプを指定する
・ペアのアドレスタイプを指定する
・ペアのアドレスを指定する
・アドバタイズパケットのチャンネルを指定する
・アドバタイズフィルタのポリシーを設定する

コマンド


$ sudo hcitool -i hci0 cmd 0x08 0x0006 Min Max AdvT OwnAdT PeerAdT PeerAd ChMap Policy

※各データは16進数表記.1オクテットごとにスペース区切り.リトルエンディアン.
 リトルエンディアンとは:http://www.wdic.org/w/TECH/%E3%83%AA%E3%83%88%E3%83%AB%E3%82%A8%E3%83%B3%E3%83%87%E3%82%A3%E3%82%A2%E3%83%B3

Min (Advertising_Interval_Min)

初期値 説明
N = 0xXXXX 0x0800 最小のアドバタイズパケット送信周期.
Range:N = 0x0020 to 0x4000
Time = N * 0.625msec

Max (Advertising_Interval_Max)

初期値 説明
N = 0xXXXX 0x0800 最大のアドバタイズパケット送信周期.
Range:N = 0x0020 to 0x4000
Time = N * 0.625msec

AdvT (Advertising_Type)

説明
0x00 Connectable undirected advertising (ADV_IND) 初期値
0x01 Connectable high duty cycle directed advertising(ADV_DIRECT_IND, high duty cycle)
0x02 Scannable undirected advertising (ADV_SCAN_IND)
0x03 Non connectable undirected advertising (ADV_NONCONN_IND)
0x04 Connectable low duty cycle directed advertising(ADV_DIRECT_IND, low duty cycle)
0x05-0xFF 未使用

OwnAdT (Own_Address_Type)

説明
0x00 Public Device Address 初期値
0x01 Random Device Address
0x02 Controller generates Resolvable Private Address based on the local IRK from resolving list.
If resolving list contains no matching entry, use public address.
0x03 Controller generates Resolvable Private Address based on the local IRK from resolving list.
If resolving list contains no matching entry, use random address from LE_Set_Random_Address.
0x04-0xFF 未使用

PeerAdT (Peer_Address_Type)

説明
0x00 Public Device Address (初期値) or Public Identity Address
0x01 Random Device Address or Random (static) Identity Address
0x02-0xFF 未使用

PeerAd (Peer_Address)

説明
0xXXXXXXXXXXXX Public Device Address, Random Device Address, Public Identity Address, or Random (static) Identity Address of the device to be connected

ChMap (Advertising_Channel_Map)

説明
00000000b 未使用
xxxxxxx1b Channel 37 shall be used
xxxxxx1xb Channel 38 shall be used
xxxxx1xxb Channel 39 shall be used
xxxxx111b all channels enabled 初期値

Policy(Advertising_Filter_Policy)

説明
0x00 Process scan and connection requests from all devices (i.e., the White List is not in use) 初期値
0x01 Process connection requests from all devices and only scan requests from devices that are in the White List.
0x02 Process scan requests from all devices and only connection requests from devices that are in the White List..
0x03 Process scan and connection requests only from devices in the White List.
0x04-0xFF 未使用

備考

  • いろいろパラメータをいじった場合,hciconfig hci0 leadv 3にてアドバタイズを開始しないこと.
    (レートが自動的に1280msに変わる)
    hcitool -i hci0 cmd 0x08 0x000a 01にてアドバタイズを開始すること.
  • Min,Max,PeerAdは特にリトルエンディアン記法に注意.

実行例

  • アドバタイズパケット送信周期を200msから1000msにしたい.
  • アドバタイズタイプはADV_SCAN_INDで.
  • あとは特に指定なし

Min : 200 / 0.625 = 320 = 0x0140
Max : 1000 / 0.625 = 1600 = 0x0640
AdvT: ADV_SCAN_IND -> 0x02
$ sudo hcitool -i hci0 cmd 0x08 0x0006 40 01 40 06 02 00 00 00 00 00 00 00 00 07 00
$ sudo hcitool -i hci0 cmd 0x08 0x000a 01

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9