我是靠谱客的博主 辛勤钢铁侠,最近开发中收集的这篇文章主要介绍(转载)ZigBee zcl规范及其协议栈实现1zigbee zcl规范及其协议栈实现1,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
zigbee zcl规范及其协议栈实现1
http://www.cnblogs.com/-song/archive/2013/03/16/3331818.html
refer to ZigBee_Cluster_Library_Public_download_version
1.zcl 分为几个不同的功能领域,每个领域霸占一部分clusterid
比如通用领域有如下的clusterid
........
在协议栈的zcl.h中有对这些clusterid定义,对应上面的文档,但是不完整
- // General Clusters
- #define ZCL_CLUSTER_ID_GEN_BASIC 0x0000
- #define ZCL_CLUSTER_ID_GEN_POWER_CFG 0x0001
- #define ZCL_CLUSTER_ID_GEN_DEVICE_TEMP_CONFIG 0x0002
- #define ZCL_CLUSTER_ID_GEN_IDENTIFY 0x0003
- #define ZCL_CLUSTER_ID_GEN_GROUPS 0x0004
- #define ZCL_CLUSTER_ID_GEN_SCENES 0x0005
- #define ZCL_CLUSTER_ID_GEN_ON_OFF 0x0006
- #define ZCL_CLUSTER_ID_GEN_ON_OFF_SWITCH_CONFIG 0x0007
- #define ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL 0x0008
- #define ZCL_CLUSTER_ID_GEN_ALARMS 0x0009
- #define ZCL_CLUSTER_ID_GEN_TIME 0x000A
- #define ZCL_CLUSTER_ID_GEN_LOCATION 0x000B
- #define ZCL_CLUSTER_ID_GEN_KEY_ESTABLISHMENT 0x0800
- // Closures Clusters
- #define ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG 0x0100
- // HVAC Clusters
- #define ZCL_CLUSTER_ID_HVAC_PUMP_CONFIG_CONTROL 0x0200
- #define ZCL_CLUSTER_ID_HAVC_THERMOSTAT 0x0201
- #define ZCL_CLUSTER_ID_HAVC_FAN_CONTROL 0x0202
- #define ZCL_CLUSTER_ID_HAVC_DIHUMIDIFICATION_CONTROL 0x0203
- #define ZCL_CLUSTER_ID_HAVC_USER_INTERFACE_CONFIG 0x0204
- // Lighting Clusters
- #define ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL 0x0300
- #define ZCL_CLUSTER_ID_LIGHTING_BALLAST_CONFIG 0x0301
- // Measurement and Sensing Clusters
- #define ZCL_CLUSTER_ID_MS_ILLUMINANCE_MEASUREMENT 0x0400
- #define ZCL_CLUSTER_ID_MS_ILLUMINANCE_LEVEL_SENSING_CONFIG 0x0401
- #define ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT 0x0402
- #define ZCL_CLUSTER_ID_MS_PRESSURE_MEASUREMENT 0x0403
- #define ZCL_CLUSTER_ID_MS_FLOW_MEASUREMENT 0x0404
- #define ZCL_CLUSTER_ID_MS_RELATIVE_HUMIDITY 0x0405
- #define ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING 0x0406
- // Security and Safety (SS) Clusters
- #define ZCL_CLUSTER_ID_SS_IAS_ZONE 0x0500
- #define ZCL_CLUSTER_ID_SS_IAS_ACE 0x0501
- #define ZCL_CLUSTER_ID_SS_IAS_WD 0x0502
- // Protocol Interfaces
- #define ZCL_CLUSTER_ID_PI_GENERIC_TUNNEL 0x0600
- #define ZCL_CLUSTER_ID_PI_BACNET_PROTOCOL_TUNNEL 0x0601
- #define ZCL_CLUSTER_ID_PI_11073_PROTOCOL_TUNNEL 0x0614
- // Advanced Metering Initiative (SE) Clusters
- #define ZCL_CLUSTER_ID_SE_PRICING 0x0700
- #define ZCL_CLUSTER_ID_SE_LOAD_CONTROL 0x0701
- #define ZCL_CLUSTER_ID_SE_SIMPLE_METERING 0x0702
- #define ZCL_CLUSTER_ID_SE_MESSAGE 0x0703
- #define ZCL_CLUSTER_ID_SE_REGISTRATION 0x0704
- #define ZCL_CLUSTER_ID_SE_SE_TUNNELING 0x0705
- #define ZCL_CLUSTER_ID_SE_PRE_PAYMENT 0x0706
2.每个clusterid由一些属性集合和命令集合组成
比如
general领域的basic clusterid就有以下这么多的属性(分为了两部分,基本设备信息和设备配置信息)
general领域的basic clusterid还有1个命令
clusterid的属性和命令在协议栈的实现,比如general领域的basic clusterid,位于zcl_general.h
- /********************************/
- /*** Basic Cluster Attributes ***/
- /********************************/
- // Basic Device Information
- #define ATTRID_BASIC_ZCL_VERSION 0x0000
- #define ATTRID_BASIC_APPL_VERSION 0x0001
- #define ATTRID_BASIC_STACK_VERSION 0x0002
- #define ATTRID_BASIC_HW_VERSION 0x0003
- #define ATTRID_BASIC_MANUFACTURER_NAME 0x0004
- #define ATTRID_BASIC_MODEL_ID 0x0005
- #define ATTRID_BASIC_DATE_CODE 0x0006
- #define ATTRID_BASIC_POWER_SOURCE 0x0007
- // Basic Device Settings
- #define ATTRID_BASIC_LOCATION_DESC 0x0010
- #define ATTRID_BASIC_PHYSICAL_ENV 0x0011
- #define ATTRID_BASIC_DEVICE_ENABLED 0x0012
- #define ATTRID_BASIC_ALARM_MASK 0x0013
- ...
- /******************************/
- /*** Basic Cluster Commands ***/
- /******************************/
- #define COMMAND_BASIC_RESET_FACT_DEFAULT 0x00
- <span style="font-family:SimSun;">
- </span>
zcl_general.h-通用
zcl_closures.h-室内or 门禁?
zcl_hvac.h-空调
zcl_lighting.h-照明
zcl_ms.h-Measurements and Sensing
zcl_ss.h
zcl_pi.h
有了clusterid的属性的宏定义,还需对属性配置(赋值)
比如,zcl_samplelight.c中对clusterid ZCL_CLUSTER_ID_GEN_BASIC的各个属性进行的配置:
- CONST zclAttrRec_t zclSampleLight_Attrs[SAMPLELIGHT_MAX_ATTRIBUTES] =
- {
- // *** General Basic Cluster Attributes ***
- {
- 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
- }
- },
- {
- 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,
- { // Attribute record
- ATTRID_BASIC_MANUFACTURER_NAME,
- ZCL_DATATYPE_CHAR_STR,
- ACCESS_CONTROL_READ,
- (void *)zclSampleLight_ManufacturerName
- }
- },
- {
- ZCL_CLUSTER_ID_GEN_BASIC,
- { // Attribute record
- ATTRID_BASIC_MODEL_ID,
- ZCL_DATATYPE_CHAR_STR,
- ACCESS_CONTROL_READ,
- (void *)zclSampleLight_ModelId
- }
- },
- {
- ZCL_CLUSTER_ID_GEN_BASIC,
- { // Attribute record
- ATTRID_BASIC_DATE_CODE,
- ZCL_DATATYPE_CHAR_STR,
- ACCESS_CONTROL_READ,
- (void *)zclSampleLight_DateCode
- }
- },
- {
- ZCL_CLUSTER_ID_GEN_BASIC,
- { // Attribute record
- ATTRID_BASIC_POWER_SOURCE,
- ZCL_DATATYPE_UINT8,
- ACCESS_CONTROL_READ,
- (void *)&zclSampleLight_PowerSource
- }
- },
- {
- ZCL_CLUSTER_ID_GEN_BASIC,
- { // Attribute record
- ATTRID_BASIC_LOCATION_DESC,
- ZCL_DATATYPE_CHAR_STR,
- (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
- (void *)zclSampleLight_LocationDescription
- }
- },
- {
- ZCL_CLUSTER_ID_GEN_BASIC,
- { // Attribute record
- ATTRID_BASIC_PHYSICAL_ENV,
- ZCL_DATATYPE_UINT8,
- (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
- (void *)&zclSampleLight_PhysicalEnvironment
- }
- },
- {
- ZCL_CLUSTER_ID_GEN_BASIC,
- { // Attribute record
- ATTRID_BASIC_DEVICE_ENABLED,
- ZCL_DATATYPE_BOOLEAN,
- (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
- (void *)&zclSampleLight_DeviceEnable
- }
- },
- // *** Identify Cluster Attribute ***
- {
- ZCL_CLUSTER_ID_GEN_IDENTIFY,
- { // Attribute record
- ATTRID_IDENTIFY_TIME,
- ZCL_DATATYPE_UINT16,
- (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
- (void *)&zclSampleLight_IdentifyTime
- }
- },
- // *** On/Off Cluster Attributes ***
- {
- ZCL_CLUSTER_ID_GEN_ON_OFF,
- { // Attribute record
- ATTRID_ON_OFF,
- ZCL_DATATYPE_UINT8,
- ACCESS_CONTROL_READ,
- (void *)&zclSampleLight_OnOff
- }
- },
- }
3.除了clusterid的专有命令之外,还有部分通用命令,比如读取clusterid的某个属性,
在协议栈的实现,位于zcl.h
- /*** Foundation Command IDs ***/
- #define ZCL_CMD_READ 0x00
- #define ZCL_CMD_READ_RSP 0x01
- #define ZCL_CMD_WRITE 0x02
- #define ZCL_CMD_WRITE_UNDIVIDED 0x03
- #define ZCL_CMD_WRITE_RSP 0x04
- #define ZCL_CMD_WRITE_NO_RSP 0x05
- #define ZCL_CMD_CONFIG_REPORT 0x06
- #define ZCL_CMD_CONFIG_REPORT_RSP 0x07
- #define ZCL_CMD_READ_REPORT_CFG 0x08
- #define ZCL_CMD_READ_REPORT_CFG_RSP 0x09
- #define ZCL_CMD_REPORT 0x0a
- #define ZCL_CMD_DEFAULT_RSP 0x0b
- #define ZCL_CMD_DISCOVER 0x0c
- #define ZCL_CMD_DISCOVER_RSP 0x0d
- #define ZCL_CMD_MAX ZCL_CMD_DISCOVER_RSP
最后
以上就是辛勤钢铁侠为你收集整理的(转载)ZigBee zcl规范及其协议栈实现1zigbee zcl规范及其协议栈实现1的全部内容,希望文章能够帮你解决(转载)ZigBee zcl规范及其协议栈实现1zigbee zcl规范及其协议栈实现1所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复