本文是参考TI官网文档整理过来的,有些是翻译,翻译的不好多原谅。
下载地址:http://download.csdn.net/detail/mengzhuicanyang/7348101
也可以去TI的官网免费下载。
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1. ZCL概述
Zcl: zigbee cluster library.
The ZCL is divided into the Foundation layer anda number of functional domains, each domain addressing clusters relating tospecific functionality.
ZCL划分为基础层和一些功能领域,每个领域包含具体的功能。这些功能领域包括:
· General
· Closures
· Heating, ventilation and Air Conditioning(HVAC)
· Lighting
· Measurements and Sensing
· Security and Safety
· Smart Energy
· Protocol Interfaces
2. API
2.1 overview
ZCL在zigbee中相当于簇功能仓库的作用。开发者开发新的Profile就必须加入相应的ZCL簇功能函数到该Profile中。
也就是说ZCL相当于一个存储命令集合的仓库。节点与节点之间,利用ZCL的命令来进行通信。
The Foundation layer and General functional domaincluster functionality is covered in this document.
The Foundation layer provides APIs to the higherlayers to:
1) GenerateRequest and Response commands
2) RegisterApplication's attribute list
3) RegisterApplication’s attribute data validation callback function
4) RegisterCluster Library Handler callback functions
5) Registerthe Application task to receive the unprocessed Foundation command/responsemessages
The General and Protocol Interfaces functionaldomains provide APIs to the high layers to:
1) GenerateRequest and Response commands
2) RegisterApplication’s Command callback functions
2.2 client/server Model
The ZCL employs a Client/Server model. A cluster is arelated collection of commands and attributes, which together define aninterface to specific functionality. Typically, the entity that stores theattributes of a cluster is referred to as theServer, and an entity thataffects or manipulates those attributes is referred as theClient.However, if required, attributes may also be present on the Client of acluster.
ZCL采用的client/server模型,簇就是命令和属性的集合,而命令和属性定义了具体功能的接口。一般地,存储“属性”的实体被定义为server,而作用和操控这些属性的实体称作为client。但是,如果要求的话,属性也可以存储在client中。
比如,读写属性的命令,用来允许设备操作属性,由client设备端发送,被server端接收。任何对这些命令的响应(response)由server发送至client端接收。
2.3 stack diagram
下图为ZCL的部件以及与与之相关的接口层。
AF层接收到ZCL命令信息,然后放进ZCL任务的消息队列中。ZCL任务解析和加工这些Profile的命令,然后通过调用ClusterLibrary Handler处理簇定义的具体命令。簇处理这些命令,然后通过调用(如果要求的话)命令回调函数来通知application/profile.
2.4 application/profileregistration
应用/profile的注册:
zcl_registerAttrList(),
zcl_registerValidateAttrData()
zcl_registerForMsg()
zcl_registerPlugin():
the functional domains to registertheir Cluster Library Handler callback function
zclGeneral_RegisterCmdCallbacks():
register Application’s Commandcallback functions. The command callback input parameter to this API is of thefollowing type:
2.5 application Creation
该部分列出了创建一个新的ZCL应用需要的的步骤,至少需要建立下面四个模块:
(1) zcl_<appname>.hwhich should contain the definitions needed for the application
(2) zcl_<appname>_data.cwhich should contain the data definitions and declarations needed for theapplication
(3) zcl_<appname>.cwhich should contain all the functions and callback functions needed for theapplication
(4) OSAL_<AppName>.cwhere all the tasks needed for the application should be added to the task list
3. Fondation Layer
3.1 introduction
基础层(foundation layer)提供了通用的命令,这些命令用来控制属性以及其他的任务,这些任务并不是个人命令簇里面特定的任务。这些命令包括:
4. General Functional Domain
General Functional Domain包括下面的簇:
The Basic, Identity, Groups, Scenes, On/Off, LevelControl, Alarms and RSSI Indication clusters provide commands but the PowerConfiguration, Device Temperature Configuration, On/Off Switch Configurationand Time clusters don’t provide any commands.
5. Closures Functional Domain
The Closures functional domainprovides the following two clusters, defined by the Home Automation PublicApplication Profile:
(1)Door LockCluster
(2)WindowCovering Cluster
The Door Lock Cluster providesan interface into a generic way to secure a door.
The Window CoveringCluster provides an interface for controlling and adjusting automatic windowcoverings such as drapery motors, automatic shades, and blinds.