在Cygwin环境下构建并使用EmberZNet PRO Zigbee Host应用程序
ZigBee 3.0 Gateway简介:
Silicon labs的ZigBee 3.0 Gateway方案是由一个Zigbee Host Application + Zigbee NCP firmware组成。NCP和Host Application软件可以用Silicon labs Simplicity studio生成。Zigbee Host Application需要在Linux环境下编译和运行。
-
安装Cygwin
-
安装必要的组件,在Cygwin下构建和编译EmberZNet PRO Zigbee Host需要的组件如下:
• Bash shell
• Make
• GCC4
• sed
• awk
• xargs
• The standard C Library and its development headers
• libreadline-devel - The Readline Library and its development headers
• libncurses-devel - The Ncurses Library and its development headers
Bash和make的安装
sed和gcc的安装
awk, libreadline和libncures的安装
-
在Simplicity studio中新建一个Z3GatewayHost的工程
-
在Cygwin下编译Z3GatewayHost的工程。
-
在Cygwin下运行Z3GatewayHost程序,Z3GatewayHost的位置和第3步新建立项目有
关。注意Cygwin中使用斜杠(/) 来表示目录,Windows中使用的是反斜杠()
C:/Users/user name/SimplicityStudio/v5_workspace/Z3GatewayHost/build/exe
./Z3GatewayHost.exe -n 0 -p comx
-n 0 代表网关程序使用115200波特率,硬件流控来连接NCP 8 N 1
-n 1 代表网关程序使用57600波特率,软件流控来连接NCP 8 N 1
-r c 代表NCP复位方式,这里使用硬件DTR/RTS脚位去控制,关于硬件复位电路,
-p COMx 代表指定串口端口的名称。
- 创建一个Zigbee网络-
plugin network-creator form [useCentralizedSecurity:1] [panId:2] [radioTxPower:1] [channel:1]
- useCentralizedSecurity - BOOLEAN - 是否创建一个集中式网络. 如果这个值是false,则创建一个分布式网络。
- panId - INT16U - 创建的网络的PanID
- radioTxPower - INT8S - 创建的网络的发射功率
- channel - INT8U - 创建的网络的通道号
- 打开网络,允许设备加入
plugin network-creator-security open-network
打开网络,只允许终端设备以Install Code派生的Link key加入
plugin network-creator-security open-with-key [eui64:8] [joiningLinkKey:-1]
- eui64 - 待入网设备的IEEE地址EUI64
- joiningLinkKey - 待入网设备的Install Code派生的Link key,可以由Install code使用HashingTool生产。
- 在终端设备上启动入网操作-plugin network-steering start [options:1]
- 使用ZCL命令控制设备
zcl on-off toggle
send [id:2] [src-endpoint:1] [dst-endpoint:1]
所有的ZCL命令后面都需要使用Send命令将缓冲区中的消息从一个endpoint发送到指定短地址的另一个endpoint。
- id:目标设备的短地址,数据类型为INT16U
- src-endpoint:源设备的endpoint,数据类型为INT8U
- dst-endpoint:目标设备的endpoint,数据类型为INT8U
- 使用EmberZNet PRO Zigbee Host对终端设备进行OTA操作。Z3GatewayHost在启动后会在”Z3GatewayHost.exe”这个文件的同一个目录生成一个”ota-files”的文件夹。将需要OTA的终端设备的ota文件放在这个文件夹,待Z3GatewayHost.exe运行后会自动开启ota操作。Ota文件可以由image-builder或Simplicity commander生成。
commander ota create --upgrade-image <filename> --manufacturer-id <ID> --image-type <image type> --firmwareversion <version> --string <text> -o <outfile> [--manufacture-tag <tag ID:filename> -stack-version <version> -- credentials <credentials> --destinations <EUI64> --min-hw <version> --max-hw <version>]
参考资料:
http://www.voxforge.org/home/docs/cygwin-cheat-sheet
https://community.silabs.com/s/article/setting-up-cygwin-for-mesh-development?language=en_US
CSDN博客仅作为本人工作学习之余的笔记使用,无任何商业目的,如果侵犯了你的隐私或权益,请随时联系作者,本人将及时删除相关内容