涂鸦 Zigbee 强电场景开关接入标准

概述

  1. Zigbee 强电场景开关是一个控制设备,通过场景指令实现场景群控功能。

  2. 用 Zigbee 3.0 标准里的 Scene Selector 设备来实现。

名词解释

名词
解释
Zigbee SDK 基于芯科 Zigbee 协议栈经过裁剪、优化后封装的涂鸦 Zigbee SDK。
Attribute Attribute (属性)是一个反映物理数量或状态的数据值。
Cluster Cluster (群集)是包含一个或多个属性(attribute)的群集 。
Endpoint Endpoint (端点)是协议栈应用层的入口,即入口地址,也可以理解应用对象存在的地方,它是为实现一个设备描述而定义的一组群集 。
Device ID Zigbee 中为每一种设备定义的序号。
弱电设备 是指使用电池供电的设备,在 Zigbee 协议中被称为 sleep end device 的设备 。
强电设备 是指使用市电或者从市电稳压后的电源供电的设备,在 Zigbee 协议中被称为 router 的设备。
PID Product ID,在涂鸦 IoT 平台创建的每一个产品都会产生一个唯一的产品编号,关联了产品具体的功能点、App 控制面板、出货信息等所有跟这个产品相关的信息。
SOC System on chip,硬件本身无 MCU,控制程序写入联网模块中。
SDK Software Development Kit,软件开发工具包,辅助开发某一类软件的相关文档、范例和工具的集合。为了鼓励开发者使用其系统或者语言,许多 SDK 是免费提供的,涂鸦的也是。
固件 Firmware,就是写入 EROM (可擦写只读存储器)或 EEPROM (电可擦可编程只读存储器)中的程序。固件是指设备内部保存的设备“驱动程序”,通过固件,操作系统才能按照标准的设备驱动实现特定机器的运行动作,比如光驱、刻录机等都有内部固件。固件是担任着一个系统最基础最底层工作的软件。
OTA 是固件升级的意思,我们是支持 OTA 的。

Zigbee 设备功能描述

Zigbee 协议版本

产品为基于标准的 Zigbee 3.0 协议。

Profile ID 0x0104
Device ID 0x0004

Endpoint

Endpoint 描述
1 第一路场景开关
2 第二路场景开关

支持的 Clusters

Scene Selector (0x0004)
Input Clusters(Server) Output Clusters(Client)
Basic(0x0000) OTA(0x0019)
IDentify(0x0003) Group Cluster(0x0004)
Group Cluster(0x0004) Scene Cluster(0x0005)
Scene Cluster(0x0005)

支持的属性和命令

属性填写的目的是网关可以通过 Zigbee 标准读写属性来获取设备的基本信息。

Commands 中使用的 C->S 表示 Client 端发送给 Server 端的 Command;S->C 表示 Server 端发送给 Client 端的 Command。

Basic Cluster

Attributes:

ID name Data Type
Range
Default
0x0000 ZCLVersion uint8-0x20 0x00-0xff 0x03
0x0001 ApplicationVersion uint8-0x20 0x00-0xff ie: 0b 01 00 0001 = 1.0.1 即 0x41 为 1.0.1 OTA 功能会用到该版本号,在 OTA 开始阶段,网关会读取 OTA 包的版本号推送给设备。在 OTA 成功重启后,网关会读取版本号来确定是否升级成功。只能往更高的版本升级。
0x0002 StackVersion uint8-0x20 0x00-0xff 0x02
0x0003 HWVersion uint8-0x20 0x00-0xff 0x01
0x0004 ManufactureName string-0x42 0-32 bytes XXX…XXX(长度为 16 个字节,由 8 字节前缀和 8 字节的 PID 组成) 0 - 7 bytes:_TZ3000_ 该字段决定了手机 App 界面的 UI 和功能展现 如果对 PID 没什么要求可用用默认 PID。
0x0005 ModeIDentifier string-0x42 0-32 bytes 该字段为了网关快速识别设备类型用,提升体验   
0x0007 PowerSource enum8-0x30 0x00-0xff 0x01
0xfffd Cluster revision uint16-0x21 0x0000-0xffff 0x0001

Commands:

ID name Direction Description
0x00 Reset To Factory Default C->S

IDentify Cluster

Attributes:

ID name Data Type **Range ** Default
0x0000 IDentifyTime uint16-0x21 0x0000-0xffff 0x0000
0xfffd ClusterRevision uint16-0x21 0x0000-0xffff 0x0001

Commands:

ID name Direction Description
0x00 IDentify C->S -
0x01 IDentify Query C->S -

Groups Cluster

Attributes:

ID name Data Type Range Default
0x0000 NameSupport Bitmap8-0x18
0xfffd ClusterRevision uint16-0x21 0x0000-0xffff 0x0001

Commands:

ID name Direction Description
0x00 Add Group C->S -
0x01 View Group C->S -
0x02 Get Group membership C->S -
0x03 Remove Group C->S -
0x04 Remove all Groups C->S -
0x05 Add Group if IDentifying C->S -
0x00 Add Group Response S->C -
0x01 View Group Response S->C -
0x02 Get Group membership Response S->C -
0x03 Remove Group Response S->C -

Scene Cluster

Attributes:

ID name Data Type Range Default
0x0000 SceneCount uint8-0x20 0x00-0xff 0x00
0x0001 CurrentScene uint8-0x20 0x00-0xff 0x00
0x0002 CurrentGroup uint16-0x21 0x0000-0xfff7 0x00
0x0003 SceneValID bool-0x10 0x00-0x01 0x00
0x0004 NameSupport Bitmap8-0x18
0xfffd ClusterRevision uint16-0x21 0x0000-0xffff 0x0001

Commands:

ID name Direction Description
0x00 Add Scene C->S -
0x01 View Scene C->S -
0x02 Remove Scene C->S -
0x03 Remove All Scenes C->S -
0x04 Store Scene C->S -
0x05 Recall Scene C->S -
0x06 Get Scene Membership C->S -
0x40 Enhanced Add Scene C->S -
0x41 Enhanced View Scene C->S -
0x42 Copy Scene C->S -
0x00 Add Scene Response S->C -
0x01 View Scene Response S->C -
0x02 Remove Scene Response S->C -
0x03 Remove All Scenes Response S->C -
0x04 Store Scene Response S->C -
0x06 Get Scene Membership Response S->C -
0x40 Enhanced Add Scene Response S->C -
0x41 Enhanced View Scene Response S->C -
0x42 Copy Scene Response S->C -

Over The Air Upgrade

Attributes:

ID name Data Type Range Default
0x0000 UpgradeServerID EUI64-0xF0 0xffffffffffffffff
0x0001 FileOffset uint32-0x23 0x00000000
0x0002 CurrentFileVersion uint32-0x23 0x00000000
0x0006 ImageUpgradeStatus enum8-0x30 0x00
0x0007 Manufature ID uint16-0x21 0x1002
0x0008 Image Type ID uint16-0x21 0x1602
0x0009 MinimumBlockPeriod uint16-0x21 0x0000-0xfffe 0x0000
0xfffd ClusterRevision uint16-0x21 0x0000-0xffff 0x0001

Commands:

ID name Direction Description
0x00 Image Notify S->C
0x01 Query Next Image Request C->S
0x03 Image Block Request C->S
0x06 Upgrade End Request C->S

Zigbee 设备流程机制

组网流程的要求

(1) Beacon request 信道扫描间隔大于 200ms,优先扫描优先信道。

(2) 扫描时间不超过 5 分钟。

(3) 如果需要上报数据,组网成功后采用 5s 到 10s 或者以上的随机延上报数据。

设备断电启动流程的要求

(1) 至少大于 15s 后上报数据。

链路维护的要求

(1) 持续 2 分钟 30 秒到 3 分钟之间的随机值上报设备版本号。

(2) 当有任一数据上报成功后延迟 2 分钟 30 秒到 3 分钟之间的随机值上报设备版本号。

数据上报的要求

(1) 如果开启了 APS 层的重传建议把 Disable Default Response 设置成 1,避免太多ack。

(2) 重传数据的 Transaction Sequence Number 需要保持一致。

(3) 重传间隔大于 250 ms,重传持续时间建议低于 3s。

(4) 收到广播、组播、情景控制时,建议需要延迟 1 分钟 - 2 分钟的随机值上报状态,延迟时间没有到达期间收到单播控制,立即上报状态。

特殊功能说明

zigbee 本地场景功能

(1) 通过 App 面板配置好场景开关哪个 Endpoint 作为触发,以及被控设备哪个 Endpoint 执行动作后,网关会先发送相应的动作指令给被控设备的 Endpoint,确认被控设备可以被执行。

(2) 网关通过 Groups Cluster 的 Add Group 依次下发 Group ID 给每个被控设备 Endpoint,被控设备回应 Add Group Response 给网关;网关通过 Scene Cluster 的 Store Scene 依次下发 Group ID 和 Scene ID 给每个被控设备 Endpoint,被控设备回应 Store Scene Response 给网关,设备保存该时的状态作为场景执行时的动作,收到上述所有被控设备的 Add Group Response 和 Store Scene Response 后 App 显示验证完成。

(3) App 显示验证完成后,点击保存,网关通过 Scene Cluster 的 Add Scene 下发 Group ID 和 Scene ID 给场景开关的触发 Endpoint,被控设备回应 Add Scene Response 给网关。注意如果场景开关该 Endpoint 已经存储了 Group ID 和 Scene ID ,则舍弃原有的 Group ID 和 Scene ID 存储下发的 Group ID 和 Scene ID。

(4) 通过 App 点击执行场景,或是点击场景开关的触发 Endpoint 对应的按键后,网关或是场景开关通过 Scene Cluster 的 Recall Scene 通过组播方式发送给被控设备 Group ID 和 Scene ID,设备收到该帧后执行该 Group ID 和 Scene ID 相应的动作,实现执行对应的场景功能,场景开关可以在 zigbee 局域网下进行执行场景而不需要网关,该功能被称为 zigbee 本地场景功能。

开发方式

  1. 基于涂鸦 Zigbee SDK 开发:

    (1)你只需修改 demo 样例的模块型号和硬件配置即可完成上述功能,包括群组,场景均实现

    (2)涂鸦提供完整的烧录,授权,产测流程和软硬件工具

涂鸦 Zigbee SDK 使用说明

烧录授权、产测工具使用说明

  1. 自行开发-非涂鸦 Zigbee 模块:

    (1) 需要完整实现上述技术细节

    (2)完成设备授权

  2. 使用涂鸦完整授权工具授权

通过模块和上位机串口通信授权

串口通信协议文档

串口通信实例代码

使用涂鸦授权 SDK 授权

  1. 自行开发-涂鸦 Zigbee 模块:

    (1)只需要实现固件功能细节

    (2)购买授权过的涂鸦 Zigbee 模块即可