0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CLI で Zigbee その1

Last updated at Posted at 2020-04-16

Nordic の CLI コントロールの Zigbee サンプルプログラムを試してみます。
今回は、接続確認して CLI デバイス同士で ping ができるところまで。

続きはこちら
「CLI で Zigbee その2」
https://qiita.com/nanbuwks/items/308a421eaa61dd3f8fb4

環境

  • 開発ボード アオノドン2019(Raytac MDBT50Q / Nordic nRF52840 搭載) Zigbee ルータとして使用
  • 開発ボード MDBT50Q-DB (Raytac MDBT50Q / Nordic nRF52840 搭載) Zigbee コーディネーター として使用
  • IDE Segger Enbedid Studio
  • SDK nRF5_SDK_for_Thread_and_Zigbee_v4.0.0_dc7186b
  • 開発PC Ubuntu 18.04LTS

プログラム

examples の zigbee ディレクトリ中は以下のようになっています。

├── app_utils
│ └── ws2812
├── experimental
│ ├── cli
│ ├── light_control
│ ├── multi_sensor
│ └── multi_sensor_freertos
├── light_control
│ ├── light_bulb
│ ├── light_coordinator
│ └── light_switch
└── ota
├── bootloader
├── client
└── experimental_server

このうち、以下を使用。

├── experimental
│ ├── cli ルータまたはコーディネーター・アオノドン2019 2台で実行
│ ├── light_control
│ ├── multi_sensor
│ └── multi_sensor_freertos
├── light_control
│ ├── light_bulb 照明エンドデバイス・アオノドン2019で実行
│ ├── light_coordinator
│ └── light_switch

元ネタ

以下の解説ページに沿って動かしていきます。

「Zigbee CLI Agent example」
https://infocenter.nordicsemi.com/topic/sdk_tz_v4.0.0/zigbee_example_cli_agent.html

また、以下にCLIのライブラリ、およびリファレンスの解説があります。

「Command Line Interface library」
https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_cli.html
「Zigbee CLI Reference」
https://infocenter.nordicsemi.com/topic/sdk_tz_v4.0.0/zigbee_example_cli_reference.html

照明エンドデバイスを用意

「Nordic nRF52840 で Zigbee 照明とスイッチ」
https://qiita.com/nanbuwks/items/92a76bc68ebb75a58dfd

と同じ操作で照明エンドデバイスを用意しておきます。

CLI デバイスを用意

CLI として使うデバイスを1台用意します。ファームウェアをコンパイル、アオノドン2019に書き込みます。

CUIインターフェースとして、下記の両方が使えます。

  • UART
  • USB CDC device

今回はUARTを使います。

115200bps,8N1で通信します。

picocom で つなげてみましたが全然反応がなくて、あれれ〜? とおもっていたら RTS/CTS線の配線が必要でした。はて、どこにハードウェアフロー制御の記述があるのかな?

image.png

image.png

※ハードウェアフロー制御を解除するために別記事を書きました。

「Nordic Zigbee CLI Example の UART設定」
https://qiita.com/nanbuwks/items/cf66d56979ad9a2a7a96

配線繋ぐとプロンプトが出てきました。

操作方法

タブを押すと入力候補が表示されます。


  balloc   bdb      log      queue    radio    reset    version  zcl
  zdo
> 

このほか、

  • タブで入力補完を使うことができます。
  • 上矢印で入力履歴を呼び出せます(8つまで)。
  • reset でリセット。ハードウェアを触らなくていいので便利。
  • BackSpaceは効かないがDeleteは効く
  • 左右カーソルキーが効く

コーディネーターに接続

まずは、コーディネーターとして light_coordinator を使って実験します。
light_coordinator は起動後一定の間しか接続を受け付けません。
CLI と コーディネータを同時に起動し、2台の CLI デバイスの両方で以下のようにします。


> bdb start
Started router
Done

すると、コーディネーターに以下のようにログが表示されます。


<info> app: Production configuration is not present or invalid (status: -1)
<info> app: Zigbee stack initialized
<info> app: Start network steering
<info> app: Network steering started
<info> app: Device update received (short: 0x194D, long: f4ce365035f26ad5, status: 1)
<info> app: New device commissioned or rejoined (short: 0x194D)
<info> app: Joining period extended.
<info> app: Device authorization event received (short: 0x194D, long: f4ce365035f26ad5, authorization type: 1, authorization status: 0)
<info> app: Device update received (short: 0xBFB4, long: f4ce36a90365d8fb, status: 1)
<info> app: New device commissioned or rejoined (short: 0xBFB4)
<info> app: Joining period extended.
<info> app: Device authorization event received (short: 0xBFB4, long: f4ce36a90365d8fb, authorization type: 1, authorization status: 0)
<info> app: Network steering finished

2つで実験します。

自分のアドレスを調べます。


> zdo short
194D
> zdo eui64
f4ce365035f26ad5

ここで、


> zdo short
Error: Check if device was commissioned

と出た場合はコーディネータに接続できていません。

もう一台で、ping してみます。



> zcl ping 194D 30
> 
Ping time: 15 ms
Done
 zcl ping f4ce365035f26ad5 30
> 
Ping time: 13 ms
Done

ショートアドレス、ロングアドレス共にPINGができていることを確認できました。

CLIでコーディネーター

先程は light_coordinator をコーディネーターとして使いましたが、CLIでコーディネータとして動かしてみます。

light_coordinator の電源をOffにし、CLIデバイス2台を再起動しました。

1台で以下のようにします。


> bdb role zc
Coordinator set
Done
> bdb start
Started coordinator
Done
> zdo short
0000
Done
> zdo eui64
f4ce36a90365d8fb
Done
> 

コーディネーターの短縮アドレスは 0000 となっていました。
もう一台からping を飛ばして、OKなことが確認できました。


> bdb start
Started router
Done
> zcl ping 0000 30
> 
Ping time: 13 ms
Done
> zcl ping f4ce36a90365d8fb 30
> 
Ping time: 15 ms
Done

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?