用户工具

站点工具


zigbee:zcl

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

zigbee:zcl [2019/08/22 21:02]
jaylee 创建
zigbee:zcl [2021/06/22 23:14]
行 1: 行 1:
-# zigbee zcl 
  
-<markdown> 
- 
-* [ZigBee Cluster Library Specification r6](https://zigbee.org/download/zigbee-custer-library/?wpdmdl=6350&refresh=5d5e4e07cc4151566461447) 
- 
-  > **提示**:zigbee 3.0 是基于 r7版本,但是非zigbee 成员,官方只是只是释放了如上的r6版本。 
- 
-* [Webinar_ZigBee_3-0_Launch_FINAL](https://www.zigbee.org/download/introducing-zigbee-3-0-webinar-presentation/?wpdmdl=2176)->`ZigBee 3.0 Devices and Application Clusters  ` 
- 
-![zcl 框架图](images/zcl_architecture.png) 
- 
- 
- 
-首先, 需要清晰认识zigbee架构的系统框图,zcl 是zigbee 应用框架层上用以约定抽象描述物联网设备的协议,也就是对于不同厂商需要研发的物联网产品,都可以基于zcl 的设备描述,通过这样的标准设备描述语言,那么就可以实现真正意义的万物互联。 
- 
-## cluster 
- 
-![cluster list](images/cluster_list.png) 
- 
-在zigbee cluster specification 里,定义如上包含关系,某个设备可以理解为多个cluster的集合(list),而zcl 约定了这里cluster,同时对于每一个固定cluser又是同时包含一个或者多个**<u>A</u>**ttribute、**<u>B</u>**ehavior、**<u>C</u>**ommand、**<u>D</u>**ependency,如下分开解释Cluster下的A、B、C、D。 
- 
-* Attribute 
- 
-  表示某个设备物理特征和状态的数据值,该数据值同其他设备通过如下Command操作关联; 
- 
-* Behavior 
- 
-  行为; 
- 
-* Command 
- 
-  操作或者影响熟悉的动作; 
- 
-* Dependency 
- 
-  依赖; 
- 
-> **提示**:详细参考,[ZigBee Cluster Library Specification r6](https://zigbee.org/download/zigbee-custer-library/?wpdmdl=6350&refresh=5d5e4e07cc4151566461447)->`2.5  General Command Frames `->`Table 2-3. ZCL Command Frames `。 
- 
-如上的Command 集合是针对固定Cluster下面的Attribute操作的,同时对于所有的Attribute,zcl还约定一系列的通用操作命令。 
- 
-|      | 命令描述                              | 
-| ---- | ------------------------------------- | 
-| 0x00 | Read Attributes                       | 
-| 0x01 | Read Attributes Response              | 
-| 0x02 | Write Attributes                      | 
-| 0x03 | Write Attributes Undivided            | 
-| 0x04 | Write Attributes Response             | 
-| 0x05 | Write Attributes No Response          | 
-| 0x06 | Configure Reporting                   | 
-| 0x07 | Configure Reporting Response          | 
-| 0x08 | Read Reporting Configuration          | 
-| 0x09 | Read Reporting Configuration Response | 
-| 0x0a | Report attributes                     | 
-| 0x0b | Default Response                      | 
-| 0x0c | Discover Attributes                   | 
-| 0x0d | Discover Attributes Response          | 
- 
-> **提示**:详细参考,[ZigBee Cluster Library Specification r6](https://zigbee.org/download/zigbee-custer-library/?wpdmdl=6350&refresh=5d5e4e07cc4151566461447)->`2.5  General Command Frames `->`Table 2-3. ZCL Command Frames `。 
- 
-## frame format 
- 
-接下来需要理解的是zcl的数据帧,以此可以通过抓包加深理解zcl的协议分层。 
- 
-![zcl 格式](images/zcl_frame_format.png) 
- 
-> **提示**:详细参考,[ZigBee Cluster Library Specification r6](https://zigbee.org/download/zigbee-custer-library/?wpdmdl=6350&refresh=5d5e4e07cc4151566461447)->`2.4 Command Frame Formats` 
- 
-每一个zcl数据帧都是用以来描述<u>操作/影响</u>  <u>指定cluster</u>下面的一个或者多个<u>attribute</u>的。 
- 
-接下来拆解如上提示。 
- 
-操作:通过如上描述的attribute 私有/通用 命令command决定,具体通过zcl 帧控制域的 Command identifier决定是通用还是私有命令; 
- 
-指定cluster:通过cluster id确定,cluster id在没有在zcl 数据值,而是在aps 层的帧头,cluster id 参考[ZigBee Cluster Library Specification r6](https://zigbee.org/download/zigbee-custer-library/?wpdmdl=6350&refresh=5d5e4e07cc4151566461447)-> `Chapter 3 General` 定义; 
- 
-attribute:zcl payload描述,通过attribute id确定,attribute id 由cluster id 指定的类别中定义;  
- 
- 
- 
-对应小米智能插座,理解如上抓包行为: 
- 
-* 上报 `generic` cluster 的`Model Identifier`和`Application version` 
- 
-  ![](images/zcl_report_attributes.png) 
- 
-* 开 
- 
-  ![开](images/zcl_command_on.png) 
- 
- 
- 
-## code implement 
- 
-有了上面的认识,还需要理解的是 cluster的master/slave 模式,简单来说需要基于cluster 实现指定产品功能集合物联网设备做 cluster master,需要交互这些产品功能的作为cluster slave。 
- 
-我们参考zstack,找到zstack中关于灯产品samplelight 的cluster list定义。 
- 
-```c 
-//zcl_samplelight_data line 204 
- 
-/********************************************************************* 
- * ATTRIBUTE DEFINITIONS - Uses REAL cluster IDs 
- */ 
- 
-// NOTE: The attributes listed in the AttrRec must be in ascending order  
-// per cluster to allow right function of the Foundation discovery commands 
-  
-CONST zclAttrRec_t zclSampleLight_Attrs[] = 
-{ 
-  // *** General Basic Cluster Attributes *** 
-  { 
-    ZCL_CLUSTER_ID_GEN_BASIC, 
-    { // Attribute record 
-      ATTRID_BASIC_ZCL_VERSION, 
-      ZCL_DATATYPE_UINT8, 
-      ACCESS_CONTROL_READ, 
-      (void *)&zclSampleLight_ZCLVersion 
-    } 
-  }, 
-  { 
-    ZCL_CLUSTER_ID_GEN_BASIC,             // Cluster IDs - defined in the foundation (ie. zcl.h) 
-    {  // Attribute record 
-      ATTRID_BASIC_HW_VERSION,            // Attribute ID - Found in Cluster Library header (ie. zcl_general.h) 
-      ZCL_DATATYPE_UINT8,                 // Data Type - found in zcl.h 
-      ACCESS_CONTROL_READ,                // Variable access control - found in zcl.h 
-      (void *)&zclSampleLight_HWRevision  // Pointer to attribute variable 
-    } 
-``` 
- 
- 
- 
-> **提示**:看起来,zstack在实现上面是直接按照attribute构造产品的,cluster 的就变成了特定attribute 的一个条目值。仔细思考其实和我们上面的包含关系理解并无偏差。 
- 
- 
- 
-</markdown> 
zigbee/zcl.txt · 最后更改: 2021/06/22 23:14 (外部编辑)