本文将讲述Ember zigbee如何对cluster library进行扩展,添加自定义cluster、command。
(参考文档:UG102-AppFrameworkDevGuide --16 Extending the ZigBee Cluster Library (ZCL))
Silicon Lab开发了一整套zigbee开发工具能够帮助开发者迅速开发产品,但是由于其底层代码并不开源,而且目前在中国技术支持力度不够并且价格相对比较昂贵,导致并没有被太多开发者所了解。本人也从事智能家居的开发使用的就是Silicon Lab的zigbee模块em3xx系列,一边学习,一边与大家分享,希望有了解的大神多多指教。
ember zigbee协议栈本身包含了丰富的cluster和相应的command,能满足大部分应用,而且是符合zigbee联盟制定的协议规范的,所以这部分是可以与其它符合zigbee标准协议的厂商直接对接使用的,但是针对不同公司,需要有自己的特色即产品差异化。那么就需要针对自己产品独特的cluster和command即custom cluster和custom command。ember提供很好的cluster扩展性,以下为步骤:
1、需要定义自己的xml文件,文件格式如下:(可在安装目录/tool/appbuilder找到sample-extensions.xml)
-<configurator>
<domain name="Ember"/>
<!-- 定义一个manufacturer name -->
-<cluster manufacturerCode="0x1002">
<!-- 定义mannufacturer code -->
<name>Sample Mfg Specific Cluster</name>
<!-- 定义cluster name -->
<domain>Ember</domain>
<description>This cluster provides an example of how the Application Framework can be extended to include manufacturer specific clusters. </description>
<!-- Cluster Id must be within the mfg spec range 0xfc00 - 0xffff -->
<code>0xFC00</code>
<!-- 定义cluster code 范围:0xfc00-0xffff -->
<define>SAMPLE_MFG_SPECIFIC_CLUSTER</define>
<client tick="false" init="false">true</client>
<server tick="false" init="false">true</server>
<!-- 定义是否需要tick,与初始化值 -->
<attribute optional="true" default="0x00" writable="true" max="0xFF" min="0x00" type="INT8U" define="ATTRIBUTE_ONE" code="0x0000" side="server">ember sample attribute</attribute>
<!-- 定义该cluster下的属性是否可选或者强制选择;定义初始化值;是否可写;最大值、最小值范围;属性数据类型;属性名为ember sample attribute;属性ID为0x0000 -->
-<command name="CommandOne" optional="true" code="0x00" source="client">
<!-- 定义属性下的相应的命令,命令名字为CommandOne,该命令非强制性可选择,命令·ID为0x00,该命令是由client