summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/ZCL/include
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/ZCL/include')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h186
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h11
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h137
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h1120
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h259
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h351
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h176
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h361
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h178
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h46
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h529
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h286
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h62
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h185
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h564
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h155
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h200
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h150
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h100
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h180
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h445
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h107
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h267
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h487
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h190
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h175
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h121
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h214
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h220
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h155
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h308
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h1004
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h228
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h265
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h363
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h171
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h215
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h297
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h95
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h114
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h281
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h648
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h63
51 files changed, 12417 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h
new file mode 100644
index 00000000..a37b19ff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h
@@ -0,0 +1,90 @@
+/************************************************************************//**
+ \file caps.h
+
+ \brief
+ The header file describes the CAPS interface
+
+ The file describes the interface and types of CAPS
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 27.11.08 A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _CAPS_H
+#define _CAPS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <aps.h>
+#include <appFramework.h>
+#include <macAddr.h>
+//#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define CAPS_SERIAL_CHANNEL UART_CHANNEL_1
+#ifdef _ZCL_SECURITY_
+ #define CAPS_DO_NOT_USE_APS_SECURITY false
+#else /* _ZCL_SECURITY_ */
+ #define CAPS_DO_NOT_USE_APS_SECURITY true
+#endif /* _ZCL_SECURITY_ */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+
+/*****************************************************************************
+ Special CAPS data types definition
+*****************************************************************************/
+typedef enum
+{
+ CAPS_SERIAL_NONE = 0x00,
+ CAPS_SERIAL_UART = 0x01
+} CAPS_Serial_t;
+
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+
+/*****************************************************************************
+ CAPS API Prototypes
+*****************************************************************************/
+
+/**************************************************************************//**
+ \brief CAPS Data Request interface.
+
+ APS_DataConf field in APS_DataReq must be an actual confirm handler pointer.
+
+ \param[in] req The APS_DataReq_t primitive pointer.
+ \param[in] serial The serial flag for redirection to the serial interface. CAPS_Serial_t must be used.
+ \param[in] noApsSecurity If true APS security is switched off.
+ \return None.
+*****************************************************************************/
+extern void CAPS_DataReq(APS_DataReq_t *req, uint8_t serial, bool noApsSecurity);
+
+#endif //#ifndef _CAPS_H
+
+
+//eof caps.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h
new file mode 100644
index 00000000..42bcd00c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h
@@ -0,0 +1,186 @@
+/************************************************************************//**
+ \file clusters.h
+
+ \brief
+ The header file describes the ZCLclusters
+
+ The file describes the ZCL clusters
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 01.12.08 I. Fedina & A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _CLUSTERS_H
+#define _CLUSTERS_H
+
+#include <zcl.h>
+#include <bcEndian.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define DEFINE_ATTRIBUTE(name, props, aid, atype) \
+ .name = {.id = aid, .type = atype, .properties = props}
+
+#define DEFINE_REPORTABLE_ATTRIBUTE(name, props, aid, atype, min, max) \
+ .name = {.id = aid, .type = atype, .properties = ZCL_REPORTABLE_ATTRIBUTE | (props), .minReportInterval = min, .maxReportInterval = max}
+
+#define COMMAND_OPTIONS(cldirection, clwaitingResponse, clackRequest) \
+ {.direction = ZCL_FRAME_CONTROL_DIRECTION_##cldirection, .waitingResponse = clwaitingResponse, \
+ .ackRequest = clackRequest}
+
+#define DEFINE_COMMAND(cname, cid, coptions, cind) \
+ .cname = {.id = cid, .options = coptions, cind}
+
+/***************************************************************************//**
+\brief The type describes possible parts of a ZCL cluster.
+
+A cluster is a related collection of commands and attributes, which together define
+an interface to specific functionality. Typically, the entity that stores the attributes
+of a cluster is referred to as the server of that cluster and an entity that affects or
+manipulates those attributes is referred to as the client of that cluster. However, if
+required, attributes may also be present on the client of a cluster.
+Commands that allow devices to manipulate attributes, e.g. the read attribute or
+write attribute commands, are (typically) sent from a client device and received
+by the server device. Any response to those commands, e.g. the read attribute response
+or the write attribute response commands, are sent from the server device and
+received by the client device.
+*******************************************************************************/
+/*ZCL command ack request field*/
+#define ZCL_COMMAND_NO_ACK 0
+#define ZCL_COMMAND_ACK 1
+
+#define ZCL_SERVER_CLUSTER_TYPE 0 //!< server part of a cluster
+#define ZCL_CLIENT_CLUSTER_TYPE 1 //!< client part of a cluster
+
+/*ZCL Header Direction sub-field value*/
+#define ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER 0x00
+#define ZCL_FRAME_CONTROL_DIRECTION_SERVER_TO_CLIENT 0x01
+
+/*ZCL cluster side possible values*/
+#define ZCL_CLUSTER_SIDE_SERVER ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER
+#define ZCL_CLUSTER_SIDE_CLIENT ZCL_FRAME_CONTROL_DIRECTION_SERVER_TO_CLIENT
+
+/*! A value to disable default response for a cluster's command*/
+#define ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE 0x01
+/*! A value to enable default response for a cluster's command*/
+#define ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE 0x00
+
+/* There is other relevant response specified for the command or not */
+#define ZCL_THERE_IS_RELEVANT_RESPONSE 0x01
+#define ZCL_THERE_IS_NO_RELEVANT_RESPONSE 0x00
+
+#define ZCL_NETWORK_KEY_CLUSTER_SECURITY 0
+#define ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY 1
+
+
+/* Bits for declaring properties bitmask of attribute */
+#define ZCL_READWRITE_ATTRIBUTE 0U
+#define ZCL_REPORTABLE_ATTRIBUTE 1U
+#define ZCL_READONLY_ATTRIBUTE 2U
+
+#ifdef _ZCL_SECURITY_
+ #define ZCL_DEFAULT_CLUSTER_SECURITY ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY
+#else
+ #define ZCL_DEFAULT_CLUSTER_SECURITY ZCL_NETWORK_KEY_CLUSTER_SECURITY
+#endif
+
+/*************************************************************************//**
+ \brief Clusters Id definition
+*****************************************************************************/
+enum
+{
+ /* General clusters defined by ZCL Specification */
+ BASIC_CLUSTER_ID = CCPU_TO_LE16(0x0000), //!<Basic cluster Id
+ POWER_CONFIGURATION_CLUSTER_ID = CCPU_TO_LE16(0x0001), //!<Power configuration cluster Id
+ IDENTIFY_CLUSTER_ID = CCPU_TO_LE16(0x0003), //!<Identify cluster Id
+ GROUPS_CLUSTER_ID = CCPU_TO_LE16(0x0004), //!<Groups cluster Id
+ SCENES_CLUSTER_ID = CCPU_TO_LE16(0x0005), //!<Scenes cluster Id
+ ONOFF_CLUSTER_ID = CCPU_TO_LE16(0x0006), //!<OnOff cluster id
+ ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID = CCPU_TO_LE16(0x0007), //!<OnOff Switch Configuration cluster id
+ LEVEL_CONTROL_CLUSTER_ID = CCPU_TO_LE16(0x0008), //!<Level Control cluster id
+ TEMPERATURE_MEASUREMENT_CLUSTER_ID = CCPU_TO_LE16(0x0402), //!<Temperature measurement cluster id
+ HUMIDITY_MEASUREMENT_CLUSTER_ID = CCPU_TO_LE16(0x0405), //!<Humidity measurement cluster id
+ OCCUPANCY_SENSING_CLUSTER_ID = CCPU_TO_LE16(0x0406), //!<Occupancy Sensing cluster id
+ TIME_CLUSTER_ID = CCPU_TO_LE16(0x000a), //!<Time cluster Id
+ OTAU_CLUSTER_ID = CCPU_TO_LE16(0x0019), //!<OTAU cluster Id
+ GENERIC_TUNNEL_CLUSTER_ID = CCPU_TO_LE16(0x0600), //!<Generic tunnel cluster Id
+ BACNET_PROTOCOL_TUNNEL_CLUSTER_ID = CCPU_TO_LE16(0x0601), //!<BACnet protocol tunnel cluster Id
+ THERMOSTAT_CLUSTER_ID = CCPU_TO_LE16(0x0201), //!<Thermostat cluster Id
+ /* Smart Energy Profile specific clusters */
+ PRICE_CLUSTER_ID = CCPU_TO_LE16(0x0700), //!<Price cluster Id
+ DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID = CCPU_TO_LE16(0x0701), //!<Demand Response and Load Control cluster Id
+ SIMPLE_METERING_CLUSTER_ID = CCPU_TO_LE16(0x0702), //!<Simple Metering cluster Id
+ MESSAGE_CLUSTER_ID = CCPU_TO_LE16(0x0703), //!<Message Cluster Id
+ ZCL_KEY_ESTABLISHMENT_CLUSTER_ID = CCPU_TO_LE16(0x0800), //!<ZCL Key Establishment Cluster Id
+ /** Lighting */
+ COLOR_CONTROL_CLUSTER_ID = CCPU_TO_LE16(0x0300), //!<Color Control cluster id
+ /* Light Link Profile clusters */
+ ZLL_COMMISSIONING_CLUSTER_ID = CCPU_TO_LE16(0x1000) //!<ZLL Commissioning Cluster Id
+};
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/*************************************************************************//**
+ \brief ZCL Command options
+
+ For internal use
+*****************************************************************************/
+typedef struct
+{
+ uint8_t direction :1; //!<Direction sub-field (ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER or ZCL_FRAME_CONTROL_DIRECTION_SERVER_TO_CLIENT)
+ uint8_t defaultResponse :1; //!<Should be 0 (#ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE) if the ZCL Default Response required and 0 (ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE) if no.
+ uint8_t waitingResponse :1; //!<Should be 1 (#ZCL_THERE_IS_RELEVANT_RESPONSE) if there is other relevant response specified for the command else 0 (#ZCL_THERE_IS_NO_RELEVANT_RESPONSE)
+ uint8_t ackRequest :1; //!<Is APS ACK requested
+ uint8_t reserved :4; //!<Reserved for future use
+} ZclCommandOptions_t;
+
+/*************************************************************************//**
+ \brief ZCL Cluster command descriptor as command Id and options
+
+ For internal use
+*****************************************************************************/
+typedef struct
+{
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*callback)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+} ZclCommand_t;
+
+BEGIN_PACK
+/*************************************************************************//**
+ \brief ZCL Cluster attribute descriptor
+
+ For internal use
+*****************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!<Attribute Id
+ uint8_t type; //!<Attribute data type
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[1]; //!<Immediate attribute value
+} ZclAttribute_t;
+
+/*************************************************************************//**
+ \brief Extra fields of reportable attribute descriptor
+
+ For internal use
+*****************************************************************************/
+typedef struct PACK
+{
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+} ZclReportableAttributeTail_t;
+END_PACK
+
+#endif // _CLUSTERS_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h
new file mode 100644
index 00000000..97d9f459
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h
@@ -0,0 +1,11 @@
+#ifndef _ECCAUX_H
+#define _ECCAUX_H
+
+#define YIELD_LEVEL 0
+int yield(void);
+
+extern unsigned char msgDigest[];
+
+#endif //#ifndef _ECCAUX_H
+
+//eof eccAux.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h
new file mode 100644
index 00000000..3d7b4120
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h
@@ -0,0 +1,90 @@
+/***************************************************************************//**
+ \file genericEcc.h
+
+ \brief
+ Generic ECC API
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 08.07.10 D. Loskutnikov - Created.
+*******************************************************************************/
+#ifndef _GENERICECC_H
+#define _GENERICECC_H
+
+/*******************************************************************************
+ Defines section
+*******************************************************************************/
+#define SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE (22)
+#define SECT163K1_UNCOMPRESSED_PUBLIC_KEY_SIZE (43)
+#define SECT163K1_PRIVATE_KEY_SIZE (21)
+#define SECT163K1_CERTIFICATE_SIZE (48)
+#define SECT163K1_SHARED_SECRET_SIZE (21)
+#define SECT163K1_POINT_ORDER_SIZE (21)
+#define AES_MMO_HASH_SIZE (16)
+
+#define MCE_SUCCESS 0x00
+#define MCE_ERR_FAIL_VERIFY 0x01
+#define MCE_ERR_NULL_PRIVATE_KEY 0x02
+#define MCE_ERR_NULL_PUBLIC_KEY 0x03
+#define MCE_ERR_NULL_INPUT_BUF 0x04
+#define MCE_ERR_NULL_OUTPUT_BUF 0x05
+#define MCE_ERR_NULL_FUNC_PTR 0x06
+#define MCE_ERR_NULL_EPHEM_PRI_KEY 0x07
+#define MCE_ERR_NULL_EPHEM_PUB_KEY 0x08
+#define MCE_ERR_BAD_INPUT 0x09
+
+/*******************************************************************************
+ Prototypes section
+*******************************************************************************/
+typedef int GetRandomDataFunc(unsigned char *buffer, unsigned long sz);
+typedef int HashFunc(unsigned char *digest, unsigned long sz, unsigned char *data);
+typedef int YieldFunc(void);
+int aesMmoHash(unsigned char *digest, unsigned long sz, unsigned char *data);
+
+int ZSE_ECDSASign(unsigned char *privateKey,
+ unsigned char *msgDigest,
+ GetRandomDataFunc *GetRandomData,
+ unsigned char *r,
+ unsigned char *s,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECDSAVerify(unsigned char *publicKey,
+ unsigned char *msgDigest,
+ unsigned char *r,
+ unsigned char *s,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECCGenerateKey(unsigned char *privateKey,
+ unsigned char *publicKey,
+ GetRandomDataFunc *GetRandomData,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECCKeyBitGenerate(unsigned char *privateKey,
+ unsigned char *ephemeralPrivateKey,
+ unsigned char *ephemeralPublicKey,
+ unsigned char *remoteCertificate,
+ unsigned char *remoteEphemeralPublicKey,
+ unsigned char *caPublicKey,
+ unsigned char *keyBits,
+ HashFunc *Hash,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECQVReconstructPublicKey(unsigned char* certificate,
+ unsigned char* caPublicKey,
+ unsigned char* publicKey,
+ HashFunc *Hash,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+#endif //_GENERICECC_H
+// eof genericEcc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h
new file mode 100644
index 00000000..4468efa4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h
@@ -0,0 +1,137 @@
+/************************************************************************//**
+ \file zclDbg.h
+
+ \brief
+ The header file describes ZCL Debug Module
+
+ The file describes the ZCL Debug Module
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 02.12.08 A. Poptashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLDBG_H
+#define _ZCLDBG_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined _SYS_ASSERT_ON_
+
+#define ZCL_SET_STATE(state, newState) (state) = (newState)
+#define ZCL_CHECK_STATE(state, checkState, nameOfAssert) \
+ assert((checkState) == (state), nameOfAssert)
+
+#else /* _SYS_ASSERT_ON_ */
+
+#define ZCL_SET_STATE(state, newState)
+#define ZCL_CHECK_STATE(state, waitState, nameOfAssert)
+#if defined assert
+#undef assert
+#endif /* assert */
+#define assert(condition, dbgCode) (void)0
+
+#endif /* _SYS_ASSERT_ON_ */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+typedef enum
+{
+ /***********************************
+ ZCL section. Range 0x8000 - 0x8fff
+ ************************************/
+
+ //ZCL Task Manager Id (0x8000 - 0x80ff)
+ ZCLTASKMANAGER_TASKHANDLER_0 = 0x8000,
+ //ZCL CAPS Id (0x8100 - 0x81ff)
+
+ //ZCL ZCL Id (0x8200 - 0x82ff)
+ ZCLGETCLUSTER_0 = 0x8200,
+ PARSEDATAIND_0 = 0x8201,
+ ZCLREPORTIND_0 = 0x8202,
+ DBG_ZCL_GET_TRUST_CENTER_ADDRESS = 0x8203,
+ ZCL_UNDEFINED_CLUSTER_IN_REQUEST = 0x8204,
+ ZCL_UNEXPECTED_ASDU_LENGTH = 0x8205,
+ UNKNOWN_DAT_TYPE_DESCR = 0x8206,
+ //ZCL Memory Manager (0x8300 - 0x83ff)
+ ZCL_DATAIND_0 = 0x8300,
+ ZCL_THERE_ARE_NO_BUFFERS = 0x8301,
+ //OTAU (0x8400 - 0x84ff)
+ ZCL_OTAU_NULL_POINTER_TO_INIT_STRUCTURE = 0x8400,
+ ZCL_OTAU_DOUBLE_START = 0x8401,
+ ZCL_OTAU_UNEXPECTED_SERVER_DISCOVERY = 0x8402,
+ ZCL_UNKNOWN_CUSTOM_MESSAGE = 0x8403,
+ ZCL_OTAU_UNKNOWN_SERVER_TRANSACTUION_ID = 0x8404,
+ ZCL_UNKNOWN_ISD_MESSAGE = 0x8405,
+ // KE
+ KE_WRONG_STATE_0 = 0x8500,
+ KE_WRONG_STATE_1 = 0x8501,
+ KE_WRONG_STATE_2 = 0x8502,
+ KE_WRONG_STATE_3 = 0x8503,
+ KE_WRONG_STATE_4 = 0x8504,
+ KE_WRONG_STATE_5 = 0x8505,
+
+ ZCL_MEMORY_CORRUPTION_0 = 0x8600,
+ ZCL_MEMORY_CORRUPTION_1 = 0x8601,
+ ZCL_MEMORY_CORRUPTION_2 = 0x8602,
+ ZCL_MEMORY_CORRUPTION_3 = 0x8603
+} ZclDbgCodeId_t;
+
+typedef enum
+{
+ OTAU_STOPPED_STATE,
+ OTAU_STARTED_STATE,
+ OTAU_OFD_INITIALIZATION_STATE,
+ OTAU_BROADCAST_MATCH_DESC_REQ,
+ OTAU_UNICAST_MATCH_DESC_REQ,
+ OTAU_SHORT_ADDR_REQ,
+ OTAU_EXT_ADDR_REQ,
+ OTAU_GET_TRUST_CENTRE_ADDR,
+ OTAU_GET_LINK_KEY,
+ OTAU_QUERY_NEXT_IMAGE_TRANSAC,
+ OTAU_WAITING_FOR_SERVER_DISCOVERY,
+ OTAU_ERASE_IMAGE,
+ OTAU_IMAGE_BLOCK_TRANSAC,
+ OTAU_IMAGE_PAGE_TRANSAC,
+ OTAU_WRITE_DATA_TO_FLASH,
+ OTAU_FLUSH_DATA_TO_FLASH,
+ OTAU_UPGRADE_END_TRANSAC,
+ OTAU_WAITING_FOR_UPGRADE_TIMEOUT,
+ OTAU_WAITING_FOR_UPGRADE_UNLIMITED,
+ OTAU_SWITCH_IMAGE
+} ZclOtauStateMachine_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+
+
+#endif //#ifndef _ZCLDBG_H
+
+//eof zclDbg.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h
new file mode 100644
index 00000000..0731a417
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h
@@ -0,0 +1,1120 @@
+/************************************************************************//**
+ \file zcl.h
+
+ \brief
+ The header file describes the public ZCL interface
+
+ The file describes the public interface and types of ZCL
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 01.12.08 I. Fedina & A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _ZCL_H
+#define _ZCL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <aps.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define PROFILE_ID_SMART_ENERGY CCPU_TO_LE16(0x0109)
+#define PROFILE_ID_CBA CCPU_TO_LE16(0x0105)
+#define PROFILE_ID_HOME_AUTOMATION CCPU_TO_LE16(0x0104)
+#define PROFILE_ID_SMART_LIGHTING CCPU_TO_LE16(0xc05e)
+
+#define ZCL_MAX_ASDU_SIZE 75 //it is temporary hack to prevent fragmentation for ZCL packets. It should be fixed with correct calculation of payload size.
+
+// Macros defines the maximum size allocated for a value of type OCTET_STRING
+#define OCTET_STRING_MAX_SIZE 255
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef uint8_t ZCL_ClusterType_t;
+typedef uint16_t ZCL_AttributeId_t; //<! Describes type of attributes IDs
+typedef uint8_t ZCL_CommandId_t;
+typedef uint32_t ZCL_UTCTime_t;
+typedef uint32_t ZCL_Date_t;
+typedef uint16_t ZCL_ReportTime_t; // time for reporting in seconds
+
+/***************************************************************************//**
+\brief Enumerated status values used in the ZCL
+*******************************************************************************/
+typedef enum
+{
+ //! Operation was successful.
+ ZCL_SUCCESS_STATUS = 0x00,
+ //!Operation was not successful
+ ZCL_FAILURE_STATUS = 0x01,
+
+ //0x02 - 0x7d - Reserved
+ ZCL_INVALID_ATTRIBUTE_VALUE_STATUS = 0x02,
+ ZCL_TC_PERMISSION_TABLE_ERROR_STATUS = 0x03,
+ ZCL_APS_LINK_KEY_ERROR_STATUS = 0x04,
+
+ //!The sender of the command does not have authorization to carry out this command.
+ ZCL_NOT_AUTHORIZED_STATUS = 0x7e,
+ //!A reserved field/subfield/bit contains a nonzero value
+ ZCL_RESERVED_FIELD_NOT_ZERO_STATUS = 0x7f,
+ /*!The command appears to contain the wrong fields, as detected either by the
+ presence of one or more invalid field entries or by there being missing fields.
+ Command not carried out. Implementer has discretion as to whether to return
+ this error or ZCL_INVALID_FIELD_STATUS.*/
+ ZCL_MALFORMED_COMMAND_STATUS = 0x80,
+ /*!The specified cluster command is not supported on the device.Command not
+ carried out.*/
+ ZCL_UNSUP_CLUSTER_COMMAND_STATUS = 0x81,
+ /*!The specified general ZCL command is not supported on the device.*/
+ ZCL_UNSUP_GENERAL_COMMAND_STATUS = 0x82,
+ /*!A manufacturer specific unicast, cluster specific command was received
+ with an unknown manufacturer code, or the manufacturer code was recognized but
+ the command is not supported*/
+ ZCL_UNSUP_MANUF_CLUSTER_COMMAND = 0x83,
+ /*!A manufacturer specific unicast, ZCL specific command was received with an
+ unknown manufacturer code, or manufacturer code was recognized but the command
+ is not supported*/
+ ZCL_UNSUP_MANUF_GENERAL_COMMAND_STATUS = 0x84,
+ /*!At least one field of the command contains an incorrect value, according
+ to the specification the device is implemented to.*/
+ ZCL_INVALID_FIELD_STATUS = 0x85,
+ /*!The specified attribute does not exist on the device.*/
+ ZCL_UNSUPPORTED_ATTRIBUTE_STATUS = 0x86,
+ /*!Out of range error, or set to a reserved value. Attribute keeps its old
+ value.*/
+ ZCL_INVALID_VALUE_STATUS = 0x87,
+ /*!Attempt to write a read only attribute.*/
+ ZCL_READ_ONLY_STATUS = 0x88,
+ /*!An operation (e.g. an attempt to create an entry in a table) failed due
+ to an insufficient amount of free space available.*/
+ ZCL_INSUFFICIENT_SPACE_STATUS = 0x89,
+ /*!An attempt to create an entry in a table failed due to a duplicate entry
+ already being present in the table.*/
+ ZCL_DUPLICATE_EXISTS_STATUS = 0x8a,
+ /*!The requested information (e.g. table entry) could not be found.*/
+ ZCL_NOT_FOUND_STATUS = 0x8b,
+ /*!Periodic reports cannot be issued for this attribute.*/
+ ZCL_UNREPORTABLE_ATTRIBUTE_STATUS = 0x8c,
+ /*!The data type given for an attribute is incorrect. Command not carried out.*/
+ ZCL_INVALID_DATA_TYPE_STATUS = 0x8d,
+ /*!The selector for an attribute is incorrect.*/
+ ZCL_INVALID_SELECTOR_STATUS = 0x8e,
+ /*!A request has been made to read an attribute that the requester is not
+ authorized to read. No action taken.*/
+ ZCL_WRITE_ONLY_STATUS = 0x8f,
+ /*!Setting the requested values would put the device in an inconsistent state
+ on startup. No action taken.*/
+ ZCL_INCONSISTENT_STARTUP_STATE_STATUS = 0x90,
+ /*!An attempt has been made to write an attribute that is present but is
+ defined using an out-of-band method and not over the air.*/
+ ZCL_DEFINED_OUT_OF_BAND_STATUS = 0x91,
+ /*!Failed case when a otau client or a otau server decides to abort the upgrade process. */
+ ZCL_ABORT_STATUS = 0x95,
+ /*!Invalid OTA upgrade image (ex. failed signature validation or signer information check or CRC check) */
+ ZCL_INVALID_IMAGE_STATUS = 0x96,
+ /*!Server does not have data block available yet */
+ ZCL_WAIT_FOR_DATA_STATUS = 0x97,
+ /*!No OTA upgrade image available for a particular client */
+ ZCL_NO_IMAGE_AVAILABLE_STATUS = 0x98,
+ /*!The client still requires more OTA upgrade image files in order to successfully upgrade*/
+ ZCL_REQUIRE_MORE_IMAGE_STATUS = 0x99,
+
+ //0x97 - 0xbf - Reserved
+
+ /*!An operation was unsuccessful due to a hardware failure.*/
+ ZCL_HARDWARE_FAILURE_STATUS = 0xc0,
+ /*!An operation was unsuccessful due to a software failure.*/
+ ZCL_SOFTWARE_FAILURE_STATUS = 0xc1,
+ /*!An error occurred during calibration.*/
+ ZCL_CALIBRATION_ERROR_STATUS = 0xc2,
+
+ //0xc3 - 0xff - Reserved
+
+ ZCL_SENDING_ERROR_STATUS = 0xc3,
+ //ZCL_ATTRIBUTE_NOT_FOUND_STATUS,
+ ZCL_BAD_FRAME_STATUS = 0xc4,
+ //ZCL_WRONG_ATTRIBUTE_TYPE_STATUS,
+ ZCL_WRONG_RESPONSE_LENGTH_STATUS = 0xc5,
+ ZCL_END_PAYLOAD_REACHED_STATUS = 0xfd,
+ ZCL_MAX_PAYLOAD_REACHED_STATUS = 0xfe,
+ ZCL_INVALID_PARAMETER_STATUS = 0xff,
+
+} ZCL_Status_t;
+
+/********************************************************************************//**
+\brief ZigBee data types identifiers.
+
+ZigBee devices, such as thermostats, lamps, etc., are defined in terms of the
+attributes they contain, which can be written, read or reported using the
+ZCL commands. The following list defines the data types and formats that
+can be used for these attributes. Note that individual clusters, which may use
+different or new types, show valid values, ranges, and units for the attributes they
+represent.
+Each data type is allocated an 8-bit data type ID. The most significant 5 bits of this
+ID is used to divide the types into 32 type classes, and the least significant 3 bits
+specify a specific data type within this class.
+***********************************************************************************/
+typedef enum
+{
+ //Null
+ ZCL_NO_DATA_TYPE_ID = 0x00,
+
+ //General data
+ ZCL_8BIT_DATA_TYPE_ID = 0x08,
+ ZCL_16BIT_DATA_TYPE_ID = 0x09,
+ ZCL_24BIT_DATA_TYPE_ID = 0x0a,
+ ZCL_32BIT_DATA_TYPE_ID = 0x0b,
+ ZCL_40BIT_DATA_TYPE_ID = 0x0c,
+ ZCL_48BIT_DATA_TYPE_ID = 0x0d,
+ ZCL_56BIT_DATA_TYPE_ID = 0x0e,
+ ZCL_64BIT_DATA_TYPE_ID = 0x0f,
+
+ //Logical
+ ZCL_BOOLEAN_DATA_TYPE_ID = 0x10,
+
+ //Bitmap
+ ZCL_8BIT_BITMAP_DATA_TYPE_ID = 0x18,
+ ZCL_16BIT_BITMAP_DATA_TYPE_ID = 0x19,
+ ZCL_24BIT_BITMAP_DATA_TYPE_ID = 0x1a,
+ ZCL_32BIT_BITMAP_DATA_TYPE_ID = 0x1b,
+ ZCL_40BIT_BITMAP_DATA_TYPE_ID = 0x1c,
+ ZCL_48BIT_BITMAP_DATA_TYPE_ID = 0x1d,
+ ZCL_56BIT_BITMAP_DATA_TYPE_ID = 0x1e,
+ ZCL_64BIT_BITMAP_DATA_TYPE_ID = 0x1f,
+
+ //Unsigned integer
+ ZCL_U8BIT_DATA_TYPE_ID = 0x20,
+ ZCL_U16BIT_DATA_TYPE_ID = 0x21,
+ ZCL_U24BIT_DATA_TYPE_ID = 0x22,
+ ZCL_U32BIT_DATA_TYPE_ID = 0x23,
+ ZCL_U40BIT_DATA_TYPE_ID = 0x24,
+ ZCL_U48BIT_DATA_TYPE_ID = 0x25,
+ ZCL_U56BIT_DATA_TYPE_ID = 0x26,
+ ZCL_U64BIT_DATA_TYPE_ID = 0x27,
+
+ //Signed integer
+ ZCL_S8BIT_DATA_TYPE_ID = 0x28,
+ ZCL_S16BIT_DATA_TYPE_ID = 0x29,
+ ZCL_S24BIT_DATA_TYPE_ID = 0x2a,
+ ZCL_S32BIT_DATA_TYPE_ID = 0x2b,
+ ZCL_S40BIT_DATA_TYPE_ID = 0x2c,
+ ZCL_S48BIT_DATA_TYPE_ID = 0x2d,
+ ZCL_S56BIT_DATA_TYPE_ID = 0x2e,
+ ZCL_S64BIT_DATA_TYPE_ID = 0x2f,
+
+ //Enumeration
+ ZCL_8BIT_ENUM_DATA_TYPE_ID = 0x30,
+ ZCL_16BIT_ENUM_DATA_TYPE_ID = 0x31,
+
+ //Floating point
+ ZCL_FSEMI_PRECISION_DATA_TYPE_ID = 0x38,
+ ZCL_FSINGLE_PRECISION_DATA_TYPE_ID = 0x39,
+ ZCL_FDOUBLE_PRECISION_DATA_TYPE_ID = 0x3a,
+
+ //String
+ ZCL_OCTET_STRING_DATA_TYPE_ID = 0x41,
+ ZCL_CHARACTER_STRING_DATA_TYPE_ID = 0x42,
+ ZCL_LONG_OCTET_STRING_DATA_TYPE_ID = 0x43,
+ ZCL_LONG_CHARACTER_STRING_DATA_TYPE_ID = 0x44,
+
+ //Ordered sequence
+ ZCL_ARRAY_DATA_TYPE_ID = 0x48,
+ ZCL_STRUCTURE_DATA_TYPE_ID = 0x4c,
+
+ //Collection
+ ZCL_SET_DATA_TYPE_ID = 0x50,
+ ZCL_BAG_DATA_TYPE_ID = 0x51,
+
+ //Time
+ ZCL_TIME_OF_DAY_DATA_TYPE_ID = 0xe0,
+ ZCL_DATE_DATA_TYPE_ID = 0xe1,
+ ZCL_UTC_TIME_DATA_TYPE_ID = 0xe2,
+
+ //Identifier
+ ZCL_CLUSTER_ID_DATA_TYPE_ID = 0xe8,
+ ZCL_ATTRIBUTE_ID_DATA_TYPE_ID = 0xe9,
+ ZCL_BACNET_OID_DATA_TYPE_ID = 0xea,
+
+ //Misscellaneous
+ ZCL_IEEE_ADDRESS_DATA_TYPE_ID = 0xf0,
+ ZCL_128BIT_SECURITY_KEY_DATA_TYPE_ID = 0xf1,
+} ZCL_AttributeType_t;
+
+/***************************************************************************//**
+\brief The list of general ZCL commands.
+*******************************************************************************/
+typedef enum
+{
+ /*! Reading particular attributes' values from a remote device*/
+ ZCL_READ_ATTRIBUTES_COMMAND_ID = 0x00,
+ ZCL_READ_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x01,
+
+/*Write attributes*/
+ /*! Modifying values of particular attributes on a remote device*/
+ ZCL_WRITE_ATTRIBUTES_COMMAND_ID = 0x02,
+ ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID = 0x03,
+ ZCL_WRITE_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x04,
+ ZCL_WRITE_ATTRIBUTES_NO_RESPONSE_COMMAND_ID = 0x05,
+
+/*Configure reporting*/
+ ZCL_CONFIGURE_REPORTING_COMMAND_ID = 0x06,
+ ZCL_CONFIGURE_REPORTING_RESPONSE_COMMAND_ID = 0x07,
+
+/*Read reporting*/
+ ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID = 0x08,
+ ZCL_READ_REPORTING_CONFIGURATION_RESPONSE_COMMAND_ID = 0x09,
+
+/*Report attributes*/
+ /*! Reporting particular attributes to a remote device; that is,
+ sending current attributes' values*/
+ ZCL_REPORT_ATTRIBUTES_COMMAND_ID = 0x0a,
+
+/*Default response*/
+ ZCL_DEFAULT_RESPONSE_COMMAND_ID = 0x0b,
+
+/*Discover attributes*/
+ /*! Obtaining information (IDs and types) of attributes supported
+ by a particular cluster on a remote device*/
+ ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID = 0x0c,
+ ZCL_DISCOVER_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x0d,
+
+/*Read attributes structured*/
+ ZCL_READ_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0e,
+
+/*Write attributes structured*/
+ ZCL_WRITE_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0f,
+ ZCL_WRITE_ATTRIBUTES_STRUCTURED_RESPONSE_COMMAND_ID = 0x10
+} ZCL_GeneralCommandId_t;
+
+/***************************************************************************//**
+\brief Type describing possible ZSE Device IDs.
+*******************************************************************************/
+typedef enum
+{
+ /*! The Range Extender is a simple device that acts as a router for other devices. The
+ Range Extender device shall not be a ZigBee end device. A product that
+ implements the Range Extender device shall not implement any other devices
+ defined in this profile. This device shall only be used if the product is not intended
+ to have any other application, or if a private application is implemented that has
+ not been addressed by this profile.*/
+ ZSE_RANGE_EXTENDER_DEVICE_ID = 0x0008,
+ /*! The Energy Service Portal connects the energy supply company communication
+ network to the metering and energy management devices within the home. It
+ routes messages to and from the relevant end points. It may be installed within a
+ meter, thermostat, or In-Premise Display, or may be a standalone device, and it
+ will contain another non-ZigBee communication module (e.g. power-line carrier,
+ RF, GPRS, broadband Internet connection).*/
+ ZSE_ENERGY_SERVICE_PORTAL_DEVICE_ID = 0x0500,
+ /*!The Metering end device is a meter (electricity, gas, water, heat, etc.) that is fitted
+ with a ZigBee device. Depending on what is being metered, the device may be
+ capable of immediate (requested) reads or it will autonomously send readings
+ periodically. A Metering end device may also be capable of communicating
+ certain status indicators (e.g. battery low, tamper detected).*/
+ ZSE_METERING_DEVICE_DEVICE_ID = 0x0501,
+ /*! The In-Premise Display device will relay energy consumption data to the user by
+ way of a graphical or text display. The display may or may not be an interactive
+ device. At a minimum at least one of the following should be displayed: current
+ energy usage, a history over selectable periods, pricing information, or text
+ messages. As an interactive device, it can be used for returning simple messages
+ for interpretation by the recipient.*/
+ ZSE_IN_PREMISE_DISPLAY_DEVICE_ID = 0x0502,
+ /*! The PCT device shall provide the capability to control the premise heating and
+ cooling systems.*/
+ ZSE_PROGRAMMABLE_COMMUNICATING_THERMOSTAT_DEVICE_ID = 0x0503,
+ /*! The Load Control device is capable of receiving Demand Response and Load
+ Control events to manage consumption on a range of devices. Example devices
+ are water heaters, exterior lighting, and pool pumps.*/
+ ZSE_LOAD_CONTROL_DEVICE_DEVICE_ID = 0x0504,
+ /*! Smart Appliance devices on the ZigBee network can participate in energy
+ management activities. Examples of these are when Utilities initiate a demand
+ response or pricing event, or the appliance actively informs customers via inhome
+ displays of when or how energy is being used. In the latter case, scenarios
+ include: Washer switching to cold water during periods of higher energy costs;
+ Washer/Dryer/Oven/Hot Water Heater reporting cycle status;
+ Over temperature conditions in Freezers and Refrigerators.*/
+ ZSE_SMART_APPLIANCE_DEVICE_ID = 0x0505,
+ /*! The Prepayment Terminal device will allow utility customers or other users (e.g.
+ sub-metered tenants) to pay for consumption in discrete increments rather than
+ establishing a traditional billing agreement. The Prepayment Terminal device will
+ accept payment (e.g. credit card, code entry), display remaining balances, and
+ alert the user of a balance approaching zero, and may perform some or all of the
+ other functions described in In-Premise Display.*/
+ ZSE_PREPAYMENT_TERMINAL_DEVICE_ID = 0x0506,
+} ZSE_DeviceId_t;
+
+/***************************************************************************//**
+\brief Type describing possible HA Device Ids.
+*******************************************************************************/
+typedef enum
+{
+ /*! Home-Automation-Profile_r25 7.4.1 On/Off Light*/
+ HA_ON_OFF_LIGHT_DEVICE_ID = 0x0100,
+ /*! Home-Automation-Profile_r25 7.4.4 On/Off Light Switch*/
+ HA_ON_OFF_LIGHT_SWITCH_DEVICE_ID = 0x0103,
+ /*! Home-Automation-Profile_r25 7.4.5 Dimmer Switch*/
+ HA_DIMMER_SWITCH_DEVICE_ID = 0x0104,
+ /*! Home-Automation-Profile_r25 7.4.8 Occupancy Sensor*/
+ HA_OCCUPANCY_SENSOR_DEVICE_ID = 0x0107,
+ /*! Home-Automation-Profile_r25 7.3.7 Remote Control*/
+ HA_REMOTE_CONTROL_DEVICE_ID = 0x0006,
+ /*! Home-Automation-Profile_r25 7.4.2 Dimmable Light*/
+ HA_DIMMABLE_LIGHT_DEVICE_ID = 0x0101,
+ /*! Home-Automation-Profile_r25 7.6.2 Thermostat*/
+ HA_THERMOSTAT_DEVICE_ID = 0x0301,
+} HA_DeviceId_t;
+
+/***************************************************************************//**
+\brief Type describing possible ZLL Device Ids.
+*******************************************************************************/
+typedef enum
+{
+ /*! On/Off Light */
+ ZLL_ON_OFF_LIGHT_DEVICE_ID = 0x0000,
+ /*! On/off plug-in unit */
+ ZLL_ON_OFF_PLUGIN_UNIT_DEVICE_ID = 0x0010,
+ /*! Dimmable light */
+ ZLL_DIMMABLE_LIGHT_DEVICE_ID = 0x0100,
+ /*! Dimmable plug-in unit */
+ ZLL_DIMMABLE_PLUGIN_UNIT_DEVICE_ID = 0x0110,
+ /*! Color light */
+ ZLL_COLOR_LIGHT_DEVICE_ID = 0x0200,
+ /*! Color remote */
+ ZLL_COLOR_REMOTE_DEVICE_ID = 0x0800,
+ /*! Color scene remote */
+ ZLL_COLOR_SCENE_REMOTE_DEVICE_ID = 0x0810,
+ /*! Non-color remote */
+ ZLL_NON_COLOR_REMOTE_DEVICE_ID = 0x0820,
+ /*! Non-color scene remote */
+ ZLL_NON_COLOR_SCENE_REMOTE_DEVICE_ID = 0x0830,
+ /*! Control bridge */
+ ZLL_CONTROL_BRIDGE_DEVICE_ID = 0x0840,
+ /*! On/off sensor */
+ ZLL_ON_OFF_SENSOR_DEVICE_ID = 0x0850,
+} ZLL_DeviceId_t;
+
+/*************************************************************************//**
+ \brief ZCL event Ids
+*****************************************************************************/
+typedef enum
+{
+ ZCL_ATTRIBUTE_READ_EVENT_ID, //!< attribute read event
+ ZCL_ATTRIBUTE_WRITE_EVENT_ID, //!< attribute written event
+} ZCL_EventId_t;
+
+/*************************************************************************//**
+ \brief Reserved type to organize the queue of ZCL requests
+*****************************************************************************/
+typedef struct
+{
+ void *next;
+ uint8_t requestType;
+} ZCL_Service_t;
+
+/********************************************************************************//**
+\brief Type describing address fields of some attributes in ZCL
+***********************************************************************************/
+typedef struct
+{
+ APS_AddrMode_t addrMode; //!< address mode indicates which address shall be used
+ APS_Address_t addr; //!< address can be short, extended or group
+ ProfileId_t profileId; //!< profile identifier
+ Endpoint_t endpointId; //!< endpoint identifier
+ ClusterId_t clusterId; //!< cluster identifier
+ uint8_t clusterSide; //!< cluster side: server or client
+ uint16_t manufacturerSpecCode; //!< manufacturer specific code
+} ZCL_Addressing_t;
+
+/***************************************************************************//**
+\brief Type describing ZCL Cluster options.
+*******************************************************************************/
+typedef struct
+{
+ uint8_t type : 1;
+ uint8_t security : 1;
+ uint8_t reserved : 6;
+} ZCL_ClusterOptions_t;
+
+/***************************************************************************//**
+\brief Type describing ZCL's events on cluster's attribute.
+*******************************************************************************/
+typedef enum
+{
+ ZCL_READ_ATTRIBUTE_EVENT,
+ ZCL_WRITE_ATTRIBUTE_EVENT
+} ZCL_AttributeEvent_t;
+
+/***************************************************************************//**
+\brief Type describing ZCL Cluster.
+*******************************************************************************/
+typedef struct
+{
+ ClusterId_t id; //!< Cluster Id
+ ZCL_ClusterOptions_t options;
+ uint8_t attributesAmount; //!< Number of cluster attributes
+ uint8_t *attributes; //!< Cluster attribute descriptors
+ uint8_t commandsAmount; //!< Number of cluster-specific commands
+ uint8_t *commands; //!< Cluster-specific command descriptors
+ uint8_t isReporting; //!< Service field - if any automatic attribute reports are in progress
+ void (*ZCL_ReportInd)(ZCL_Addressing_t *addressing, uint8_t reportLength, uint8_t *reportPayload); //!< Callback for reporting events
+ void (*ZCL_AttributeEventInd)(ZCL_Addressing_t *addressing, ZCL_AttributeId_t attributeId, ZCL_AttributeEvent_t event); //!< Callback indicates action on cluster's attribute
+} ZCL_Cluster_t;
+
+/********************************************************************************//**
+\brief Type describing information which is necessary for put/get element to/from payload
+***********************************************************************************/
+typedef struct
+{
+ uint8_t id; //!< element id. Can be either ::ZCL_GeneralCommandId_t value or special cluster command id
+ uint8_t payloadLength; //!< payload length after adding a new element
+ uint8_t *payload; //!< payload pointer where an element is added.
+ void *content; //!< pointer to content (memory) which shall be added/filled to/from payload
+} ZCL_NextElement_t;
+
+/********************************************************************************//**
+\brief Type describing ZCL response
+***********************************************************************************/
+typedef struct
+{
+ ZCL_Status_t status; //!< status of command
+ uint8_t responseLength; //!< length of response payload
+ uint8_t *responsePayload; //!< pointer to response payload. Response payload can be parsed by ZCL_GetNextElement() function
+} ZCL_Response_t;
+
+typedef struct
+{
+ // Service structure
+ ZCL_Service_t service;
+ ZCL_Response_t response; //!< Response structure
+ void (*ZCL_Response)(ZCL_Response_t *resp); //!< callback for response
+ void (*ZCL_DefaultResponse)(ZCL_Response_t *resp); //!< callback for default response
+ ZCL_Addressing_t dstAddressing; //!< addressing of destination node
+ Endpoint_t endpointId; //!< endpoint id who is request initiator
+ uint8_t id; //!< command id
+ uint8_t requestLength; //!< request payload length
+ uint8_t defaultResponse; //!< default response bit state
+ uint8_t *requestPayload; //!< request payload. It can be filled by ZCL_PutNextElement() function.
+} ZCL_Request_t;
+
+BEGIN_PACK
+
+/********************************************************************************//**
+\brief Reporting record of an cluster attribute.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*! The direction field specifies whether values of the attribute are be reported (0x00),
+ * or whether reports of the attribute are to be received (0x01).*/
+ uint8_t direction;
+ /*! If the direction field is 0x00, this field contains the identifier of the attribute
+ * that is to be reported. If instead the direction field is 0x01,
+ * the device shall expect reports of values of this attribute.*/
+ ZCL_AttributeId_t attributeId;
+ union PACK
+ {
+ struct PACK
+ {
+ /*! The Attribute data type field contains the data type of the attribute
+ * that is to be reported.*/
+ uint8_t attributeType;
+ /*! The minimum reporting interval field is 16-bits in length and shall contain
+ * the minimum interval, in seconds, between issuing reports of the specified attribute.*/
+ ZCL_ReportTime_t minReportInterval;
+ /*! The maximum reporting interval field is 16-bits in length and
+ * shall contain the maximum interval, in seconds, between issuing reports
+ * of the specified attribute.*/
+ ZCL_ReportTime_t maxReportInterval;
+ /*! The reportable change field shall contain the minimum change to the attribute
+ * that will result in a report being issued. This field is of variable length.
+ * For attributes with 'analog' data type the field has the same data type
+ * as the attribute.*/
+ uint8_t reportableChange[1];
+ };
+ /*! The timeout period field is 16-bits in length and shall contain the maximum
+ * expected time, in seconds, between received reports for the attribute specified
+ * in the attribute identifier field. If more time than this elapses between reports,
+ * this may be an indication that there is a problem with reporting.
+ * If this value is set to 0x0000, reports of the attribute are not subject to timeout.*/
+ ZCL_ReportTime_t timeoutPeriod;
+ };
+} ZCL_ReportRecord_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of read request command.
+
+This type can be used to add one attribute entry to the read request payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+} ZCL_ReadAttributeReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of response to read request command.
+
+This type can be used to get one attribute entry from the read response payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+ uint8_t status; //!< status of reading attribute operation
+ uint8_t type; //!< requested attribute type
+ uint8_t value[1]; //!< requested attribute value
+} ZCL_ReadAttributeResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of write request command.
+
+This type can be used to add one attribute entry to the write request payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+ uint8_t type; //!< requested attribute type
+ uint8_t value[1]; //!< requested attribute value
+} ZCL_WriteAttributeReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of response to write request command.
+
+This type can be used to get next writing status from the write response payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ uint8_t status; //!< status of writing attribute operation
+ ZCL_AttributeId_t id; //!< requested attribute id
+} ZCL_WriteAttributeResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of configure report request command.
+
+This type can be used to add one reporting record to the "configure report" request payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_ReportRecord_t record; //!< Reporting record
+} ZCL_ConfigureReportReq_t;
+
+typedef struct PACK
+{
+ /*! TBD */
+ uint8_t direction;
+ /*! TBD */
+ uint16_t attributeId;
+ union PACK
+ {
+ struct PACK
+ {
+ /*! TBD */
+ uint8_t attributeType;
+ /*! TBD */
+ uint16_t minReportingInterval;
+ /*! TBD */
+ uint16_t maxReportingInterval;
+ /*! TBD */
+ uint8_t reportableChange[1];
+ };
+ /*! TBD */
+ uint16_t timeoutPeriod;
+ };
+} ZCL_ConfigureReportingReq_t;
+
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t direction;
+ uint16_t attributeId;
+} ZCL_ConfigureReportingResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of response to configure report request command.
+
+This type can be used to get next status entry from the "configure report" response payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ uint8_t status; //!< status of the configure reporting operation
+ uint8_t direction; //!< The direction field specifies whether values of the attribute are be reported (0x00), or whether reports of the attribute are to be received (0x01).
+ ZCL_AttributeId_t id; //!< requested attribute identifier
+} ZCL_ConfigureReportResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of ZCL Read Reporting Configuration command.
+***********************************************************************************/
+typedef struct PACK
+{
+ uint8_t direction; //!< The direction field specifies whether values of the attribute are be reported (0x00), or whether reports of the attribute are to be received (0x01).
+ uint16_t attributeId; //!< requested attribute identifier
+} ZCL_ReadReportingConfigurationReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of ZCL Read Reporting Configuration Response command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*! If the attribute is not implemented on the sender or receiver of the command,
+ * whichever is relevant (depending on direction), this field shall be set
+ * to UNSUPPORTED_ATTRIBUTE. If the attribute is supported, but is not capable of
+ * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE.
+ * Otherwise, this field shall be set to SUCCESS.*/
+ uint8_t status;
+ /*! The direction field specifies whether values of the attribute are reported (0x00),
+ * or whether reports of the attribute are received (0x01).*/
+ uint8_t direction;
+ /*! TBD */
+ uint16_t attributeId;
+ union PACK
+ {
+ struct PACK
+ {
+ /*! TBD */
+ uint8_t attributeType;
+ /*! TBD */
+ uint16_t minReportingInterval;
+ /*! TBD */
+ uint16_t maxReportingInterval;
+ /*! TBD */
+ uint8_t reportableChange[1];
+ };
+ /*! TBD */
+ uint16_t timeoutPeriod;
+ };
+} ZCL_ReadReportingConfigurationResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of report command.
+
+This type can be used to get next reported attribute from the report payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+ uint8_t type; //!< requested attribute type
+ uint8_t value[1]; //!< requested attribute value
+} ZCL_Report_t;
+
+/********************************************************************************//**
+\brief Type describing payload of ZCL Default Response Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*!The command identifier field is 8-bit in length and specifies the identifier
+ of the received command to which this command is a response.*/
+ uint8_t commandId;
+ /*!The status code field is 8-bit in length and specifies either SUCCESS or
+ the nature of the error that was detected in the receive command.*/
+ uint8_t statusCode;
+} ZCL_DefaultResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload of ZCL Discovery Attributes Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*!The start attribute identifier field is 16-bit in length and specifies
+ the value of the identifier at which to begin the attribute discovery.*/
+ ZCL_AttributeId_t startAttributeId;
+ /*!The maximum attribute identifiers field is 8-bit in length and specifies
+ the maximum number of attribute identifiers that are to be returned in the
+ resulting discovery attributes response command.*/
+ uint8_t maxAttributeIds;
+} ZCL_DiscoverAttributesReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload the Attribute Report field of ZCL Discovery
+ Attributes Response Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t attributeId; //!<Attribute identifier
+ uint8_t typeId; //!<Attribute data type Id
+} ZCL_DiscoverAttributesRespRec_t;
+
+/********************************************************************************//**
+\brief Type describing payload of ZCL Discovery Attributes Response Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*!The discovery complete field is a boolean field. A value of 0 indicates
+ that there are more attributes to be discovered. A value of 1 indicates that
+ there are no more attributes to be discovered.*/
+ uint8_t discoveryComplete;
+ /*!Discovered attribute information*/
+ ZCL_DiscoverAttributesRespRec_t attributeInfo[1];
+} ZCL_DiscoverAttributesResp_t;
+
+END_PACK
+
+/*************************************************************************//**
+ \brief Type describing attribute events notification
+*****************************************************************************/
+typedef struct
+{
+ ZCL_Addressing_t addressing; //!< source addressing, source endpoint, destination cluster
+ uint8_t attributeId; //!< attribute id
+} ZCL_AttributeEventNtfy_t;
+
+/*************************************************************************//**
+ \brief Type describing parameter of ZCL_EventNtfy() function
+*****************************************************************************/
+typedef struct
+{
+ ZCL_EventId_t eventId; //!< event Id (e.g. ZCL_ATTRIBUTE_READ_EVENT_ID)
+ union
+ {
+ ZCL_AttributeEventNtfy_t attribute; //!< attribute event
+ } eventType;
+} ZCL_EventNtfy_t;
+
+/********************************************************************************//**
+\brief Type describing parameter of ZCL_RegisterEndpoint() function
+***********************************************************************************/
+typedef struct
+{
+ // Service structure
+ struct
+ {
+ APS_RegisterEndpointReq_t apsEndpoint;
+ uint8_t seqNum;
+ } service;
+
+ SimpleDescriptor_t simpleDescriptor; //!< Device endpoint Simple Descriptor
+ ZCL_Cluster_t *serverCluster; //!< Device server clusters
+ ZCL_Cluster_t *clientCluster; //!< Device client clusters
+} ZCL_DeviceEndpoint_t;
+
+/*************************************************************************//**
+ \brief ZCL Data Type Descriptor.
+ Describes the Data Type length in bytes and Data Type kind (Analog or Descrete).
+*****************************************************************************/
+typedef struct
+{
+ uint16_t length; //!<Length in bytes
+ /*!Kind of Data Type (Analog or Descrete). The #ZCL_DATA_TYPE_ANALOG_KIND or \n
+ !#ZCL_DATA_TYPE_DESCRETE_KIND should be used).*/
+ uint8_t kind;
+} ZCL_DataTypeDescriptor_t;
+
+/******************************************************************************
+ Inline functions section
+******************************************************************************/
+/********************************************************************************//**
+ \brief Gets Cluster Side the Incoming command is intended to.
+
+ \param[in] direction - incoming command direction
+ \return cluster side detected
+***********************************************************************************/
+INLINE uint8_t getDstClusterSideByIncommingCommandDirection(uint8_t direction)
+{
+ return direction;
+}
+
+/********************************************************************************//**
+ \brief Gets source Cluster Side by destination Cluster side.
+
+ \param[in] clusterSide - destination cluster's side
+ \return cluster side detected
+***********************************************************************************/
+INLINE uint8_t getSrcClusterSideByDstClusterSide(uint8_t clusterSide)
+{
+ return !clusterSide;
+}
+
+/********************************************************************************//**
+ \brief Gets destination Cluster Side by source Cluster side.
+
+ \param[in] clusterSide - source cluster's side
+ \return cluster side detected
+***********************************************************************************/
+INLINE uint8_t getDstClusterSideBySrcClusterSide(uint8_t clusterSide)
+{
+ return !clusterSide;
+}
+
+/********************************************************************************//**
+ \brief Gets outgoing command direction by destination Cluster side.
+
+ \param[in] clusterSide - destination cluster's side
+ \return command direction detected
+***********************************************************************************/
+INLINE uint8_t getOutgoingCommandDirectionByDstClusterSide(uint8_t clusterSide)
+{
+ return clusterSide;
+}
+
+/********************************************************************************//**
+ \brief Gets source Cluster side by direction of incoming command.
+
+ \param[in] direction - incoming command direction.
+ \return detected cluster side.
+***********************************************************************************/
+INLINE uint8_t getOwnClusterSideByIncomingCommandDirection(uint8_t direction)
+{
+ return direction;
+}
+
+/********************************************************************************//**
+ \brief Gets destination Cluster side by direction of outgoing command.
+
+ \param[in] direction - outgoing command direction.
+ \return detected cluster side.
+***********************************************************************************/
+INLINE uint8_t getDstClusterSideByOutgoingCommandDirection(uint8_t direction)
+{
+ return direction;
+}
+
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+/*********************************************************************************//**
+\brief Register device endpoint.
+
+This function registers a device endpoint to make ZCL know which devices types
+are used in applications and which clusters they support.
+
+\param[in] endpoint - contains device descriptor
+************************************************************************************/
+void ZCL_RegisterEndpoint(ZCL_DeviceEndpoint_t *endpoint);
+
+/*************************************************************************//**
+ \brief This function resets ZCL component.
+
+ \param[in] none
+*****************************************************************************/
+void ZCL_ResetReq(void);
+
+/*************************************************************************//**
+ \brief Finds attribute in ZCL and returns attribute value
+
+ \param[in] endpointId - endpoint on which cluster is registered
+ \param[in] clusterId - cluster unique identifier
+ \param[in] direction - detects the cluster's side (client or server)
+ \param[in] attrId - attribute unique identifier
+ \param[out] attrType - pointer to attribute type determined and returned
+ \param[out] attrValue - read out attribute value pointer
+
+ \return status of operation
+*****************************************************************************/
+ZCL_Status_t ZCL_ReadAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
+ ZCL_AttributeId_t attrId, uint8_t *attrType, uint8_t *attrValue);
+
+/*************************************************************************//**
+ \brief Finds attribute in ZCL and rewrites its value by the new one
+ (to be used with local write request).
+
+ \param[in] endpointId - endpoint on which cluster is registered
+ \param[in] clusterId - cluster unique identifier
+ \param[in] direction - detects the cluster's side (client or server)
+ \param[in] attrId - attribute unique identifier
+ \param[in] attrType - type of the attribute to be set
+ \param[in] attrValue - pointer to attribute value to be set
+
+ \return status of operation
+*****************************************************************************/
+ZCL_Status_t ZCL_WriteAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
+ ZCL_AttributeId_t attrId, uint8_t attrType, uint8_t *attrValue);
+
+/*************************************************************************//**
+ \brief Finds attribute in ZCL and rewrites its value by the new one
+ (to be used with remote write request).
+
+ \param[in] endpointId - endpoint on which cluster is registered
+ \param[in] clusterId - cluster unique identifier
+ \param[in] direction - detects the cluster's side (client or server)
+ \param[in] attrId - attribute unique identifier
+ \param[in] attrType - type of the attribute to be set
+ \param[in] attrValue - pointer to attribute value to be set
+
+ \return status of operation
+*****************************************************************************/
+ZCL_Status_t zclRemoteWriteAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
+ ZCL_AttributeId_t attrId, uint8_t attrType, uint8_t *attrValue);
+
+/*************************************************************************//**
+ \brief Sends a general ZCL command related to attributes to a remote device
+
+ The function is used to read/write attributes from a remote device, to report
+ local attributes, and to discover attributes supported by a particular cluster
+ on a remote device.
+
+ Command's parameters include addressing information, calback functions, command's
+ ID, and the payload. The payload may be formed via the ZCL_PutNextElement() function
+ and an instance of ZCL_NextElement_t type. The command may be used to perform
+ actions on multiple attributes at a time; for example, to read several attributes
+ from a remote device.
+
+ Attribute related commands are usually send to specific short or extended addresses.
+ Sending such commands to bound devices (employing ::APS_NO_ADDRESS mode) may not
+ be as efficient, because in case of responses from more than one device the ZCL
+ component will process only the first one.
+
+ Upon receiving the response from the remote device, the callback function specified
+ in the \c req->ZCL_Response field is called.
+
+ Common uses of the function include sending the following commands (the command's
+ ID listed below should be assigned to the \c req->id field):
+ \li ::ZCL_READ_ATTRIBUTES_COMMAND_ID - reading remote attributes (obtaining values)
+ \li ::ZCL_WRITE_ATTRIBUTES_COMMAND_ID - writing remote attributes (assigning new values)
+ \li ::ZCL_REPORT_ATTRIBUTES_COMMAND_ID - reporting local attributes to remote devices
+ (sending current attributes' values)
+ \li ::ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID - discovering attributes of a remote device (obtaining
+ data types and IDs of attributes supported by a particular cluster)
+
+ \param[in] req - command parameters
+*****************************************************************************/
+void ZCL_AttributeReq(ZCL_Request_t *req);
+
+/*********************************************************************************//**
+ \brief Sends a cluster command
+
+ The function sends a general cluster specific command. The command's type is
+ recognized according to the \c req->id field. Commands' IDs are defined in clusters'
+ definition files, which also contain all definition related to a particular cluster.
+
+ In addition to addressing information and command's ID, eesential fields of
+ the request parameters include the payload and the payload length. The payload
+ for each command is defined as a structure in the cluster's definition file.
+ The pointer to a properly configured instance of the command's payload shall be \
+ assigned to the \c req->requestPayload field.
+
+ The callback function specified in the \c req->ZCL_Response field is called to
+ indicate the status of the command's delivery (not a specific response for the
+ command). If acknowledgment of the command's delivery is received the success
+ status is reported in the callback.
+
+ A specific response to the command is processed by a special indication function
+ registered for the command. If a command does not imply a specific response
+ the default response may be requested (to indicate that the command has been
+ executed). To request the default response set the \c req->defaultResponse field
+ to ::ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE and assign the callback function
+ that should be called upon default response reception to the \c req->ZCL_DefaultResponse
+ field. To disable default response set \c req->defaultResponse to
+ ::ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE and \c req->ZCL_DefaultResponse to \c NULL.
+
+ \param[in] req - contains request descriptor
+************************************************************************************/
+void ZCL_CommandReq(ZCL_Request_t *req);
+
+/*********************************************************************************//**
+\brief Specific command indication handler
+
+\param[in] ind - contains indication descriptor
+************************************************************************************/
+//void ZCL_CommandInd(ZCL_CommandInd_t *ind);
+
+/*************************************************************************//**
+ \brief ZCL event notification handler
+
+ \param[in] event - contains event descriptor
+*****************************************************************************/
+void ZCL_EventNtfy(ZCL_EventNtfy_t *event);
+
+/*************************************************************************//**
+ \brief This function returns bytes amount of a type by type id.
+
+ \param[in] typeId - type id
+ \param[in] value - pointer to variable of typeId, NULL means maximum possible
+ size.
+*****************************************************************************/
+uint16_t ZCL_GetAttributeLength(uint8_t typeId, const uint8_t *value);
+
+/*************************************************************************//**
+ \brief Adds an element to the outgoing command payload
+
+ This function is used to simplify forming a correst payload for general
+ commands (read/write attributes etc.). A single command may involve actions on
+ several attributes, and so the overall payload should contain pieces
+ corresponding to each attribute.
+
+ The general idea is to provide a buffer for the payload and some content. The
+ function writes the content in a correct way to the buffer and calculate the
+ overall payload length. The buffer and the payload length are then passed as
+ parameters to the ZCL_AttributeReq() function.
+
+ See the following example:
+
+\code
+ZCL_NextElement_t element;
+ZCL_ReadAttributeReq_t readAttrReqElement;
+ZCL_Request_t readAttrReq;
+uint8_t buffer[BUFFER_SIZE];
+
+element.payloadLength = 0;
+element.payload = buffer;
+element.id = ZCL_READ_ATTRIBUTES_COMMAND_ID;
+element.content = &readAttrReqElement;
+
+readAttrReqElement = ATTRIBUTE_ID1; //Set to the ID of the first attribute
+ZCL_PutNextElement(&element);
+
+readAttrReqElement = ATTRIBUTE_ID2; //Set to the ID of the second attribute
+ZCL_PutNextElement(&element);
+
+readAttrReq.requestLength = element.payloadLength;
+readAttrReq.requestPayload = element.payload;
+...
+\endcode
+
+ Note, however, that the usage may differ depending on a command's type.
+
+ \param[in] element - information about payload and element
+ \param[out] status of the operation
+*****************************************************************************/
+ZCL_Status_t ZCL_PutNextElement(ZCL_NextElement_t *element);
+
+/*************************************************************************//**
+ \brief Gets an element from the incoming command's payload
+
+ The function is used to simplify processing of responses fo general
+ attributes related commands. Such command may return information concerning
+ several attributes in a single frame. This function reads the next portion
+ of information from the response payload.
+
+ To use the function configure an instance of ZCL_NextElement type.
+ The \c element->payload field should be set to the response payload,
+ the \c element->payloadLength to the reponse payload's length, and
+ the \c element->id field to the ID of the response. After calling this
+ function, the \c element->content field may be casted to the appropriate
+ response type (depending on the command's type); for example, for
+ read attributes response it is ZCL_ReadAttributeResp_t.
+
+ \param[in] element - information about payload and element
+ \param[out] status of the operation
+*****************************************************************************/
+ZCL_Status_t ZCL_GetNextElement(ZCL_NextElement_t *element);
+
+/***************************************************************************//**
+\brief Checks whether ZCL is busy or not.
+
+\return true - if ZCL is busy, false - otherwise.
+******************************************************************************/
+bool ZCL_IsBusy(void);
+
+/*************************************************************************//**
+ \brief ZCL Data Type Descriptor get by Type Id function.
+ Fills the ZCL Data Type Descriptor dased on ZCL Data Type Id
+ \param Id - ZCL Data Type Id (unsigned 8-bit integer)
+ \param value - pointer to variable of typeId, NULL means maximum possible
+ size.
+ \param descriptor - ZCL Data Type Descriptor being filled.
+ \return None.
+ \sa ZCL_DataTypeDescriptor_t
+ \sa ZCL_GetAttributeLength()
+*****************************************************************************/
+void ZCL_GetDataTypeDescriptor(uint8_t typeId, const uint8_t *value, ZCL_DataTypeDescriptor_t *descriptor);
+
+#endif //_ZCL_H
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h
new file mode 100644
index 00000000..da679d3e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h
@@ -0,0 +1,105 @@
+/***************************************************************************//**
+ \file zclBACnetProtocolTunnelCluster.h
+
+ \brief
+ The header file describes the ZCL BACnet Protocol Tunnel Cluster and its interface
+
+ The file describes the types and interface of the ZCL BACnet Protocol Tunnel Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 20.10.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLBACNETPROTOCOLTUNNELCLUSTER_H
+#define _ZCLBACNETPROTOCOLTUNNELCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/***************************************************************************//**
+ \brief ZCL BACnet Protocol Tunnel Cluster server side attributes amount
+*******************************************************************************/
+#define ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+/***************************************************************************//**
+ \brief ZCL BACnet Protocol Tunnel client side attributes amount
+*******************************************************************************/
+#define ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+/***************************************************************************//**
+ \brief ZCL BACnet Protocol Tunnel Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BACNET_PROTOCOL_TUNNEL_COMMANDS_AMOUNT 1
+/**
+ * \brief Generic tunnel client side commands identifiers.
+*/
+#define ZCL_BACNET_PROTOCOL_TRANSFER_NPDU_COMMAND_ID 0x00
+
+#define ZCL_DEFINE_BACNET_PROTOCOL_CLUSTER_TUNNEL_CLUSTER_COMMANDS(transferNPDUCommandInd) \
+ DEFINE_COMMAND(transferNPDUCommand, ZCL_BACNET_PROTOCOL_TRANSFER_NPDU_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), transferNPDUCommandInd)
+
+#define BACNET_PROTOCOL_TUNNEL_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = BACNET_PROTOCOL_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_BACNET_PROTOCOL_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define BACNET_PROTOCOL_TUNNEL_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = BACNET_PROTOCOL_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_BACNET_PROTOCOL_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_BACNET_PROTOCOL_TUNNEL_CLUSTER(cltype, clattributes, clcommands) BACNET_PROTOCOL_TUNNEL_CLUSTER##cltype(clattributes, clcommands)
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Transfer NPDU Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t npdu[1]; //!<npdu octet string
+} ZCL_TransferNPDU_t;
+END_PACK
+/**
+ * \brief BACnet protocol tunnel cluster commands.
+*/
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*transferNPDUCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TransferNPDU_t *payload);
+ } transferNPDUCommand;
+} ZCL_BACnetProtocolTunnelCommands_t;
+
+#endif /* _ZCLBACNETPROTOCOLTUNNELCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h
new file mode 100644
index 00000000..b21facc5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h
@@ -0,0 +1,259 @@
+/***************************************************************************//**
+ \file zclBasicCluster.h
+
+ \brief
+ The header file describes the ZCL Basic Cluster and its interface
+
+ The file describes the types and interface of the ZCL Basic Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 03.01.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLBASICCLUSTER_H
+#define _ZCLBASICCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+//The ZCLVersion and PowerSource attributes
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+//There are no any commands at the server side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+//There are no any commands at the client side
+
+
+//Atribute Ids of Basic Device Information Attribute Set at the server side
+//!ZCL Basic Cluster server side ZCLVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+//!ZCL Basic Cluster server side ApplicationVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Basic Cluster server side StackVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Basic Cluster server side HWVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+//!ZCL Basic Cluster server side ManufacturerName attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+//!ZCL Basic Cluster server side ModelIdentifier attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID CCPU_TO_LE16(0x0005)
+//!ZCL Basic Cluster server side DateCode attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID CCPU_TO_LE16(0x0006)
+//!ZCL Basic Cluster server side PowerSource attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID CCPU_TO_LE16(0x0007)
+
+//Atribute Ids of Basic Device Settings Attribute Set at the server side
+//!ZCL Basic Cluster server side LocationDescription attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_LOCATION_DESCRIPTION_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+//!ZCL Basic Cluster server side PhysicalEnvironment attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+//!ZCL Basic Cluster server side DeviceEnabled attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DEVICE_ENABLED_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+//!ZCL Basic Cluster server side AlarmMask attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ALARM_MASK_ATTRIBUTE_ID CCPU_TO_LE16(0x0013)
+
+//!ZCL Basic Cluster server side ResetToFactoryDeafaults commabd id
+#define ZCL_BASIC_CLUSTER_SERVER_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID 0x00
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Basic Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterAttributes = ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(zclVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(powerSource, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side defining macros
+
+ This macros should be used with #ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES for
+ ZCL Basic Cluster server side defining in application.
+
+ \param attributes - pointer to cluster server attributes (ZCL_BasicClusterServerAttributes_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterServerAttributes = DEFINE_ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_SERVER(&basicClusterServerAttributes),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side defining macros
+
+ This macros should be used for ZCL Basic Cluster client side defining in application.
+
+ \return None
+
+ \internal
+ //The typical code is:
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_CLIENT(),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_CLIENT() \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Basic Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Basic Device Information attribute set (Id == 0x00)
+
+ /*!ZCL Version attribute (Read only, M)
+ The ZCLVersion attribute is 8-bits in length and specifies the version number of
+ the ZigBee Cluster Library that all clusters on this endpoint conform to. For the
+ initial version of the ZCL, this attribute shall be set to 0x01.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } zclVersion;
+
+ /*!Power Source attribute (Read only, M)
+ The PowerSource attribute is 8-bits in length and specifies the source(s) of power
+ available to the device. Bits b0 of this attribute represent the primary power
+ source of the device and bit b7 indicates whether the device has a secondary power
+ source in the form of a battery backup.
+
+ Bits b0 of this attribute shall be set to one of the non-reserved values:
+ 0x00 - Unknown
+ 0x01 - Mains (single phase)
+ 0x02 - Mains (3 phase)
+ 0x03 - Battery
+ 0x04 - DC source
+ 0x05 - Emergency mains constantly powered
+ 0x06 - Emergency mains and transfer switch
+ 0x07-0x7f - Reserved
+
+ Bit b7 of this attribute shall be set to 1 if the device has a secondary power source
+ in the form of a battery backup. Otherwise, bit b7 shall be set to 0.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0007, #ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (8-bit enumeration, #ZCL_8BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } powerSource;
+
+ //!Basic Device Settings attribute set (Id == 0x01)
+} ZCL_BasicClusterServerAttributes_t;
+
+END_PACK
+
+#if 0
+// The ResetToFactoryDefaults command is optional now.
+/***************************************************************************//**
+ \brief
+ Describes the Basic Cluster server side commands
+
+ On receipt of this command, the device resets all the attributes of all its clusters to
+ their factory defaults.
+ Note that ZigBee networking functionality and any bindings are not affected by
+ this command.
+ This command does not have a payload.
+*******************************************************************************/
+typedef struct PACK
+{
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00, #ZCL_BASIC_CLUSTER_SERVER_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID)
+ ZclCommandOptions_t options; //!<Command options (.direction should be equal to #ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER)
+ /*!
+ \brief
+ Command indication handler
+ \param payloadLength - actual payload length in bytes (should be zero)
+ */
+ void (*resetToFactoryDefaults)(uint8_t payloadLength, uint8_t *payload);
+ } resetToFactoryDefaults;
+} BasicClusterServerCommands_t;
+#endif //#if 0
+
+
+#endif //#ifndef _ZCLBASICCLUSTER_H
+
+//eof zclBasicCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h
new file mode 100644
index 00000000..a3b9e23c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h
@@ -0,0 +1,351 @@
+/************************************************************************//**
+ \file zclDemandResponseCluster.h
+
+ \brief
+ The header file describes the Demand Response Cluster.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 03.02.09 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _ZCLDEMANDRESPONSECLUSTER_H
+#define _ZCLDEMANDRESPONSECLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+/**
+ * \brief Demand Response Server Cluster attributes amount.
+*/
+#define DRLC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Demand Response Client Cluster attributes amount.
+*/
+#define DRLC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 4
+
+/**
+ * \brief Demand Response Cluster commands amount.
+*/
+#define DRLC_CLUSTER_COMMANDS_AMOUNT 5
+
+/**
+ * \brief Demand Response Server Cluster commands identifiers.
+*/
+#define LOAD_CONTROL_EVENT_COMMAND_ID 0x00
+#define CANCEL_LOAD_CONTROL_EVENT_COMMAND_ID 0x01
+#define CANCEL_ALL_LOAD_CONTROL_EVENTS_COMMAND_ID 0x02
+
+/**
+ * \brief Demand Response Client Cluster commands identifiers.
+*/
+#define REPORT_EVENT_STATUS_COMMAND_ID 0x00
+#define GET_SCHEDULED_EVENTS_COMMAND_ID 0x01
+
+/**
+ * \brief Report event status identifiers
+ */
+#define REPORT_EVENT_STATUS_COMMAND_RECEIVED 0x01
+#define REPORT_EVENT_STATUS_EVENT_STARTED 0x02
+#define REPORT_EVENT_STATUS_EVENT_COMPLETED 0x03
+#define REPORT_EVENT_STATUS_EVENT_CANCELED 0x06
+#define REPORT_EVENT_STATUS_INVALID_CANCEL_COMMAND_DEFAULT 0xF8
+
+#define DEFINE_DRLC_CLUSTER_COMMANDS(clLoadControlEventInd, \
+ clCancelLoadControlEventInd, \
+ clCancelAllLoadControlEventsInd, \
+ clReportEventStatusInd, \
+ clGetScheduledEventsInd) \
+ DEFINE_COMMAND(loadControlEventCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clLoadControlEventInd), \
+ DEFINE_COMMAND(cancelLoadControlEventCommand, 0x01, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clCancelLoadControlEventInd), \
+ DEFINE_COMMAND(cancelAllLoadControlEventsCommand, 0x02, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clCancelAllLoadControlEventsInd), \
+ DEFINE_COMMAND(reportEventStatusCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clReportEventStatusInd), \
+ DEFINE_COMMAND(getScheduledEventsCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clGetScheduledEventsInd)
+
+
+
+
+#define DEFINE_DRLC_CLUSTER_CLIENT_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(utilityEnrolmentGroupAttr, ZCL_READWRITE_ATTRIBUTE, CCPU_TO_LE16(0x0000), ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(startRandomizeMinutesAttr, ZCL_READWRITE_ATTRIBUTE, CCPU_TO_LE16(0x0001), ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(endRandomizeMinutesAttr, ZCL_READWRITE_ATTRIBUTE, CCPU_TO_LE16(0x0002), ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(deviceClassValueAttr, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0003), ZCL_16BIT_BITMAP_DATA_TYPE_ID)
+
+#define DRLC_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = DRLC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = DRLC_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DRLC_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = DRLC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = DRLC_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DEFINE_DRLC_CLUSTER(cltype, clattributes, clcommands) \
+ DRLC_CLUSTER_##cltype(clattributes, clcommands)
+
+//! Signature type. AMI r15 profile spec., D.2.3.3.1.1.
+#define ZCL_ECDSA_SIGNATURE_TYPE 0x01
+//! Signature length. AMI r15 profile spec., D.2.3.3.1.1.
+#define REPORT_EVENT_STATUS_SIGNATURE_LENGTH 42
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief Device Class type.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(8,(
+ uint16_t hvacCompressor : 1,
+ uint16_t stripHeaters : 1,
+ uint16_t waterHeater : 1,
+ uint16_t poolPump : 1,
+ uint16_t smartAppliances : 1,
+ uint16_t irrigationPump : 1,
+ uint16_t managedCommercAndIndustrLoads : 1,
+ uint16_t simpleMiscLoads : 1
+ ))
+ LITTLE_ENDIAN_OCTET(5,(
+ uint16_t exteriorLighting : 1,
+ uint16_t interiorLighting : 1,
+ uint16_t electricalVehicle : 1,
+ uint16_t generationSystem : 1,
+ uint16_t reserved : 4
+ ))
+} ZCL_DeviceClass_t;
+
+/**
+ * \brief Device Class type.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(3,(
+ uint8_t randStartTime : 1,
+ uint8_t randEndTime : 1,
+ uint8_t reserved : 6
+ ))
+} ZCL_EventControl_t;
+
+/**
+ * \brief The Load Control Event Command Payload.
+*/
+typedef struct PACK
+{
+ uint32_t issuerEventId;
+ ZCL_DeviceClass_t deviceClass;
+ uint8_t utilityEnrolmentGroup;
+ uint32_t startTime;
+ uint16_t durationInMinutes;
+ uint8_t criticalityLevel;
+ uint8_t coolingTemperatureOffset;
+ uint8_t heatingTemperatureOffset;
+ uint16_t coolingTemperatureSetPoint;
+ uint16_t heatingTemperatureSetPoint;
+ int8_t avrgLoadAdjstPercentage;
+ uint8_t dutyCycle;
+ ZCL_EventControl_t eventControl;
+} ZCL_LoadControlEvent_t;
+
+/**
+ * \brief The Cancel Control type.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t randomizeEnd : 1,
+ uint8_t reserved : 7
+ ))
+} ZCL_CancelControl_t;
+
+/**
+ * \brief The Cancel Load Control Event Command Payload.
+*/
+typedef struct PACK
+{
+ uint32_t issuerEventId;
+ ZCL_DeviceClass_t deviceClass;
+ uint8_t utilityEnrolmentGroup;
+ ZCL_CancelControl_t cancelControl;
+ ZCL_UTCTime_t effectiveTime;
+} ZCL_CancelLoadControlEvent_t;
+
+typedef struct PACK
+{
+ ZCL_CancelControl_t cancelControl; // ZCL_U8BIT_BITMAP_TYPE_ID
+} ZCL_CancelAllLoadControlEvents_t;
+
+typedef struct PACK
+{
+ //! Utility Enrolment Group Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t utilityEnrolmentGroup;
+ } utilityEnrolmentGroupAttr;
+
+ //! Start Randomize Minutes Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t startRandomizeMinutes;
+ } startRandomizeMinutesAttr;
+
+ //! End Randomize Minutes Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t endRandomizeMinutes;
+ } endRandomizeMinutesAttr;
+
+ //! Device Class Value Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ ZCL_DeviceClass_t deviceClassValue;
+ } deviceClassValueAttr;
+
+} ZCL_DemandResponseClientClusterAttributes_t;
+
+/**
+ * \brief Report event status type.
+*/
+typedef struct PACK
+{
+ uint32_t issuerEventId;
+ uint8_t eventStatus;
+ ZCL_UTCTime_t eventStatusTime;
+ uint8_t criticalityLevelApplied;
+ uint16_t coolingTemperatureSetPointApplied;
+ uint16_t heatingTemperatureSetPointApplied;
+ int8_t avrgLoadAdjstPercentageApplied;
+ uint8_t dutyCycleApplied;
+ ZCL_EventControl_t eventControl;
+ uint8_t signatureType;
+ uint8_t signature[REPORT_EVENT_STATUS_SIGNATURE_LENGTH];
+} ZCL_ReportEventStatus_t;
+
+/**
+ * \brief Get scheduled events type.
+*/
+typedef struct PACK
+{
+ ZCL_UTCTime_t startTime;
+ uint8_t numberOfEvents;
+} ZCL_GetScheduledEvents_t;
+
+END_PACK
+
+/**
+ * \brief ZCL Demand Response Cluster Commands.
+*/
+typedef struct
+{
+ //! Load Control Event Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*loadControlEvent)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_LoadControlEvent_t *payload);
+ } loadControlEventCommand;
+
+ //! Cancel Load Control Event Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*cancelLoadControlEvent)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CancelLoadControlEvent_t *payload);
+ } cancelLoadControlEventCommand;
+
+ //! Confirm Key Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x02)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*cancelAllLoadControlEvents)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CancelAllLoadControlEvents_t *payload);
+ } cancelAllLoadControlEventsCommand;
+ //! Report Event Status Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*reportEventStatus)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ReportEventStatus_t *payload);
+ } reportEventStatusCommand;
+
+ //! Confirm Key Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x02)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*getScheduledEvents)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetScheduledEvents_t *payload);
+ } getScheduledEventsCommand;
+
+} ZCL_DemandResponseAndLoadControlClusterCommands_t;
+
+#endif /*_ZCLDEMANDRESPONSECLUSTER_H*/
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h
new file mode 100644
index 00000000..93560a06
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h
@@ -0,0 +1,176 @@
+/***************************************************************************//**
+ \file zclGenericTunnelCluster.h
+
+ \brief
+ The header file describes the ZCL Generic Tunnel Cluster and its interface
+
+ The file describes the types and interface of the ZCL Generic Tunnel Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 20.10.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLGENERICTUNNELCLUSTER_H
+#define _ZCLGENERICTUNNELCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/***************************************************************************//**
+ \brief ZCL Generic Tunnel Cluster server side attributes amount
+*******************************************************************************/
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 3
+/***************************************************************************//**
+ \brief ZCL Generic Tunnel Cluster client side attributes amount
+*******************************************************************************/
+#define ZCL_GENERIC_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+/***************************************************************************//**
+ \brief ZCL Generic Tunnel Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_GENERIC_TUNNEL_COMMANDS_AMOUNT 3
+/**
+ * \brief Generic tunnel server side attributes identifiers.
+*/
+//!ZCL Generic tunnel server side MaximumIncomingTransferSize attribute id
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MITS_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Generic tunnel server side MaximumOutgoingTransferSize attribute id
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MOTS_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Generic tunnel server side ProtocolAddress attribute id
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_PROTOCOL_ADDR_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+/**
+ * \brief Generic tunnel server side commands identifiers.
+*/
+#define ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID 0x00
+#define ZCL_GENERIC_TUNNEL_ADVERTISE_PROTOCOL_ADDRESS_COMMAND_ID 0x01
+/**
+ * \brief Generic tunnel client side commands identifiers.
+*/
+#define ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID 0x00
+
+#define ZCL_DEFINE_GENERIC_TUNNEL_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(maximumIncomingTransferSize, ZCL_READONLY_ATTRIBUTE, ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MITS_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(maximumOutgoingTransferSize, ZCL_READONLY_ATTRIBUTE, ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MOTS_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(protocolAddress, ZCL_READWRITE_ATTRIBUTE, ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_PROTOCOL_ADDR_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_GENERIC_TUNNEL_CLUSTER_COMMANDS(matchProtocolAddressCommandInd, matchProtocolAddressResponseCommandInd, advertiseProtocolAddressInd) \
+ DEFINE_COMMAND(matchProtocolAddressCommand, ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), matchProtocolAddressCommandInd), \
+ DEFINE_COMMAND(matchProtocolAddressResponseCommand, ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), matchProtocolAddressResponseCommandInd), \
+ DEFINE_COMMAND(advertiseProtocolAddress, ZCL_GENERIC_TUNNEL_ADVERTISE_PROTOCOL_ADDRESS_COMMAND_ID, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), advertiseProtocolAddressInd)
+
+#define GENERIC_TUNNEL_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GENERIC_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_GENERIC_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GENERIC_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define GENERIC_TUNNEL_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GENERIC_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GENERIC_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_GENERIC_TUNNEL_CLUSTER(cltype, clattributes, clcommands) GENERIC_TUNNEL_CLUSTER##cltype(clattributes, clcommands)
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Match Protocol Address Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t address[1]; //!<address (octet string)
+} ZCL_MatchProtocolAddress_t;
+/**
+ * \brief Advertise Protocol Address Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t address[1]; //!<address (octet string)
+} ZCL_AdvertiseProtocolAddress_t;
+/**
+ * \brief Generic tunnel cluster server attributes.
+*/
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } maximumIncomingTransferSize;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } maximumOutgoingTransferSize;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value[OCTET_STRING_MAX_SIZE];
+ } protocolAddress;
+} ZCL_GenericTunnelClusterServerAttributes_t;
+END_PACK
+/**
+ * \brief Generic tunnel cluster commands.
+*/
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*matchProtocolAddressCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_MatchProtocolAddress_t *payload);
+ } matchProtocolAddressCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*matchProtocolAddressResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } matchProtocolAddressResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*advertiseProtocolAddress)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AdvertiseProtocolAddress_t *payload);
+ } advertiseProtocolAddress;
+} ZCL_GenericTunnelClusterCommands_t;
+
+#endif /* _ZCLGENERICTUNNELCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h
new file mode 100644
index 00000000..43e233ca
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h
@@ -0,0 +1,361 @@
+/***************************************************************************//**
+ \file zclGroupsCluster.h
+
+ \brief
+ The header file describes the ZCL Groups Cluster and its interface
+
+ The file describes the types and interface of the ZCL Groups Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLGROUPSCLUSTER_H
+#define _ZCLGROUPSCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Groups Cluster group name support bit
+*/
+
+#define GROUP_NAME_SUPPORT_FLAG 0x80
+
+/**
+ * \brief Groups Cluster server attributes amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Groups Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Groups Cluster commands amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT 10
+
+/**
+ * \brief Groups Cluster server's attributes identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Groups Cluster client's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID 0x03
+#define ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID 0x04
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID 0x05
+
+/**
+ * \brief Groups Cluster servers's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID 0x03
+
+/**
+ * \brief Groups Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_COMMANDS(addGroupCommandInd, viewGroupCommandInd, getGroupMembershipCommandInd, \
+ removeGroupCommandInd, removeAllGroupsCommandInd, addGroupIfIdentifyingCommandInd, \
+ addGroupResponseCommandInd, viewGroupResponseCommandInd, getGroupMembershipResponseCommandInd, \
+ removeGroupResponseCommandInd) \
+ DEFINE_COMMAND(addGroupCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupCommandInd), \
+ DEFINE_COMMAND(viewGroupCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipCommandInd), \
+ DEFINE_COMMAND(removeGroupCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupCommandInd), \
+ DEFINE_COMMAND(removeAllGroupsCommand, ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllGroupsCommandInd), \
+ DEFINE_COMMAND(addGroupIfIdentifyingCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupIfIdentifyingCommandInd), \
+ DEFINE_COMMAND(addGroupResponseCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupResponseCommandInd), \
+ DEFINE_COMMAND(viewGroupResponseCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupResponseCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipResponseCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipResponseCommandInd), \
+ DEFINE_COMMAND(removeGroupResponseCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupResponseCommandInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define GROUPS_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define GROUPS_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_GROUPS_CLUSTER(cltype, clattributes, clcommands) \
+ GROUPS_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[2];
+} ZCL_AddGroup_t;
+
+/**
+ * \brief View Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_ViewGroup_t;
+
+/**
+ * \brief Get Group Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t groupCount;
+ uint16_t groupList[1];
+} ZCL_GetGroupMembership_t;
+
+/**
+ * \brief Remove Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveGroup_t;
+
+/**
+ * \brief Add Group if identifying Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[2];
+} ZCL_AddGroupIfIdentifying_t;
+
+/**
+ * \brief Add Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_AddGroupResponse_t;
+
+/**
+ * \brief View Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t groupName[2];
+} ZCL_ViewGroupResponse_t;
+
+/**
+ * \brief Get Group Membership Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t capacity;
+ uint8_t groupCount;
+ uint16_t groupList[1];
+} ZCL_GetGroupMembershipResponse_t;
+
+/**
+ * \brief Remove Group Command Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveGroupResponse_t;
+
+/**
+ * \brief Groups Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_GroupsClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Groups Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroup_t * payload);
+ } addGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroup_t * payload);
+ } viewGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembership_t * payload);
+ } getGroupMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroup_t * payload);
+ } removeGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllGroupsCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void * payload);
+ } removeAllGroupsCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupIfIdentifyingCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupIfIdentifying_t * payload);
+ } addGroupIfIdentifyingCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupResponse_t * payload);
+ } addGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroupResponse_t * payload);
+ } viewGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembershipResponse_t * payload);
+ } getGroupMembershipResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroupResponse_t * payload);
+ } removeGroupResponseCommand;
+} ZCL_GroupsClusterCommands_t;
+
+#endif /* _ZCLGROUPSCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h
new file mode 100644
index 00000000..afcc9f94
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ \file zclHumidityMeasurement.h
+
+ \brief
+ The file describes the types and interface of the
+ Relative Humidity Measurement cluster.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 18.01.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _ZCLHUMIDITYMEASUREMENT_H_
+#define _ZCLHUMIDITYMEASUREMENT_H_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <types.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+* \brief server attributes amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 3
+
+/**
+* \brief server commands amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+/**
+* \brief client attributes amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+* \brief client commands amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+
+/**
+* \brief Supported attribue id
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+
+/**
+ * \brief server define attributes macros
+*/
+#define ZCL_DEFINE_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES(reportMin, reportMax) \
+ DEFINE_REPORTABLE_ATTRIBUTE(measuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID, reportMin, reportMax), \
+ DEFINE_ATTRIBUTE(minMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(maxMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_HUMIDITY_MEASUREMENT_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = HUMIDITY_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) (clattributes), \
+ .commandsAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define ZCL_DEFINE_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT() \
+ { \
+ .id = HUMIDITY_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK {
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint16_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } measuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } minMeasuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } maxMeasuredValue ;
+} ZCL_HumidityMeasurementClusterAttributes_t ;
+END_PACK
+
+
+#endif /* _ZCLHUMIDITYMEASUREMENT_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h
new file mode 100644
index 00000000..a1294c6a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h
@@ -0,0 +1,178 @@
+/***************************************************************************//**
+ \file zclIdentifyCluster.h
+
+ \brief
+ The header file describes the ZCL Identify Cluster and its interface
+
+ The file describes the types and interface of the ZCL Identify Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 11.03.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLIDENTIFYCLUSTER_H
+#define _ZCLIDENTIFYCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Identify Server Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Identify Client Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Identify Client Cluster commands amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT 3
+
+/**
+ * \brief Identify Server Cluster attributes identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Identify Server Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_RESPONSE_COMMAND_ID 0x00
+
+/**
+ * \brief Identify Client Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_COMMAND_ID 0x00
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_COMMAND_ID 0x01
+
+/*
+ *\brief ZCL Idetify Cluster server side attributes defining macros
+ */
+
+#define ZCL_DEFINE_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(identifyTime, ZCL_READWRITE_ATTRIBUTE, ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/*
+ * \brief ZCL Identify Cluster commands defining macros
+ */
+
+#define IDENTIFY_CLUSTER_COMMANDS(identifyCommandInd, identifyQueryCommandInd, identifyQueryResponseCommandInd) \
+ DEFINE_COMMAND(identifyCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyCommandInd), \
+ DEFINE_COMMAND(identifyQueryCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryCommandInd), \
+ DEFINE_COMMAND(identifyQueryResponseCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryResponseCommandInd)
+
+#define IDENTIFY_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define IDENTIFY_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define DEFINE_IDENTIFY_CLUSTER(cltype, clattributes, clcommands) IDENTIFY_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief Identify Command Payload format.
+*/
+typedef struct PACK
+{
+ uint16_t identifyTime;
+} ZCL_Identify_t;
+
+/**
+ * \brief Identify Query Response Payload format.
+*/
+
+typedef struct PACK
+{
+ uint16_t timeout;
+} ZCL_IdentifyQueryResponse_t;
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } identifyTime;
+} ZCL_IdentifyClusterAttributes_t;
+
+END_PACK
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_Identify_t *payload);
+ } identifyCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } identifyQueryCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_IdentifyQueryResponse_t *payload);
+ } identifyQueryResponseCommand;
+} ZCL_IdentifyClusterCommands_t;
+
+
+#endif
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h
new file mode 100644
index 00000000..d984f38f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h
@@ -0,0 +1,46 @@
+/************************************************************************//**
+ \file zcl.h
+
+ \brief
+ The header file describes internal ZCL interface
+
+ The header file describes internal ZCL interface and types
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 09.12.08 I. Fedina - Created.
+******************************************************************************/
+
+#ifndef _ZCLINT_H
+#define _ZCLINT_H
+
+#include <zcl.h>
+#include <clusters.h>
+
+BEGIN_PACK
+typedef struct PACK
+{
+ uint8_t status;
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t value[1];
+} ZclReadAttributeResp_t;
+
+typedef struct PACK
+{
+ uint8_t status;
+ ZCL_AttributeId_t id;
+} ZclWriteAttributeResp_t;
+END_PACK
+
+uint8_t zclGetSequenceNumber(Endpoint_t endpointId);
+ZclAttribute_t *zclGetNextAttribute(Endpoint_t endpoint, ClusterId_t clusterId, uint8_t direction, ZclAttribute_t *currentAttribute);
+
+#endif // _ZCL_INT_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h
new file mode 100644
index 00000000..4c9f843f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h
@@ -0,0 +1,529 @@
+/***************************************************************************//**
+ \file zclKeyEstablishmentCluster.h
+
+ \brief
+ The header file describes the ZCL Key Establishment Cluster and its interface
+
+ The file describes the types and interface of the ZCL Key Establishment Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 10.03.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLKEYESTABLISHMENTCLUSTER_H
+#define _ZCLKEYESTABLISHMENTCLUSTER_H
+
+/*!
+Attributes and commands necessary for managing secure communication between
+ZigBee devices.
+*/
+
+#ifdef _ZCL_SECURITY_
+#ifdef _CERTICOM_SECURITY_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+#include <zclSecurityManager.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define ZCL_KE_INVALID_ENDPOINT APS_ZDO_ENDPOINT
+#define ZCL_KE_INVALID_SHORT_ADDRESS 0xffff
+#define ZCL_KE_INVALID_EXT_ADDRESS 0xffffffffffffffffLL
+
+
+//KE Cluster timeout settings
+#ifndef ZCL_KE_EPHEMERAL_DATA_GENERATE_TIME
+#define ZCL_KE_EPHEMERAL_DATA_GENERATE_TIME 0x10
+#endif
+
+#ifndef ZCL_KE_CONFIRM_KEY_GENERATE_TIME
+#define ZCL_KE_CONFIRM_KEY_GENERATE_TIME 0x10
+#endif
+
+//!This timeout (seconds) will be sent in Terminate KE Command
+#ifndef ZCL_KE_TERMINATE_KE_TIMEOUT
+#define ZCL_KE_TERMINATE_KE_TIMEOUT 50
+#endif
+
+//!This timeout (seconds) will be applied for commands receive wating with unspecified timeouts
+#ifndef ZCL_KE_TIMEOUT
+#define ZCL_KE_TIMEOUT 50
+#endif
+
+
+
+
+
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster server side attributes amount
+*******************************************************************************/
+#define ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster client side attributes amount
+*******************************************************************************/
+#define ZCL_KE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 1
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster commands amount
+*******************************************************************************/
+#define ZCL_KE_CLUSTER_COMMANDS_AMOUNT 8
+
+//!Key Establishment Suite Attribute
+#define ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+//!Key Establishment Suite Attribute
+#define ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+
+#define ZCL_KE_INITIATE_KEY_ESTABLISHMENT_REQUEST_COMMAND_ID 0x00
+#define ZCL_KE_EPHEMERAL_DATA_REQUEST_COMMAND_ID 0x01
+#define ZCL_KE_CONFIRM_KEY_DATA_REQUEST_COMMAND_ID 0x02
+#define ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID 0x03
+
+#define ZCL_KE_INITIATE_KEY_ESTABLISHMENT_RESPONSE_COMMAND_ID 0x00
+#define ZCL_KE_EPHEMERAL_DATA_RESPONSE_COMMAND_ID 0x01
+#define ZCL_KE_CONFIRM_KEY_DATA_RESPONSE_COMMAND_ID 0x02
+
+
+#define ZCL_KE_CBKE_ECMQV_KEY_ESTABLISHMENT_SUITE_ID 0x0001
+
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Key Establishment Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Key Establishment Cluster server side related attributes
+ ZCL_EKClusterServerAttributes_t ekClusterServerAttributes = ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES() \
+ {DEFINE_ATTRIBUTE(keyEstablishmentSuite, ZCL_READONLY_ATTRIBUTE, ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID, ZCL_16BIT_ENUM_DATA_TYPE_ID)}
+
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster client side attributes defining macros
+
+ This macros should be used for ZCL Key Establishment Cluster client side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Key Establishment Cluster client side related attributes
+ ZCL_EKClusterClientAttributes_t ekClusterClientAttributes = ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES() \
+ {DEFINE_ATTRIBUTE(keyEstablishmentSuite, ZCL_READONLY_ATTRIBUTE, ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID, ZCL_16BIT_ENUM_DATA_TYPE_ID)}
+
+#define DEFINE_INITIATE_KEY_ESTABLISHMENT_REQUEST(initiateKeyEstablishmentReqInd) \
+ DEFINE_COMMAND(initiateKeyEstablishmentReq, ZCL_KE_INITIATE_KEY_ESTABLISHMENT_REQUEST_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ initiateKeyEstablishmentReqInd)
+
+#define DEFINE_INITIATE_KEY_ESTABLISHMENT_RESPONSE(initiateKeyEstablishmentRespInd) \
+ DEFINE_COMMAND(initiateKeyEstablishmentResp, ZCL_KE_INITIATE_KEY_ESTABLISHMENT_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ initiateKeyEstablishmentRespInd)
+
+#define DEFINE_EPHEMERAL_DATA_REQUEST(ephemeralDataReqInd) \
+ DEFINE_COMMAND(ephemeralDataReq, ZCL_KE_EPHEMERAL_DATA_REQUEST_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ ephemeralDataReqInd)
+
+#define DEFINE_EPHEMERAL_DATA_RESPONSE(ephemeralDataRespInd) \
+ DEFINE_COMMAND(ephemeralDataResp, ZCL_KE_EPHEMERAL_DATA_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ ephemeralDataRespInd)
+
+#define DEFINE_CONFIRM_KEY_DATA_REQUEST(confirmKeyDataReqInd) \
+ DEFINE_COMMAND(confirmKeyDataReq, ZCL_KE_CONFIRM_KEY_DATA_REQUEST_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ confirmKeyDataReqInd)
+
+#define DEFINE_CONFIRM_KEY_DATA_RESPONSE(confirmKeyDataRespInd) \
+ DEFINE_COMMAND(confirmKeyDataResp, ZCL_KE_CONFIRM_KEY_DATA_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ confirmKeyDataRespInd)
+
+#define DEFINE_TERMINATE_KEY_ESTABLISHMENT_SERVER_PART(terminateKeyEstablishmentReqIndServerPart) \
+ DEFINE_COMMAND(terminateKeyEstablishmentReqServerPart, ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ terminateKeyEstablishmentReqIndServerPart)
+
+#define DEFINE_TERMINATE_KEY_ESTABLISHMENT_CLIENT_PART(terminateKeyEstablishmentReqIndClientPart) \
+ DEFINE_COMMAND(terminateKeyEstablishmentReqClientPart, ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ terminateKeyEstablishmentReqIndClientPart)
+
+#define KE_CLUSTER_COMMANDS(initiateKeyEstablishmentReqInd, initiateKeyEstablishmentRespInd, \
+ ephemeralDataReqInd, ephemeralDataRespInd, confirmKeyDataReqInd, confirmKeyDataRespInd, \
+ terminateKeyEstablishmentReqIndServerPart, terminateKeyEstablishmentReqIndClientPart) \
+ DEFINE_INITIATE_KEY_ESTABLISHMENT_REQUEST(initiateKeyEstablishmentReqInd), \
+ DEFINE_INITIATE_KEY_ESTABLISHMENT_RESPONSE(initiateKeyEstablishmentRespInd), \
+ DEFINE_EPHEMERAL_DATA_REQUEST(ephemeralDataReqInd), \
+ DEFINE_EPHEMERAL_DATA_RESPONSE(ephemeralDataRespInd), \
+ DEFINE_CONFIRM_KEY_DATA_REQUEST(confirmKeyDataReqInd), \
+ DEFINE_CONFIRM_KEY_DATA_RESPONSE(confirmKeyDataRespInd), \
+ DEFINE_TERMINATE_KEY_ESTABLISHMENT_SERVER_PART(terminateKeyEstablishmentReqIndServerPart), \
+ DEFINE_TERMINATE_KEY_ESTABLISHMENT_CLIENT_PART(terminateKeyEstablishmentReqIndClientPart) \
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster server side defining macros
+
+ This macros should be used with #ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES and
+ #ZCL_DEFINE_EK_CLUSTER_SERVER_COMMANDS for ZCL Key Establishment Cluster server
+ side defining.
+
+ \param attributes - pointer to cluster server attributes (ZCL_KEClusterServerAttributes_t)
+ \param commands - pointer to cluster server commands (ZCL_KEServerCommands_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Key Establishment Cluster server side related attributes and commands
+ ZCL_KEClusterServerAttributes_t keClusterServerAttributes = ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_KEClusterServerCommands_t keClusterServerCommands = ZCL_DEFINE_EK_CLUSTER_SERVER_COMMANDS(handler1, handler2, handler3, handlerv);
+ ZCL_Cluster_t ekClusterServer = ZCL_DEFINE_KE_CLUSTER_SERVER(&keClusterServerAttributes, &keClusterServerCommands);
+*******************************************************************************/
+#define ZCL_DEFINE_KE_CLUSTER_SERVER(clattributes, clcommands) \
+ { \
+ .id = ZCL_KEY_ESTABLISHMENT_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_KE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster client side defining macros
+
+ This macros should be used with #ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES and
+ #ZCL_DEFINE_EK_CLUSTER_CLIENT_COMMANDS for ZCL Key Establishment Cluster client
+ side defining.
+
+ \param attributes - pointer to cluster client attributes (ZCL_KEClusterClientAttributes_t)
+ \param commands - pointer to cluster client commands (ZCL_KEClientCommands_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Key Establishment Cluster client side related attributes and commands
+ ZCL_KEClusterClientAttributes_t keClusterClientAttributes = ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES();
+ ZCL_KEClusterClientCommands_t keClusterClientCommands = ZCL_DEFINE_EK_CLUSTER_CLIENT_COMMANDS(handler1, handler2, handler3, handlerv);
+ ZCL_Cluster_t ekClusterClient = ZCL_DEFINE_KE_CLUSTER_Client(&keClusterClientAttributes, &keClusterClientCommands);
+*******************************************************************************/
+#define ZCL_DEFINE_KE_CLUSTER_CLIENT(clattributes, clcommands) \
+ { \
+ .id = ZCL_KEY_ESTABLISHMENT_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_KE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Key Establishment Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Information attribute set (Id == 0x00)
+
+ /*!KeyEstablishmentSuite attribute (Read only, M)
+ The KeyEstablishmentSuite attribute is 16-bits in length and specifies all the
+ cryptographic schemes for key establishment on the device. A device shall set the
+ corresponding bit to 1 for every cryptographic scheme that is supports. All other
+ cryptographic schemes and reserved bits shall be set to 0.
+
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (16-bit enumeration, #ZZCL_16BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint16_t value; //!<Attribute value (default 0x0000)
+ } keyEstablishmentSuite;
+} ZCL_KEClusterServerAttributes_t;
+END_PACK
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Key Establishment Cluster client side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Information attribute set (Id == 0x00)
+
+ /*!KeyEstablishmentSuite attribute (Read only, M)
+ The KeyEstablishmentSuite attribute is 16-bits in length and specifies all the
+ cryptographic schemes for key establishment on the device. A device shall set the
+ corresponding bit to 1 for every cryptographic scheme that is supports. All other
+ cryptographic schemes and reserved bits shall be set to 0.
+
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (16-bit enumeration, #ZZCL_16BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint16_t value; //!<Attribute value (default 0x0000)
+ } keyEstablishmentSuite;
+} ZCL_KEClusterClientAttributes_t;
+END_PACK
+
+
+BEGIN_PACK
+
+/***************************************************************************//**
+ \brief
+ ZCL Initiate Key Establishment command
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!This will be type of KeyEstablishment that the initiator is requesting for
+ the Key Establishment Cluster. For CBKE-ECMQV this will be 0x0001.
+ */
+ uint16_t keyEstablishmentSuite;
+ /*!This value indicates approximately how long the initiator device will take
+ in seconds to generate the Ephemeral Data Request command. The valid range is
+ 0x00 to 0xFE.
+ */
+ uint8_t ephemeralDataGenerateTime;
+ /*!This value indicates approximately how long the initiator device will take
+ in seconds to generate the Confirm Key Request command. The valid range is
+ 0x00 to 0xFE.
+ */
+ uint8_t confirmKeyGenerateTime;
+ /*!For keyEstablishmentSuite = 0x0001 (CBKE), the identify field shall be the
+ block of octets containing the implicit certificate CERTU.
+ */
+ uint8_t identify[48];
+} ZCL_InitiateKeyEstablishmentCommand_t;
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Confirm Key Request and ZCL Confirm Key Response commands
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!Secure Message Authentication Code field which shall be the octet-string
+ representation of MACU or MACV.
+ */
+ uint8_t mac[16];
+} ZCL_ConfirmKeyCommand_t;
+
+
+typedef enum
+{
+ //0x00 - Reserved
+
+ /*!The Issuer field whithin the key establishment partner's certificate is
+ unknown to the sending device, and it has terminated the key establishment.
+ */
+ ZCL_TKE_UNKNOWN_ISSUER_STATUS = 0x01,
+ /*!The device could not confirm that is shares the same key with the
+ corresponding device and has terminated the key establishment.
+ */
+ ZCL_TKE_BAD_KEY_CONFIRM_STATUS = 0x02,
+ /*!The device received a bad messagefrom the corresponding device (e.g. message
+ whith bad data, an out of sequence number, or a message with a bad format)
+ and has terminated the key establishment.
+ */
+ ZCL_TKE_BAD_MESSAGE_STATUS = 0x03,
+ /*!The device does not currently have the internal resources necessary to
+ perform key establishment and has terminated the exchange.
+ */
+ ZCL_TKE_NO_RESOURCES_STATUS = 0x04,
+ /*!The device does not support the specified key establishment suite in the
+ partner's Initiate Key Establishment message.
+ */
+ ZCL_TKE_UNSUPPORTED_SUITE_STATUS = 0x05,
+
+ /*For internal use only*/
+ ZCL_TKE_NO_STATUS = 0xff
+ //0x06 - 0xFF - Reserved
+} ZCL_TKEStatus_t;
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Terminate Key Establishment command
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ Status code indicates the key establishment termination reason.
+ #ZCL_TEKStatus_t values should be used.
+ */
+ uint8_t statusCode;
+ /*!This value indicates the minimum amount of time in seconds the initiator
+ device should wait befor trying to initiate key establishment again. The valid
+ range is 0x00 to 0xFE.
+ */
+ uint8_t waitTime;
+ /*!This value will be set the value of the KeyEstablishmentSuite attribute.
+ It indicates the list of key exchange methods that the device supports.
+ */
+ uint16_t keyEstablishmentSuite;
+} ZCL_TerminateKeyEstablishmentCommand_t;
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Ephemeral Data Request and ZCL Ephemeral Data Request commands
+
+ The Ephemeral Data Request command allows a device to communicate its
+ ephemeral data to another device and request that the device send back
+ its own ephemeral data.
+
+ The Ephemeral Data Response command allows a device to communicate its
+ ephemeral data to another device and request that the device send back
+ its own ephemeral data.
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ Ephemeral Data (QEU, QEV)
+ */
+ uint8_t data[22];
+} ZCL_EphemeralDataCommand_t;
+
+END_PACK
+
+/***************************************************************************//**
+ \brief
+ ZCL Key Establishment Cluster Commands
+*******************************************************************************/
+typedef struct
+{
+ //!Initiate Key Establishment Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_InitiateKeyEstablishmentCommand_t *payload);
+ } initiateKeyEstablishmentReq;
+
+ //!Initiate Key Establishment Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_InitiateKeyEstablishmentCommand_t *payload);
+ } initiateKeyEstablishmentResp;
+
+ //!Ephemeral Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EphemeralDataCommand_t *payload);
+ } ephemeralDataReq;
+
+ //!Ephemeral Data Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EphemeralDataCommand_t *payload);
+ } ephemeralDataResp;
+
+ //!Confirm Key Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ConfirmKeyCommand_t *payload);
+ } confirmKeyDataReq;
+
+ //!Confirm Key Data Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ConfirmKeyCommand_t *payload);
+ } confirmKeyDataResp;
+
+ //!Terminate Key Establishment Command descriptor (server part)
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TerminateKeyEstablishmentCommand_t *payload);
+ } terminateKeyEstablishmentReqServerPart;
+
+ //!Terminate Key Establishment Command descriptor (client part)
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TerminateKeyEstablishmentCommand_t *payload);
+ } terminateKeyEstablishmentReqClientPart;
+} ZCL_KEClusterCommands_t;
+
+/***************************************************************************//**
+ \brief Finds KE Certificate descriptor for the device with particular address
+
+ \param subject - device's address which certificate is looking for
+ \return pointer to KE Certificate descriptor if it was found, NULL otherwise
+*******************************************************************************/
+ZclCertificate_t *keGetCertificate(ExtAddr_t subject);
+
+/*************************************************************************************//**
+\brief Return server or client cluster descriptor for external use.
+
+Use this function if you want register KE cluster on endpoint.
+
+\param[in] server - If true returns server descriptor otherwise client descriptor.
+******************************************************************************************/
+ZCL_Cluster_t* keGetClusterDescriptor(uint8_t server);
+
+#endif //#ifdef _CERTICOM_SECURITY_
+#endif //#ifdef _ZCL_SECURITY_
+#endif //#ifndef _ZCLKEYESTABLISHMENTCLUSTER_H
+
+//eof zclKeyEstablishmentCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h
new file mode 100644
index 00000000..827ce9d7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h
@@ -0,0 +1,286 @@
+/***************************************************************************//**
+ \file zclLevelControlCluster.h
+
+ \brief
+ Interface and types of Level Control Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 22.06.10 D.Loskutnikov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLLEVELCONTROLCLUSTER_H
+#define _ZCLLEVELCONTROLCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Amount of Level Control cluster server's attributes
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Client doesn't have attributes.
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Level Control Cluster commands amount
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT 8
+
+/**
+ * \brief Level Control Cluster server's attributes identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID 0x00
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID 0x01
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID 0x02
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID 0x03
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID 0x04
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID 0x05
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID 0x06
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID 0x07
+
+/**
+ * \brief Level Control Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_MANDATORY_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(currentLevel, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID, min, max)
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_OPTIONAL_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(remainingTime, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onOffTransitionTime, ZCL_READWRITE_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onLevel, ZCL_READWRITE_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID)
+
+
+/**
+ * \brief Level Control Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_COMMANDS(moveToLevelCommandInd,\
+ moveCommandInd,\
+ stepCommandInd,\
+ stopCommandInd,\
+ moveToLevelWOnOffCommandInd,\
+ moveWOnOffCommandInd,\
+ stepWOnOffCommandInd,\
+ stopWOnOffCommandInd)\
+ DEFINE_COMMAND(moveToLevelCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelCommandInd), \
+ DEFINE_COMMAND(moveCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveCommandInd), \
+ DEFINE_COMMAND(stepCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepCommandInd), \
+ DEFINE_COMMAND(stopCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopCommandInd), \
+ DEFINE_COMMAND(moveToLevelWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelWOnOffCommandInd), \
+ DEFINE_COMMAND(moveWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveWOnOffCommandInd), \
+ DEFINE_COMMAND(stepWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepWOnOffCommandInd), \
+ DEFINE_COMMAND(stopWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopWOnOffCommandInd)
+
+/**
+ * \brief Level Control Cluster definition macros
+*/
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER(cltype, clattributes, clcommands) \
+ LEVEL_CONTROL_CLUSTER_##cltype(clattributes, clcommands)
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = LEVEL_CONTROL_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .currentLevel = value
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Move To Level Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t level;
+ uint16_t transitionTime;
+} ZCL_MoveToLevel_t;
+
+/**
+ * \brief Move Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_Move_t;
+
+/**
+ * \brief Step Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint16_t transitionTime;
+} ZCL_Step_t;
+
+/**
+ * \brief Level Control Cluster server's attributes
+*/
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } currentLevel;
+} ZCL_LevelControlClusterServerAttributes_t;
+
+/**
+ * \brief Level Control Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ uint8_t currentLevel;
+} ZCL_LevelControlSceneExtensionFields_t;
+
+END_PACK
+
+/**
+ * \brief Level Control Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopWOnOffCommand;
+} ZCL_LevelControlClusterCommands_t;
+
+#endif /* _ZCLLEVELCONTROLCLUSTER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h
new file mode 100644
index 00000000..01321f26
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h
@@ -0,0 +1,62 @@
+/************************************************************************//**
+ \file zclMem.h
+
+ \brief
+ The header file describes the ZCL memory structure
+
+ The file describes the structure of ZCL memory
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 03.12.08 I. Fedina - Created.
+******************************************************************************/
+
+#ifndef _ZCLMEM_H
+#define _ZCLMEM_H
+
+#include <queue.h>
+#include <appTimer.h>
+
+typedef enum
+{
+ ZCL_IDLE_STATE,
+ ZCL_REQUEST_STATE,
+ ZCL_WAITING_FOR_CONFIRM_STATE,
+ ZCL_WAITING_FOR_RESPONSE_STATE,
+ ZCL_CONFIRM_STATE,
+} ZclState_t;
+
+
+/*
+ * Describes ZCL memory structure
+ * */
+typedef struct
+{
+ ZclState_t state;
+ QueueDescriptor_t requestQueue;
+ uint8_t *request;
+ HAL_AppTimer_t waitTimer;
+ HAL_AppTimer_t reportTimer;
+} ZclMem_t;
+
+/*
+ * ZCL memory global object
+ * */
+extern ZclMem_t zclMem;
+
+/*
+ * Function returns point to ZCL memory object
+ * */
+static inline ZclMem_t * zclMemReq()
+{
+ return ((ZclMem_t *)&zclMem);
+}
+
+#endif // _ZCLMEM_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h
new file mode 100644
index 00000000..46017dc4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h
@@ -0,0 +1,90 @@
+/************************************************************************//**
+ \file zclMemoryManager.h
+
+ \brief
+ The header file describes the ZCL Memory Manager interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 27.11.08 A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLMEMORYMANAGER_H
+#define _ZCLMEMORYMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <aps.h>
+#include <appFramework.h>
+#include <macAddr.h>
+#include <zcl.h>
+#include <dbg.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef union
+{
+ APS_DataReq_t apsDataReq;
+ APS_DataInd_t apsDataInd;
+} ZclMmPrimitive_t;
+
+typedef struct
+{
+ TOP_GUARD
+ uint8_t header[APS_ASDU_OFFSET]; // Auxiliary header (required by stack)
+ uint8_t asdu[ZCL_MAX_ASDU_SIZE]; // ASDU content
+#if (APS_AFFIX_LENGTH - APS_ASDU_OFFSET)
+ uint8_t footer[APS_AFFIX_LENGTH - APS_ASDU_OFFSET]; //Auxiliary footer (required by stack)
+#endif
+ BOTTOM_GUARD
+} ZclMmFrame_t;
+
+typedef enum
+{
+ ZCL_MM_BUFFER_FREE = 0x00,
+ ZCL_MM_BUFFER_BUSY = 0x01
+} ZclMmBufferBusy_t;
+
+typedef struct
+{
+ ZclMmPrimitive_t primitive;
+ ZclMmFrame_t frame;
+} ZclMmBuffer_t;
+
+typedef struct
+{
+ uint8_t busy; //ZclMmBufferBusy_t should be used
+ ZclMmBuffer_t buf;
+} ZclMmBufferDescriptor_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+\brief Looks for and return free zcl memory buffer
+
+\return pointer to memory buffer or NULL if there is no free buffer.
+*****************************************************************************/
+ZclMmBuffer_t *zclMmGetMem(void);
+
+/*************************************************************************//**
+\brief Makes free zcl busy buffer
+
+\param[in] mem - pointer to used zcl buffer
+*****************************************************************************/
+void zclMmFreeMem(ZclMmBuffer_t *mem);
+
+#endif //#ifndef _ZCLMEMORYMANAGER_H
+
+
+//eof zclMemoryManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h
new file mode 100644
index 00000000..4e0e11cb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h
@@ -0,0 +1,185 @@
+/************************************************************************//**
+ \file zclMessageingCluster.h
+
+ \brief
+ The header file describes the ZCL Message Cluster
+
+ The header file describes the ZCL Message Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 27.11.08 A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _MESSAGINGCLUSTER_H
+#define _MESSAGINGCLUSTER_H
+
+#include <zcl.h>
+#include <clusters.h>
+/*******************************************************************************
+ Defines section
+ ******************************************************************************/
+/***************************************************************************//**
+\brief Macros defines duration value of Display Message command,
+ * which means 'until change'.
+ * According to ZB AMI Spec r15, D.5.2.3.1.1.1, page 203.
+*******************************************************************************/
+#define DISPLAY_MESSAGE_DURATION_UNTIL_CHANGED 0xFFFF
+
+/*************************************************************************//**
+ \brief Message Cluster attributes amount
+*****************************************************************************/
+#define MESSAGE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+#define MESSAGE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/*************************************************************************//**
+ \brief Message Cluster commands amount
+*****************************************************************************/
+#define MESSAGE_CLUSTER_COMMANDS_AMOUNT 4
+
+#define DISPLAY_MESSAGE_COMMAND_ID 0x00
+#define CANCEL_MESSAGE_COMMAND_ID 0x01
+#define GET_LAST_MESSAGE_COMMAND_ID 0x00
+#define CONFIRM_MESSAGE_COMMAND_ID 0x01
+
+#define DEFINE_MESSAGING_CLUSTER_COMMANDS(clDisplayMessageInd, clCancelMessageInd, clGetLastMessageInd, clMessageConfirmationInd) \
+ DEFINE_COMMAND(displayMessageCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clDisplayMessageInd), \
+ DEFINE_COMMAND(cancelMessageCommand, 0x01, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clCancelMessageInd), \
+ DEFINE_COMMAND(getLastMessageCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clGetLastMessageInd), \
+ DEFINE_COMMAND(messageConfirmationCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clMessageConfirmationInd)
+
+#define MESSAGING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = MESSAGE_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = MESSAGE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = MESSAGE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define MESSAGING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = MESSAGE_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = MESSAGE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = MESSAGE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+#define DEFINE_MESSAGING_CLUSTER(cltype, clattributes, clcommands) MESSAGING_CLUSTER_##cltype(clattributes, clcommands)
+
+BEGIN_PACK
+
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(4,(
+ uint8_t transmissionType : 2,
+ uint8_t importanceLevel : 2,
+ uint8_t reserved : 3,
+ uint8_t messageConfirmation : 1
+ ))
+} MessageControl_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL Messaging Cluster Display Message Command payload format
+*******************************************************************************/
+typedef struct PACK
+{
+ uint32_t messageId; //!<Message Id (Unsignet 32 bit Integer)
+ MessageControl_t messageControl; //!<Message Control (8-bit Bitmap)
+ uint32_t startTime; //!<Start Time (UTCTime)
+ uint16_t duration; //!<Duration In Minutes (Unsigned 16-bit Integer)
+ uint8_t message[1]; //!<Message (Character string)
+} DisplayMessage_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL Messaging Cluster Cancel Message Command payload format
+*******************************************************************************/
+typedef struct PACK
+{
+ uint32_t messageId; //!<Message Id (Unsignet 32 bit Integer)
+ MessageControl_t messageControl; //!<Message Control (8-bit Bitmap)
+} CancelMessage_t;
+
+typedef struct PACK
+{
+ uint32_t messageId;
+ ZCL_UTCTime_t confirmationTime;
+}MessageConfirmation_t;
+END_PACK
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Messaging Cluster Commands
+*******************************************************************************/
+typedef struct
+{
+ //!Display Message Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*displayMessage)(ZCL_Addressing_t *addressing, uint8_t payloadLength, DisplayMessage_t *payload);
+ } displayMessageCommand;
+
+ //!Cancel Message Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*cancelMessage)(ZCL_Addressing_t *addressing, uint8_t payloadLength, CancelMessage_t *payload);
+ } cancelMessageCommand;
+ //!Get Last Message Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*getLastMessage)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void *payload);
+ } getLastMessageCommand;
+ //!Message Confirmation Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*messageConfirmation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, MessageConfirmation_t *payload);
+ } messageConfirmationCommand;
+} MessagingClusterCommands_t;
+
+
+
+#endif // _MESSAGINGCLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h
new file mode 100644
index 00000000..32b0b9d0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h
@@ -0,0 +1,564 @@
+/**************************************************************************//**
+ \file zclOTAUCluster.h
+
+ \brief The header file describes the OTAU cluster interface.
+ ZigBee Document 095264r17.
+ Revision 17 Version 0.7 March 14, 2010
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 15.01.10 A. Khromykh - Created.
+*******************************************************************************/
+#ifndef _ZCLOTAUCLUSTER_H
+#define _ZCLOTAUCLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+#include <ofdExtMemory.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+//#define _OTAU_DEBUG_
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster atrebutes
+*******************************************************************************/
+#define ZCL_OTAU_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+#define ZCL_OTAU_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 2
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster commands amount
+*******************************************************************************/
+#define ZCL_OTAU_CLUSTER_COMMANDS_AMOUNT 7
+
+//!ZCL OTAU Cluster client side attributes id
+#define ZCL_OTAU_CLUSTER_CLIENT_UPGRADE_SERVER_ID 0x0000
+#define ZCL_OTAU_CLUSTER_CLIENT_IMAGE_UPGRADE_STATUS_ID 0x0006
+
+#define DEFINE_OTAU_CLIENT_ATTRIBUTES \
+ DEFINE_ATTRIBUTE(upgradeServerIEEEAddr, ZCL_READONLY_ATTRIBUTE, ZCL_OTAU_CLUSTER_CLIENT_UPGRADE_SERVER_ID, ZCL_IEEE_ADDRESS_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(imageUpgradeStatus, ZCL_READONLY_ATTRIBUTE, ZCL_OTAU_CLUSTER_CLIENT_IMAGE_UPGRADE_STATUS_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+#define OTAU_HEADER_STRING_SIZE 32
+
+// OTAU commands
+// list of commands id
+#define QUERY_NEXT_IMAGE_REQUEST_ID 0x01
+#define QUERY_NEXT_IMAGE_RESPONSE_ID 0x02
+#define IMAGE_BLOCK_REQUEST_ID 0x03
+#define IMAGE_PAGE_REQUEST_ID 0x04
+#define IMAGE_BLOCK_RESPONSE_ID 0x05
+#define UPGRADE_END_REQUEST_ID 0x06
+#define UPGRADE_END_RESPONSE_ID 0x07
+
+#define DEFINE_QUERY_NEXT_IMAGE_REQUEST(queryNextImageReqInd) \
+ DEFINE_COMMAND(queryNextImageReq, QUERY_NEXT_IMAGE_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ queryNextImageReqInd)
+
+#define DEFINE_QUERY_NEXT_IMAGE_RESPONSE(queryNextImageRespInd) \
+ DEFINE_COMMAND(queryNextImageResp, QUERY_NEXT_IMAGE_RESPONSE_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ queryNextImageRespInd)
+
+#define DEFINE_IMAGE_BLOCK_REQUEST(imageBlockReqInd) \
+ DEFINE_COMMAND(imageBlockReq, IMAGE_BLOCK_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ imageBlockReqInd)
+
+#define DEFINE_IMAGE_PAGE_REQUEST(imagePageReqInd) \
+ DEFINE_COMMAND(imagePageReq, IMAGE_PAGE_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ imagePageReqInd)
+
+#define DEFINE_IMAGE_BLOCK_RESPONSE(imageBlockRespInd) \
+ DEFINE_COMMAND(imageBlockResp, IMAGE_BLOCK_RESPONSE_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ imageBlockRespInd)
+
+#define DEFINE_UPGRADE_END_REQUEST(upgradeEndReqInd) \
+ DEFINE_COMMAND(upgradeEndReq, UPGRADE_END_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ upgradeEndReqInd)
+
+#define DEFINE_UPGRADE_END_RESPONSE(upgradeEndRespInd) \
+ DEFINE_COMMAND(upgradeEndResp, UPGRADE_END_RESPONSE_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ upgradeEndRespInd)
+
+#define OTAU_COMMANDS(queryNextImageReqInd, queryNextImageRespInd, imageBlockReqInd, imagePageReqInd, \
+ imageBlockRespInd, upgradeEndReqInd, upgradeEndRespInd) \
+ DEFINE_QUERY_NEXT_IMAGE_REQUEST(queryNextImageReqInd), \
+ DEFINE_QUERY_NEXT_IMAGE_RESPONSE(queryNextImageRespInd), \
+ DEFINE_IMAGE_BLOCK_REQUEST(imageBlockReqInd), \
+ DEFINE_IMAGE_PAGE_REQUEST(imagePageReqInd), \
+ DEFINE_IMAGE_BLOCK_RESPONSE(imageBlockRespInd), \
+ DEFINE_UPGRADE_END_REQUEST(upgradeEndReqInd), \
+ DEFINE_UPGRADE_END_RESPONSE(upgradeEndRespInd)
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster server side defining macros
+
+ \param attributes - pointer to cluster server attributes (ZCL_OtauClusterClientAttributes_t)
+ or NULL if there are no attributes
+ \param clcommands - pointer to cluster server commands
+ or NULL if there are no commands
+
+ \return None
+*******************************************************************************/
+#define OTAU_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = OTAU_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_DEFAULT_CLUSTER_SECURITY, \
+ .reserved = 0}, \
+ .attributesAmount = ZCL_OTAU_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_OTAU_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster client side defining macros
+
+ \param attributes - pointer to cluster client attributes (ZCL_OtauClusterClientAttributes_t)
+ or NULL if there are no attributes
+ \param clcommands - pointer to cluster client commands
+ or NULL if there are no commands
+
+ \return None
+*******************************************************************************/
+#define OTAU_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = OTAU_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_DEFAULT_CLUSTER_SECURITY, \
+ .reserved = 0}, \
+ .attributesAmount = ZCL_OTAU_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_OTAU_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DEFINE_OTAU_CLUSTER(cltype, clattributes, clcommands) OTAU_CLUSTER_##cltype(clattributes, clcommands)
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+typedef uint8_t OtauHeaderString_t[OTAU_HEADER_STRING_SIZE];
+
+typedef enum PACK
+{
+ OTAU_SERVER_HAS_BEEN_FOUND,
+ OTAU_SERVER_HAS_NOT_BEEN_FOUND,
+ OTAU_SERVER_HAS_BEEN_LOST,
+ OTAU_OFD_DRIVER_ERROR,
+ OTAU_SERVER_RECEIVED_MALFORMED_COMMAND,
+ OTAU_SERVER_NO_IMAGE_AVAILABLE,
+ OTAU_SERVER_RECEIVED_UNSUPPORTED_COMMAND,
+ OTAU_SERVER_RECEIVED_UNKNOWN_STATUS,
+ OTAU_SERVER_IS_NOT_AUTHORIZED_TO_UPDATE,
+ OTAU_DOWNLOAD_STARTED,
+ OTAU_DOWNLOAD_ABORTED,
+ OTAU_DOWNLOAD_FINISHED,
+ OTAU_DEVICE_SHALL_CHANGE_IMAGE,
+ OTAU_ISD_IMAGE_CACHE_IS_FOUND,
+ OTAU_ISD_HARDWARE_FAULT,
+ OTAU_ISD_COMMUNICATION_LOST,
+ OTAU_MAX_MESSAGE_NUMBER
+} ZCL_OtauAction_t;
+
+typedef void (* ZCL_OtauStatInd_t)(ZCL_OtauAction_t action);
+
+typedef enum
+{
+ OTAU_ZB_STACK_VERSION_2006 = 0x0000,
+ OTAU_ZB_STACK_VERSION_2007 = 0x0001,
+ OTAU_ZB_STACK_VERSION_PRO = 0x0002,
+ OTAU_ZB_STACK_VERSION_IP = 0x0003,
+ OTAU_FAKE_VERSION = 0xFFFF
+} ZCL_OtauZigbeeStackVersion_t;
+
+typedef enum
+{
+ OTAU_SPECIFIC_IMAGE_TYPE = 0x0000,
+ OTAU_SECURITY_CREDENTIAL_TYPE = 0xFFC0,
+ OTAU_CONFIGURATION_TYPE = 0xFFC1,
+ OTAU_LOG_TYPE = 0xFFC2,
+ OTAU_WILD_CARD_TYPE = 0xFFFF
+} ZCL_OtauImageType_t;
+
+typedef enum
+{
+ OTAU_UPGRADE_IMAGE = 0x0000,
+ OTAU_ECDSA_SIGNATURE = 0x0001,
+ OTAU_ECDSA_SIGNING_CERTIFICATE = 0x0002,
+ OTAU_FAKE_NUMBER = 0xFFFF
+} ZCL_OtauTagID_t;
+
+BEGIN_PACK
+typedef enum PACK
+{
+ OTAU_NORMAL,
+ OTAU_DOWNLOAD_IN_PROGRESS,
+ OTAU_DOWNLOAD_COMPLETE,
+ OTAU_WAITING_TO_UPGRADE,
+ OTAU_COUNT_DOWN,
+ OTAU_WAIT_FOR_MORE
+} ZCL_ImageUpdateStatus_t;
+
+typedef union PACK
+{
+ uint16_t memAlloc;
+ struct PACK
+ {
+ uint16_t securityCredentialVersionPresent : 1;
+ uint16_t deviceSpecificFile : 1;
+ uint16_t hardwareVersionPresent : 1;
+ uint16_t reserved : 13;
+ };
+} ZCL_OtauHeaderFieldControl_t;
+
+typedef struct PACK
+{
+ ZCL_OtauTagID_t tagID;
+ uint32_t lengthField;
+} ZCL_OtauSubElementHeader_t;
+
+typedef union PACK
+{
+ uint32_t memAlloc;
+ struct PACK
+ {
+ uint8_t appRelease;
+ uint8_t appBuild;
+ uint8_t stackRelease;
+ uint8_t stackBuild;
+ };
+} ZCL_OtauFirmwareVersion_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU upgrade image header
+*******************************************************************************/
+typedef struct PACK
+{
+ uint32_t magicNumber;
+ uint16_t headerVersion;
+ uint16_t headerLength;
+ ZCL_OtauHeaderFieldControl_t fieldControl;
+ uint16_t manufacturerId;
+ uint16_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ ZCL_OtauZigbeeStackVersion_t zigbeeStackVersion;
+ OtauHeaderString_t headerString;
+ uint32_t totalImageSize;
+} ZCL_OtauUpgradeImageHeader_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU Cluster attributes.
+ Currently, all attributes are client side attributes (only stored on the client).
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ \brief The attribute is used to store the IEEE address of the upgrade server
+ resulted from the discovery of the upgrade server's identity. If the value is set
+ to a non-zero value and corresponds to an IEEE address of a device that is no longer
+ accessible, a device may choose to discover a new Upgrade Server depending on its own
+ security policies. The attribute is mandatory because it serves as a placeholder in a case
+ where the client is programmed, during manufacturing time, its upgrade server ID.
+ In addition, the attribute is used to identify the current upgrade server the client is using
+ in a case where there are multiple upgrade servers in the network. The attribute is also helpful
+ in a case when a client has temporarily lost connection to the network (for example, via a reset
+ or a rejoin), it shall try to rediscover the upgrade server via network address discovery using
+ the IEEE address stored in the attribute. By default the value is 0xffffffffffffffff, which is
+ an invalid IEEE address. The attribute is a client-side attribute and stored on the client.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000)
+ uint8_t type; //!<Attribute type (ExtAddr_t - 64-bit) (typeId = 0xf0, #ZCL_IEEE_ADDRESS_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ ExtAddr_t value; //!<Attribute value (default none)
+ } upgradeServerIEEEAddr;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0006)
+ uint8_t type; //!<Attribute type (ZCL_ImageUpdateStatus_t - 8-bit enum) (typeId = 0x30)
+ uint8_t properties; //!<Attribute properties bitmask
+ ZCL_ImageUpdateStatus_t value; //!<Attribute value (default none)
+ } imageUpgradeStatus;
+} ZCL_OtauClusterClientAttributes_t;
+END_PACK
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU Cluster commands.
+*******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Control field of query next image request.
+*/
+typedef struct PACK
+{
+ uint8_t hardwareVersionPresent : 1;
+ uint8_t reserved : 7;
+} ZCL_QueryNextImageReqControlField_t;
+
+/**
+ * \brief Query Next Image Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_QueryNextImageReqControlField_t controlField;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t currentFirmwareVersion;
+} ZCL_OtauQueryNextImageReq_t;
+
+/**
+ * \brief Query Next Image Response Command.
+*/
+typedef struct PACK
+{
+ ZCL_Status_t status;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t currentFirmwareVersion;
+ uint32_t imageSize;
+} ZCL_OtauQueryNextImageResp_t;
+
+/**
+ * \brief Control field of image block request.
+*/
+typedef struct PACK
+{
+ uint8_t reqNodeIeeeAddrPresent : 1;
+ uint8_t reserved : 7;
+} ZCL_QueryImageBlockReqControlField_t;
+
+
+/**
+ * \brief Image Block Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_QueryImageBlockReqControlField_t controlField;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ uint32_t fileOffset;
+ uint8_t maxDataSize;
+} ZCL_OtauImageBlockReq_t;
+
+/**
+ * \brief Image Block Response Command.
+*/
+typedef struct PACK
+{
+ ZCL_Status_t status;
+ union PACK
+ {
+ struct PACK
+ {
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ uint32_t fileOffset;
+ uint8_t dataSize;
+ uint8_t imageData[OFD_BLOCK_SIZE];
+ };
+ struct PACK
+ {
+ uint32_t currentTime;
+ uint32_t requestTime;
+ };
+ };
+} ZCL_OtauImageBlockResp_t;
+
+/**
+ * \brief Upgrade End Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_Status_t status;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+} ZCL_OtauUpgradeEndReq_t;
+
+/**
+ * \brief Upgrade End Response Command.
+*/
+typedef struct PACK
+{
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ uint32_t currentTime;
+ uint32_t upgradeTime;
+} ZCL_OtauUpgradeEndResp_t;
+END_PACK
+
+/**
+ * \brief Image Page Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_OtauImageBlockReq_t imageBlockRequest;
+ uint16_t pageSize;
+ uint16_t responseSpacing;
+} ZCL_OtauImagePageReq_t;
+
+/**
+ * \brief ZCL OTAU Cluster Commands
+ */
+typedef struct
+{
+ //! Query Next Image Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pQueryNextImageReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauQueryNextImageReq_t *payload);
+ } queryNextImageReq;
+
+ //! Query Next Image Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pQueryNextImageRespInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauQueryNextImageResp_t *payload);
+ } queryNextImageResp;
+
+ //! Image Block Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pImageBlockReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauImageBlockReq_t *payload);
+ } imageBlockReq;
+
+ //! Image Page Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pImagePageReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauImagePageReq_t *payload);
+ } imagePageReq;
+
+ //! Image Block Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pImageBlockRespInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauImageBlockResp_t *payload);
+ } imageBlockResp;
+
+ //! Upgrade End Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pUpgradeEndReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauUpgradeEndReq_t *payload);
+ } upgradeEndReq;
+
+ //! Upgrade End Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pUpgradeEndRespInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauUpgradeEndResp_t *payload);
+ } upgradeEndResp;
+} ZCL_OtauClusterCommands_t;
+
+/**//**
+ \brief Initialization parameters for OTAU service
+ */
+typedef struct
+{
+/** \brief Cluster side. Must be chosen from: \n
+ ZCL_SERVER_CLUSTER_TYPE \n
+ ZCL_CLIENT_CLUSTER_TYPE */
+ uint8_t clusterSide;
+/** \brief Endpoint for cluster. */
+ Endpoint_t otauEndpoint;
+/** \brief Profile ID, that uses otau service. */
+ ProfileId_t profileId;
+/** \brief Current firmware version. Parameter is valid only for client. */
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+} ZCL_OtauInitParams_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Gets Otau's cluster
+
+\return Otau's client cluster
+******************************************************************************/
+ZCL_Cluster_t ZCL_GetOtauClientCluster(void);
+
+/***************************************************************************//**
+\brief Gets Otau's cluster
+
+\return Otau's server cluster
+******************************************************************************/
+ZCL_Cluster_t ZCL_GetOtauServerCluster(void);
+
+/***************************************************************************//**
+\brief OTAU parametres initialization. Start server discovery procedure
+ on client side or start server.
+
+\param[in] pInitParam - pointer to init structure.
+\param[in] ind - indication for OTAU actions \n
+("ind" can be NULL if indication is not required.)
+
+\return Service status
+******************************************************************************/
+ZCL_Status_t ZCL_StartOtauService(ZCL_OtauInitParams_t *pInitParam, ZCL_OtauStatInd_t ind);
+
+/***************************************************************************//**
+\brief Stop OTAU service. (It is not implemented for client)
+
+\param[in] pInitParam - pointer to init structure.
+
+\return Service status
+******************************************************************************/
+ZCL_Status_t ZCL_StopOtauService(ZCL_OtauInitParams_t *pInitParam);
+
+/***************************************************************************//**
+\brief Checks whether OTAU cluster is busy or not.
+
+\return true - if OTAU cluster is busy, false - otherwise.
+******************************************************************************/
+bool zclIsOtauBusy(void);
+
+/***************************************************************************//**
+\brief The server may send an unsolicited Upgrade End Response command to the client.
+This may be used for example if the server wants to synchronize the upgrade
+on multiple clients simultaneously.
+
+\param[in] addressing - pointer to structure with addressing information;
+\param[in] resp - pointer to upgrade end response payload
+
+\return true - data is sending, false - server is busy.
+******************************************************************************/
+bool ZCL_UnsolicitedUpgradeEndResp(ZCL_Addressing_t *addressing, ZCL_OtauUpgradeEndResp_t *resp);
+
+#endif /* _ZCLOTAUCLUSTER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h
new file mode 100644
index 00000000..167c43b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h
@@ -0,0 +1,155 @@
+/***************************************************************************//**
+ \file zclOccupancySensingCluster.h
+
+ \brief
+ The header file describes the ZCL Occupancy Sensing Cluster and its interface
+
+ The file describes the types and interface of the ZCL Occupancy Sensing Configuration Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLOCCUPANCYSENSINGCLUSTER_H
+#define _ZCLOCCUPANCYSENSINGCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+ * \brief Occupancy Sensing cluster attributes values
+*/
+
+#define OCCUPANCY_ATTRIBUTE_VALUE_OCCUPIED 1
+#define OCCUPANCY_ATTRIBUTE_VALUE_UNOCCUPIED 0
+
+#define OCCUPANYC_SENSOR_TYPE_ATTRIBUTE_VALUE_PIR 0x00
+#define OCCUPANYC_SENSOR_TYPE_ATTRIBUTE_VALUE_ULTRASONIC 0x01
+#define OCCUPANYC_SENSOR_TYPE__ATTRIBITE_VALUE_PIR_AND_ULTRASONIC 0x02
+
+/**
+ * \brief Occupancy Sensing Cluster server attributes amount
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+
+/**
+ * \brief Occupancy Sensing Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Switch Configuration Cluster commands amount
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_COMMANDS_AMOUNT 0
+
+/**
+ * \brief Occupancy Sensing Cluster server's attributes identifiers
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SENSOR_TYPE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+
+/**
+ * \brief Occupancy Sensing Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_OCCUPANCY_SENSING_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(occupancy, ZCL_READONLY_ATTRIBUTE, ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(occupancySensorType, ZCL_READONLY_ATTRIBUTE, ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SENSOR_TYPE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+/**
+ * \brief Occupancy Sensing Cluster definition macros
+*/
+
+#define OCCUPANCY_SENSING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = OCCUPANCY_SENSING_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define OCCUPANCY_SENSING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = OCCUPANCY_SENSING_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_OCCUPANCY_SENSING_CLUSTER(cltype, clattributes, clcommands) \
+ OCCUPANCY_SENSING_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Switch Configuration Cluster server's attributes
+*/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } occupancy;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } occupancySensorType;
+} ZCL_OccupancySensingClusterServerAttributes_t;
+
+END_PACK
+
+
+#endif /* _ZCLOCCUPANCYSENSINGCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h
new file mode 100644
index 00000000..5eec8fb9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h
@@ -0,0 +1,200 @@
+/***************************************************************************//**
+ \file zclOnOffCluster.h
+
+ \brief
+ The header file describes the ZCL On/Off Cluster and its interface
+
+ The file describes the types and interface of the ZCL On/Off Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLONOFFCLUSTER_H
+#define _ZCLONOFFCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief On/Off Cluster server attributes amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief On/Off Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Cluster commands amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT 3
+
+/**
+ * \brief On/Off Cluster server's attributes identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID 0x00
+#define ZCL_ONOFF_CLUSTER_ON_COMMAND_ID 0x01
+#define ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID 0x02
+
+/**
+ * \brief On/Off Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(onOff, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID, min, max)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_COMMANDS(onCommandInd, offCommandInd, toggleCommandInd) \
+ DEFINE_COMMAND(onCommand, ZCL_ONOFF_CLUSTER_ON_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ onCommandInd), \
+ DEFINE_COMMAND(offCommand, ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ offCommandInd), \
+ DEFINE_COMMAND(toggleCommand, ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ toggleCommandInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define ONOFF_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define ONOFF_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_ONOFF_CLUSTER(cltype, clattributes, clcommands) \
+ ONOFF_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Cluster server's attributes
+*/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ bool reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } onOff;
+} ZCL_OnOffClusterServerAttributes_t;
+
+/**
+ * \brief On/Off Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ bool onOffValue;
+} ZCL_OnOffClusterExtensionFieldSet_t;
+
+END_PACK
+
+/**
+ * \brief On/Off Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } onCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*offCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } offCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*toggleCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } toggleCommand;
+} ZCL_OnOffClusterCommands_t;
+
+#define DEFINE_ONOFF_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = ONOFF_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .onOffValue = value
+
+#endif /* _ZCLONOFFCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h
new file mode 100644
index 00000000..97c1c57a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h
@@ -0,0 +1,150 @@
+/***************************************************************************//**
+ \file zclOnOffSwitchConfigurationCluster.h
+
+ \brief
+ The header file describes the ZCL On/Off Switch Configuration Cluster and its interface
+
+ The file describes the types and interface of the ZCL On/Off Switch Configuration Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLONOFFSWITCHCONFIGURATIONCLUSTER_H
+#define _ZCLONOFFSWITCHCONFIGURATIONCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+ * \brief On/Off Switch Configuration attributes values
+*/
+
+#define SWITCH_TYPE_ATTRIBUTE_VALUE_TOGGLE 0x00
+#define SWITCH_TYPE_ATTRIBUTE_VALUE_MOMENTARY 0x01
+
+#define SWITCH_ACTIONS_ATTRIBUTE_VALUE_ON_OFF 0x00
+#define SWITCH_ACTIONS_ATTRIBUTE_VALUE_OFF_ON 0x01
+#define SWITCH_ACTIONS_ATTRIBITE_VALUE_TOGGLE_TOGGLE 0x02
+
+/**
+ * \brief On/Off Switch Configuration Cluster server attributes amount
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+
+/**
+ * \brief On/Off Switch Configuration Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Switch Configuration Cluster commands amount
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_COMMANDS_AMOUNT 0
+
+/**
+ * \brief On/Off Switch Configuration Cluster server's attributes identifiers
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_TYPE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_ACTIONS_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+
+/**
+ * \brief On/Off Switch Configuration Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(switchType, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_TYPE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(switchActions, ZCL_READWRITE_ATTRIBUTE, ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_ACTIONS_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+
+/**
+ * \brief On/Off Switch Configuration Cluster definition macros
+*/
+
+#define ONOFF_SWITCH_CONFIGURATION_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define ONOFF_SWITCH_CONFIGURATION_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_ONOFF_SWITCH_CONFIGURATION_CLUSTER(cltype, clattributes, clcommands) \
+ ONOFF_SWITCH_CONFIGURATION_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Switch Configuration Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } switchType;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } switchActions;
+} ZCL_OnOffSwitchConfigurationClusterServerAttributes_t;
+
+END_PACK
+
+#endif /* _ZCLONOFFSWITCHCONFIGURATIONCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h
new file mode 100644
index 00000000..54365690
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+ \file zclOTAUCluster.h
+
+ \brief Declaration of the private OTAU interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 13.05.10 A. Khromykh - Created.
+*******************************************************************************/
+#ifndef _ZCLOTAUDISCOVERY_H
+#define _ZCLOTAUDISCOVERY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+#include <zdo.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef union
+{
+ ZDO_ZdpReq_t zdpOtauReq;
+#ifdef _ZCL_SECURITY_
+ APS_RequestKeyReq_t apsKeyReq;
+#endif // _ZCL_SECURITY_
+ ZCL_Request_t zclCommandReq;
+} OtauReqMemory_t;
+
+typedef union
+{
+ ZCL_OtauQueryNextImageReq_t uQueryNextImageReq;
+ ZCL_OtauImageBlockReq_t uImageBlockReq;
+ ZCL_OtauImagePageReq_t uImagePageReq;
+ ZCL_OtauUpgradeEndReq_t uUpgradeEndReq;
+} OtauZclReqMemory_t;
+
+typedef struct
+{
+ uint32_t imageInternalLength;
+ uint8_t internalAddressStatus;
+ uint32_t currentFileOffset;
+ uint8_t currentDataSize;
+ uint32_t imageRemainder;
+ uint32_t imagePageOffset;
+} OtauImageAuxVar_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU Cluster parametres.
+*******************************************************************************/
+typedef struct
+{
+ uint32_t imageSize;
+ uint8_t imageBlockData[OFD_BLOCK_SIZE];
+ uint8_t *imagePageData;
+
+} ZclOtauClientImageBuffer_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Restart poll timer
+
+\param[in] period - timer fired time
+\param[in] cb - pointer to fired method
+******************************************************************************/
+void otauStartGenericTimer(uint32_t period, void (* cb)(void));
+
+/***************************************************************************//**
+\brief Restart discovery service with context gap
+******************************************************************************/
+void otauStartPollDiscovery(void);
+
+/***************************************************************************//**
+\brief Entry point to client process
+******************************************************************************/
+void otauClientEntryPoint(void);
+
+/***************************************************************************//**
+\brief Start discovery of upgrade server
+******************************************************************************/
+void ZCL_OtauUpgradeServerDiscovery(void);
+
+/***************************************************************************//**
+\brief Server IEEE addresses request
+******************************************************************************/
+void otauServerExtAddrReq(void);
+
+#endif /* _ZCLOTAUDISCOVERY_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h
new file mode 100644
index 00000000..ad091491
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h
@@ -0,0 +1,180 @@
+/**************************************************************************//**
+ \file zclOTAUManager.h
+
+ \brief Declaration of the OTAU manager interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 16.05.11 A. Khromykh - Created.
+*******************************************************************************/
+#ifndef _ZCLOTAUMANAGER_H
+#define _ZCLOTAUMANAGER_H
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{ /* memory for storage of server discovery result */
+ struct
+ {
+ void *next;
+ } service;
+
+ bool busy;
+ Endpoint_t serverEndpoint;
+ ShortAddr_t serverShortAddress;
+ ExtAddr_t serverExtAddress;
+} ZclOtauDiscoveryResult_t;
+
+typedef struct
+{
+ struct
+ {
+ void *next;
+ } service;
+
+ bool busy;
+ uint8_t id;
+ ZCL_Addressing_t addressing;
+ ZCL_Request_t zclCommandReq;
+
+ union
+ {
+ ZCL_OtauQueryNextImageReq_t queryNextImageReq;
+ ZCL_OtauQueryNextImageResp_t queryNextImageResp;
+ ZCL_OtauImageBlockReq_t imageBlockReq;
+ ZCL_OtauImageBlockResp_t imageBlockResp;
+ ZCL_OtauUpgradeEndReq_t upgradeEndReq;
+ ZCL_OtauUpgradeEndResp_t upgradeEndResp;
+ };
+ ZCL_OtauImagePageReq_t imagePageReq;
+} ZclOtauServerTransac_t;
+
+typedef struct
+{
+ uint32_t fileOffset;
+ uint16_t size;
+} ZclOtauMissedBlockResponses_t;
+
+typedef struct
+{
+ uint8_t quantity;
+ uint8_t internalBlockOffset;
+ bool blockGetting;
+ ZclOtauMissedBlockResponses_t *missedBlockResponses;
+} otauMissedBlocksBuffer_t;
+
+typedef struct
+{
+ OtauReqMemory_t reqMem;
+ OtauZclReqMemory_t zclReqMem;
+ HAL_AppTimer_t genericTimer;
+ HAL_AppTimer_t pageRequestTimer;
+ ZclOtauClientImageBuffer_t otauParam;
+ OtauImageAuxVar_t imageAuxParam;
+ OFD_MemoryAccessParam_t memParam;
+ ZCL_OtauFirmwareVersion_t newFirmwareVersion;
+
+ uint8_t discoveredServerAmount;
+ ZclOtauDiscoveryResult_t *discoveredServerMem;
+
+ uint16_t pageReminderSize;
+ otauMissedBlocksBuffer_t missedBlocks;
+} ZCL_OtauClientMem_t;
+
+typedef struct
+{
+ ZCL_Request_t unsolicitedReq;
+ ZCL_OtauUpgradeEndResp_t unsolicitedUpgradeEndResp;
+
+ uint8_t transacAmount;
+ ZclOtauServerTransac_t *serverTransac;
+ uint16_t pageReminderSize;
+} ZCL_OtauServerMem_t;
+
+typedef struct
+{
+ ZCL_OtauStatInd_t otauInd;
+ ZCL_OtauInitParams_t initParam;
+ union
+ {
+ ZCL_OtauClientMem_t clientMem;
+ ZCL_OtauServerMem_t serverMem;
+ };
+} ZclOtauMem_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/** zclOtauMem is defined in zclOtauManager.c */
+extern ZclOtauMem_t zclOtauMem;
+extern bool isOtauBusy;
+
+/******************************************************************************
+ Inline functions section
+******************************************************************************/
+INLINE ZclOtauMem_t* zclGetOtauMem(void)
+{
+ return &zclOtauMem;
+}
+
+INLINE ZCL_OtauClientMem_t* zclGetOtauClientMem(void)
+{
+ return &zclOtauMem.clientMem;
+}
+
+INLINE ZCL_OtauServerMem_t* zclGetOtauServerMem(void)
+{
+ return &zclOtauMem.serverMem;
+}
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Lift otau cluster action for customer.
+
+\param[in] action - the OTAU action for a customer.
+******************************************************************************/
+void zclRaiseCustomMessage (const ZCL_OtauAction_t action);
+
+/***************************************************************************//**
+\brief Start otau client service
+******************************************************************************/
+void zclStartOtauClient(void);
+
+/***************************************************************************//**
+\brief Start otau server service
+******************************************************************************/
+void zclStartOtauServer(void);
+
+/***************************************************************************//**
+\brief Stop otau server service
+******************************************************************************/
+void zclStopOtauServer(void);
+
+/***************************************************************************//**
+\brief Clear otau server memory.
+******************************************************************************/
+void zclClearOtauServerMemory(void);
+
+/***************************************************************************//**
+\brief Clear otau client memory.
+******************************************************************************/
+void zclClearOtauClientMemory(void);
+
+/***************************************************************************//**
+\brief Find empty cell in memory pool.
+
+\return pointer to empty cell.
+******************************************************************************/
+ZclOtauServerTransac_t * zclFindEmptyCell(void);
+
+#endif /* _ZCLOTAUMANAGER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h
new file mode 100644
index 00000000..141d5b1f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h
@@ -0,0 +1,445 @@
+/************************************************************************//**
+ \file zclParser.h
+
+ \brief
+ The header file describes the ZCL Parser interface
+
+ The file describes the interface and types of ZCL Parser
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 02.12.08 A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLPARSER_H
+#define _ZCLPARSER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+//#include <zclDbg.h>
+#include <zcl.h>
+#include <zclMemoryManager.h>
+#include <queue.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/*ZCL Header Frame Type sub-field value*/
+#define ZCL_FRAME_CONTROL_FRAME_TYPE_UNIVERSAL_COMMAND 0x00
+#define ZCL_FRAME_CONTROL_FRAME_TYPE_SPECIFIC_COMMAND 0x01
+
+/*ZCL Header Manufacturer Specific sub-field value*/
+#define ZCL_FRAME_CONTROL_MANUFACTURER_NONSPECIFIC 0x00
+#define ZCL_FRAME_CONTROL_MANUFACTURER_SPECIFIC 0x01
+
+#define ZCL_FRAME_SIMPLE_HEADER_LENGTH 3
+#define ZCL_FRAME_HEADER_MANUFACTURER_CODE_LENGTH 2
+#define ZCL_FRAME_HEADER_WITH_MANUFACTURER_CODE_LENGTH \
+ (ZCL_FRAME_SIMPLE_HEADER_LENGTH + ZCL_FRAME_HEADER_MANUFACTURER_CODE_LENGTH)
+
+#ifndef ZCL_STANDARD_REQ_TYPE
+#define ZCL_STANDARD_REQ_TYPE ZCL_FRAME_CONTROL_FRAME_TYPE_UNIVERSAL_COMMAND
+#endif
+#ifndef ZCL_SPECIAL_REQ_TYPE
+#define ZCL_SPECIAL_REQ_TYPE ZCL_FRAME_CONTROL_FRAME_TYPE_SPECIFIC_COMMAND
+#endif
+
+#ifndef ZCL_MAX_STANDARD_DATA_TYPE_SIZE
+#define ZCL_MAX_STANDARD_DATA_TYPE_SIZE 8
+#endif
+
+/*************************************************************************//**
+ \brief Defines the Descrete Kind of ZCL Data Type (used in #ZCL_DataTypeDescriptor_t)
+*****************************************************************************/
+#ifndef ZCL_DATA_TYPE_DESCRETE_KIND
+#define ZCL_DATA_TYPE_DESCRETE_KIND 0x00
+#endif
+
+/*************************************************************************//**
+ \brief Defines the Analog Kind of ZCL Data Type (used in #ZCL_DataTypeDescriptor_t)
+*****************************************************************************/
+#ifndef ZCL_DATA_TYPE_ANALOG_KIND
+#define ZCL_DATA_TYPE_ANALOG_KIND 0x01
+#endif
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+typedef enum
+{
+ ZCL_PARSER_IDLE_STATE,
+ ZCL_PARSER_RECEIVED_PACKET_STATE,
+ ZCL_PARSER_SENDING_RESPONSE_STATE,
+} ZclParserState_t;
+
+typedef struct
+{
+ //ZclParserState_t state;
+ uint8_t dataIndAmount;
+ QueueDescriptor_t dataIndQueue;
+} ZclParserMem_t;
+
+BEGIN_PACK
+typedef struct PACK
+{
+ union PACK
+ {
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(5,(
+ uint8_t frameType :2, //Frame type sub-field
+ uint8_t manufacturerSpecific :1, //Manufacturer specific sub-field
+ uint8_t direction :1, //Direction sub-field
+ uint8_t defaultResponse :1, //Disable default response sub-field
+ uint8_t reserved :3 //Reserved bits. Must have a zero value
+ ))
+ };
+ uint8_t uint8;
+ };
+} ZclFrameControlField_t;
+
+typedef struct PACK
+{
+ ZclFrameControlField_t frameControl;
+ uint16_t manufacturerCode;
+ uint8_t sequenceNumber;
+ uint8_t commandId;
+} ZclFrameHeader_t;
+
+typedef struct PACK
+{
+ ZclFrameHeader_t header;
+ uint8_t payload[1];
+} ZclFrame_t;
+
+/******************************************************************************
+ Read Attributes commands
+******************************************************************************/
+/** \brief ZCL read attributes command record */
+typedef struct PACK
+{
+ uint16_t attributeId;
+} ZclReadAttributesRecord_t;
+
+/** \brief ZCL Read attributes command payload */
+typedef struct PACK
+{
+ ZclReadAttributesRecord_t records[1];
+} ZclReadAttributesCommand_t;
+
+typedef struct PACK
+{
+ uint8_t elementType;
+ uint16_t elementsAmount;
+ struct PACK
+ {
+ uint8_t value[1];
+ } elements[1];
+} ZclReadAttributesResponseArraySetBagValue_t;
+
+typedef struct PACK
+{
+ uint16_t elementsAmount;
+ struct PACK
+ {
+ uint8_t elementType;
+ uint8_t value[1];
+ } elements [1];
+} ZclReadAttributesResponseStructValue_t;
+
+/** \brief ZCL read attributes response command record */
+typedef struct PACK
+{
+ ZCL_AttributeId_t attributeId;
+ uint8_t status;
+ uint8_t type;
+ union PACK
+ {
+ uint8_t simpleValue[1];
+ ZclReadAttributesResponseArraySetBagValue_t arraySetBagValue;
+ ZclReadAttributesResponseStructValue_t structValue;
+ };
+} ZclReadAttributesResponseRecord_t;
+
+/** \brief ZCL read attributes response command payload */
+typedef struct PACK
+{
+ ZclReadAttributesResponseRecord_t records[1];
+} ZclReadAttributesResponseCommand_t;
+
+/******************************************************************************
+ Write Attributes commands
+******************************************************************************/
+/** \brief ZCL write attributes command record */
+typedef struct PACK
+{
+ ZCL_AttributeId_t attributeId;
+ uint8_t type;
+ uint8_t value[1];
+} ZclWriteAttributesRecord_t;
+
+/** \brief ZCL Wrire attributes command payload */
+typedef struct PACK
+{
+ ZclWriteAttributesRecord_t records[1];
+} ZclWriteAttributesCommand_t;
+
+/** \brief ZCL Wrire attributes undivided command payload */
+typedef ZclWriteAttributesCommand_t ZclWriteAttributesUndividedCommand_t;
+
+/** \brief ZCL Wrire attributes no response command payload */
+typedef ZclWriteAttributesCommand_t ZclWriteAttributesNoResponseCommand_t;
+
+/** \brief ZCL write attributes response command record */
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t attributeId;
+} ZclWriteAttributesResponseRecord_t;
+
+/** \brief ZCL Wrire attributes response command payload */
+typedef struct PACK
+{
+ ZclWriteAttributesResponseRecord_t records[1];
+} ZclWriteAttributesResponseCommand_t;
+
+/******************************************************************************
+ Configure reporting command
+******************************************************************************/
+/** \brief ZCL configure reporting command record */
+typedef struct PACK
+{
+ uint8_t direction;
+ uint16_t attributeId;
+ uint16_t minimumReportingInterval;
+ uint16_t maximumReportingInterval;
+ uint8_t reportableChange[1];
+ uint16_t timeoutPeriod;
+} ZclConfigureReportingRecord_t;
+
+/** \brief ZCL configure reporting command payload */
+typedef struct PACK
+{
+ ZclConfigureReportingRecord_t records[1];
+} ZclConfigureReportingCommand_t;
+
+/** \brief ZCL configure reporting response command record */
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t direction;
+ uint16_t attributeId;
+} ZclConfigureReportingResponseRecord_t;
+
+/** \brief ZCL configure reporting response command payload */
+typedef struct PACK
+{
+ ZclConfigureReportingResponseRecord_t records[1];
+} ZclConfigureReportingResponseCommand_t;
+
+END_PACK
+
+typedef struct
+{
+ ZCL_GeneralCommandId_t commandId;
+ void *primitive;
+} ZclBuffer_t;
+
+typedef enum
+{
+ ZCL_PARSER_SUCCESS_STATUS = 0,
+ ZCL_PARSER_UNKNOWN_COMMAND_STATUS = 1,
+ ZCL_PARSER_BAD_FORMAT_STATUS = 2,
+ ZCL_PARSER_INVALID_PARAMETER_STATUS = 3
+} ZclParserStatus_t;
+
+typedef enum
+{
+ ZCL_REQUEST_TYPE,
+ ZCL_RESPONSE_TYPE,
+ ZCL_EVENT_TYPE,
+ ZCL_UNSPECIFIED_COMMAND_TYPE
+} ZCL_CommandType_t;
+
+typedef struct
+{
+ uint8_t headerLength;
+ uint8_t payloadLength;
+ uint8_t frameType;
+ uint8_t direction;
+ uint8_t defaultResponse;
+ uint8_t manufacturerSpecific;
+ uint16_t manufacturerCode;
+ uint8_t sequenceNumber;
+ uint8_t commandId;
+ uint8_t *header;
+ uint8_t *payload;
+} ZclFrameDescriptor_t;
+
+typedef struct
+{
+ ZclFrameDescriptor_t *frameDescriptor;
+ APS_DataInd_t *ind;
+ ZCL_Status_t commandStatus;
+ bool noApsSecurity;
+ bool relevantResponse;
+} ZclAuxParseData_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/**************************************************************************//**
+\brief ZCL memory global object
+******************************************************************************/
+extern ZclParserMem_t zclParserMem;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+ \brief Reset parser queue and clear memory.
+*****************************************************************************/
+void zclParserInit(void);
+
+/**************************************************************************//**
+\brief Form zcl header.
+
+\param[in] - dataReq - pointer to data request;
+\param[in] - reqType - type of the request;
+\param[in] - direction - cluster\server side;
+\param[in] - commandId - zcl command identification;
+\param[in] - defaultResponse - presence or absence of the default responde;
+\param[in] - manufacSpecCode - manufacturer specific code;
+\return header length
+******************************************************************************/
+uint8_t zclFormRequest(APS_DataReq_t *dataReq, uint8_t reqType, uint8_t direction, uint8_t commandId, uint8_t defaultResponse, uint16_t manufacSpecCode);
+
+/*************************************************************************//**
+ \brief Response has been received.
+
+ \param[in] auxData - pointer to structure with command payload and
+ descriptor of received command frame.
+*****************************************************************************/
+void zclResponseInd(ZclAuxParseData_t *auxData);
+
+/*************************************************************************//**
+\brief Routine of Read Reporting Configuration Command.
+
+\param[in] apsDataInd - pointer to aps payload
+\param[in] frameDescriptor - pointer to parsed data structure from payload
+*****************************************************************************/
+void zclReadReportingConfigurationHandler(APS_DataInd_t *apsDataInd, ZclFrameDescriptor_t *frameDescriptor);
+
+/*************************************************************************//**
+\brief Routine of Configure Reporting Command.
+
+\param[in] apsDataInd - pointer to aps payload
+\param[in] frameDescriptor - pointer to parsed data structure from payload
+*****************************************************************************/
+void zclConfigureReportingHandler(APS_DataInd_t *apsDataInd, ZclFrameDescriptor_t *frameDescriptor);
+
+/*************************************************************************//**
+ \brief Report has been received.
+
+ \param[in] apsData - report payload
+ \param[in] frameDesc - descriptor of received report frame
+*****************************************************************************/
+void zclReportInd(APS_DataInd_t *apsData, ZclFrameDescriptor_t *frameDescriptor);
+
+/*************************************************************************//**
+ \brief Special cluster command has been received.
+
+ \param[in] auxData - pointer to structure with command payload and
+ descriptor of received command frame.
+*****************************************************************************/
+void zclCommandInd(ZclAuxParseData_t *auxData);
+
+/*************************************************************************//**
+ \brief The attribute has been read or written.
+
+ \param[in] apsDataInd - attribute payload
+ \param[in] direction - direction
+ \param[in] event - event type
+ \param[in] attributeId - attribute identifier
+*****************************************************************************/
+void zclAttributeEventInd(APS_DataInd_t *apsDataInd, uint8_t direction, ZCL_AttributeEvent_t event, ZCL_AttributeId_t attributeId);
+
+/*************************************************************************//**
+ \brief Configuration has been received.
+
+ \param[in] apsData - configuration payload
+ \param[in] frameDesc - descriptor of received report frame
+*****************************************************************************/
+void zclConfigurationInd(APS_DataInd_t *apsData, ZclFrameDescriptor_t *frameDesc);
+
+/*************************************************************************//**
+ \brief Indication from CAPS.
+
+ \param[in] ind - buffer for data indication.
+*****************************************************************************/
+void zclDataInd(APS_DataInd_t *ind);
+
+/*************************************************************************//**
+ \brief Security Type get by Cluster Id function and by endpointId, on which
+ was registered cluster.
+ Returns Security Type should be used with ClusterId specified
+ \param[in] clusterId - cluster identifier
+ \param[in] endpointId - end point identifier
+ \return ZCL_NETWORK_KEY_CLUSTER_SECURITY - NWK Key Security should be used
+ ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY - APS Link Key Security
+ shoud be used.
+ If cluster is unknown, security key will be determined by security mode,
+ i.e. ZCL_NETWORK_KEY_CLUSTER_SECURITY for Standard Security,
+ ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY for High Security.
+*****************************************************************************/
+uint8_t zclGetSecurityTypeByClusterId(ClusterId_t clusterId, Endpoint_t endpointId);
+
+/**************************************************************************//**
+ \brief Get next registered ZCL endpoint descriptor by previous.
+
+ \param[in] prev - previous ZCL endpoint descriptor pointer.It is must be non NULL
+ sequential access required if. And it is must be NULL the
+ first descriptor as registered endpoints queue head element
+ access required if.
+
+ \return Valid ZCL endpoint descriptor pointer descriptor found if,
+ NULL - other case.
+ ******************************************************************************/
+ZCL_DeviceEndpoint_t* zclNextEndpoint(ZCL_DeviceEndpoint_t *prev);
+
+/*************************************************************************//**
+ \brief Find endpoint descriptor by endpoint id.
+
+ \param[in] endpointId - endpoint unique identifier.
+ \return endpoint descriptor if found, NULL otherwise.
+*****************************************************************************/
+ZCL_DeviceEndpoint_t *zclGetEndpoint(Endpoint_t endpointId);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/******************************************************************************
+\brief Function returns point to ZCL memory object
+******************************************************************************/
+static inline ZclParserMem_t *zclParserMemReq(void)
+{
+ return ((ZclParserMem_t *)&zclParserMem);
+}
+
+#endif //#ifndef _ZCLPARSER_H
+
+//eof zclParser.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h
new file mode 100644
index 00000000..eccbb372
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ \file zclPowerConfigurationCluster.h
+
+ \brief
+ The file describes the types and interface of the Power Configuration cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 18.01.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _ZCLPOWERCONFIGURATIONCLUSTER_H_
+#define _ZCLPOWERCONFIGURATIONCLUSTER_H_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <types.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+* \brief server attributes amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+
+/**
+* \brief server commands amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+/**
+* \brief client attributes amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+* \brief client commands amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+
+
+/**
+* \brief Supported attribue id
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_VOLTAGE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_FREQUENCY_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+
+/**
+ * \brief server define attributes macros
+*/
+#define ZCL_DEFINE_POWER_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(mainsVoltage, ZCL_READONLY_ATTRIBUTE, ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_VOLTAGE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(mainsFrequency, ZCL_READONLY_ATTRIBUTE, ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_FREQUENCY_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_POWER_CONFIGURATION_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = POWER_CONFIGURATION_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) (clattributes), \
+ .commandsAmount = ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define ZCL_DEFINE_POWER_CONFIGURATION_CLUSTER_CLIENT() \
+ { \
+ .id = POWER_CONFIGURATION_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK {
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } mainsVoltage ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } mainsFrequency ;
+} ZCL_PowerConfigurationClusterAttributes_t ;
+END_PACK
+
+#endif /* _ZCLPOWERCONFIGURATIONCLUSTER_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h
new file mode 100644
index 00000000..0769596b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h
@@ -0,0 +1,267 @@
+/************************************************************************//**
+ \file zclPriceCluster.h
+
+ \brief
+ The header file describes the Price Cluster.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 05.02.09 A. Mandychev - Changed.
+******************************************************************************/
+
+#ifndef _ZCLPRICECLUSTER_H
+#define _ZCLPRICECLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+/**
+\brief Macros defines duration of Publish Price command,
+ * which means 'until change'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 197.
+*/
+#define PUBLISH_PRICE_DURATION_UNTIL_CHANGED (0xFFFF)
+
+/**
+\brief Macros defines start time of Publish Price command,
+ * which means 'now'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 197.
+*/
+#define PUBLISH_PRICE_START_TIME_NOW (0x0000)
+
+/**
+\brief Macros defines Price Ratio field special value,
+ * which means 'not used'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198.
+*/
+#define PUBLISH_PRICE_PRICE_RATIO_IS_NOT_USED (0xFF)
+
+/**
+\brief Macros defines Generation Price Ratio field special value,
+ * which means 'not used'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198.
+*/
+#define PUBLISH_PRICE_GENERATION_PRICE_RATIO_IS_NOT_USED (0xFF)
+
+/**
+\brief Macros defines Generation Price field special value,
+ * which means 'not used'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198.
+*/
+#define PUBLISH_PRICE_GENERATION_PRICE_IS_NOT_USED (0xFFFFFFFF)
+
+/**
+\brief Macros defines Number Of Block Thresholds field special value,
+ * which means 'not used'.
+ * According to ZigBee-095310r23ZB, page 65.
+*/
+#define PUBLISH_NUMBER_OF_BLOCK_THRESHOLDS_IS_NOT_USED (0xFF)
+
+/**
+\brief Macros defines Price Control field special value,
+ * which means 'not used'.
+ * According to ZigBee-095310r23ZB, page 65.
+*/
+#define PUBLISH_PRICE_CONTROL_IS_NOT_USED (0x00)
+
+/**
+\brief Macros defines Standing Charge field special value,
+ * which means 'not used'.
+ * According to ZigBee-095310r23ZB, page 65.
+*/
+#define PUBLISH_STANDING_CHARGE_IS_NOT_USED (0xFFFFFFFF)
+
+/**
+ * \brief Price Server Cluster attributes amount.
+*/
+#define PRICE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Price Client Cluster attributes amount.
+*/
+#define PRICE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Price Client Cluster commands amount.
+*/
+#define PRICE_CLUSTER_COMMANDS_AMOUNT 3
+
+/**
+ * \brief Price Server Cluster commands identifiers.
+*/
+#define PUBLISH_PRICE_COMMAND_ID 0x00
+
+/**
+ * \brief Price Client Cluster commands identifiers.
+*/
+#define GET_CURRENT_PRICE_COMMAND_ID 0x00
+#define GET_SCHEDULED_PRICES_COMMAND_ID 0x01
+
+#define RATE_LABEL_MAX_LEN 12
+
+/*
+#define DEMAND_RESPONSE_CLUSTER_SERVER_COMMANDS(publishPriceInd) \
+ DEFINE_COMMAND(publishPriceCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT), publishPriceInd)
+
+
+#define DEMAND_RESPONSE_CLUSTER_CLIENT_COMMANDS(getCurrentPriceInd) \
+ DEFINE_COMMAND(getCurrentPriceCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER), getCurrentPriceInd)
+*/
+
+#define PRICE_CLUSTER_COMMANDS(getCurrentPriceInd, publishPriceInd, getScheduledPricesInd) \
+ DEFINE_COMMAND(getCurrentPriceCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getCurrentPriceInd), \
+ DEFINE_COMMAND(publishPriceCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), publishPriceInd), \
+ DEFINE_COMMAND(getScheduledPricesCommand, GET_SCHEDULED_PRICES_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getScheduledPricesInd)
+
+#define PRICE_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = PRICE_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = PRICE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = PRICE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define PRICE_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = PRICE_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = PRICE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = PRICE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+#define DEFINE_PRICE_CLUSTER(cltype, clattributes, clcommands) PRICE_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Publish Price Command Payload format.
+*/
+typedef struct PACK
+{
+ uint32_t providerId;
+ uint8_t rateLabelLength;
+ uint8_t rateLabel[RATE_LABEL_MAX_LEN];
+ uint32_t issuerEventId;
+ ZCL_UTCTime_t currentTime;
+ uint8_t unitOfMeasure;
+ uint16_t currency;
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t priceTrailDigit : 4,
+ uint8_t priceTier : 4
+ ))
+ } priceTrailDigitPriceTier;
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t numberOfPriceTiers : 4,
+ uint8_t registerTier : 4
+ ))
+ } numberOfPriceTiersRegisterTier;
+ ZCL_UTCTime_t startTime;
+ uint16_t durationInMinutes;
+ uint32_t price;
+ uint8_t priceRatio;
+ uint32_t generationPrice;
+ uint8_t generationPriceRatio;
+ uint32_t alternateCostDelivered;
+ uint8_t alternateCostUnit;
+ uint8_t alternateCostTrailingDigit;
+ uint8_t numberOfBlockThresholds;
+ uint8_t priceControl;
+ uint32_t standingCharge;
+} ZCL_PublishPrice_t;
+
+/**
+ * \brief Get Current Price Command Payload format.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t requestorRxOnWhenIdle :1, //!<The requestor Rx On When Idle sub-field
+ uint8_t reserved :7 //!<Reserved field
+ ))
+} ZCL_GetCurrentPrice_t;
+
+/**
+ * \brief Get Scheduled Prices Command Payload format.
+*/
+typedef struct PACK
+{
+ ZCL_UTCTime_t startTime;
+ uint8_t numberOfEvents;
+} ZCL_GetScheduledPrices_t;
+END_PACK
+
+
+/**
+ * \brief ZCL Price Cluster Commands
+ */
+typedef struct
+{
+ //! Get Current Price Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*getCurrentPrice)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetCurrentPrice_t *payload);
+ } getCurrentPriceCommand;
+
+ //! Get Scheduled Prices Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in octets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*getScheduledPrices)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetScheduledPrices_t *payload);
+ } getScheduledPricesCommand;
+
+ //! Publish Price Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*publishPrice)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_PublishPrice_t *payload);
+ } publishPriceCommand;
+
+} ZCL_PriceClusterCommands_t;
+
+
+
+#endif // _ZCLPRICECLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h
new file mode 100644
index 00000000..eb8a5ad8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h
@@ -0,0 +1,487 @@
+/***************************************************************************//**
+ \file zclScenesCluster.h
+
+ \brief
+ The header file describes the ZCL Scenes Cluster and its interface
+
+ The file describes the types and interface of the ZCL Scenes Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLSCENESCLUSTER_H
+#define _ZCLSCENESCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Scenes Cluster scene name support bit
+*/
+
+#define SCENE_NAME_SUPPORT_FLAG 0x80
+
+/**
+ * \brief Scenes Cluster server attributes amount
+*/
+
+#define ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/**
+ * \brief Scenes Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief Scenes Cluster commands amount
+*/
+
+#define ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT 13
+
+/**
+ * \brief Scenes Cluster server's attributes identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+#define ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+#define ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+
+/**
+ * \brief Scenes Cluster client's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID 0x05
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID 0x06
+
+/**
+ * \brief Scenes Cluster servers's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID 0x06
+
+
+/**
+ * \brief Scenes Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(sceneCount, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentScene, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentGroup, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(sceneValid, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_COMMANDS(addSceneCommandInd, viewSceneCommandInd, removeSceneCommandInd, \
+ removeAllScenesCommandInd, storeSceneCommandInd, recallSceneCommandInd, \
+ getSceneMembershipCommandInd, addSceneResponseCommandInd, viewSceneResponseCommandInd, \
+ removeSceneResponseCommandInd, removeAllScenesResponseCommandInd, storeSceneResponseCommandInd, \
+ getSceneMembershipResponseInd) \
+ DEFINE_COMMAND(addSceneCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneCommandInd), \
+ DEFINE_COMMAND(viewSceneCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneCommandInd), \
+ DEFINE_COMMAND(removeSceneCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneCommandInd), \
+ DEFINE_COMMAND(removeAllScenesCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesCommandInd), \
+ DEFINE_COMMAND(storeSceneCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneCommandInd), \
+ DEFINE_COMMAND(recallSceneCommand, ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ recallSceneCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipCommandInd), \
+ DEFINE_COMMAND(addSceneResponseCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneResponseCommandInd), \
+ DEFINE_COMMAND(viewSceneResponseCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeSceneResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeAllScenesResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesResponseCommandInd), \
+ DEFINE_COMMAND(storeSceneResponseCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneResponseCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipResponse, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipResponseInd)
+
+
+/**
+ * \brief Scene Cluster definition macros
+*/
+
+#define SCENES_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define SCENES_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_SCENES_CLUSTER(cltype, clattributes, clcommands) \
+ SCENES_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t sceneNameAndExtField[1];
+} ZCL_AddScene_t;
+
+/**
+ * \brief View Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_ViewScene_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveScene_t;
+
+/**
+ * \brief Remove All Scenes Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveAllScenes_t;
+
+/**
+ * \brief Store Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreScene_t;
+
+/**
+ * \brief Recall Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RecallScene_t;
+
+/**
+ * \brief Get Scene Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_GetSceneMembership_t;
+
+/**
+ * \brief Add Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_AddSceneResponse_t;
+
+/**
+ * \brief View Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t nameAndExtField[1]; // string sceneName, extension field.
+} ZCL_ViewSceneResponse_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveSceneResponse_t;
+
+/**
+ * \brief Remove All Scenes Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveAllScenesResponse_t;
+
+/**
+ * \brief Store Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreSceneResponse_t;
+
+/**
+ * \brief Get Scene Membership Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t capacity;
+ uint16_t groupId;
+ uint8_t sceneCount;
+ uint8_t sceneList[1];
+} ZCL_GetSceneMembershipResponse_t;
+
+/**
+ * \brief Scene Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } sceneCount;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentScene;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentGroup;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ } sceneValid;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_SceneClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Scene Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddScene_t * payload);
+ } addSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewScene_t * payload);
+ } viewSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveScene_t * payload);
+ } removeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenes_t * payload);
+ } removeAllScenesCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreScene_t * payload);
+ } storeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*recallSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RecallScene_t * payload);
+ } recallSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembership_t * payload);
+ } getSceneMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddSceneResponse_t * payload);
+ } addSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewSceneResponse_t * payload);
+ } viewSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveSceneResponse_t * payload);
+ } removeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenesResponse_t * payload);
+ } removeAllScenesResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreSceneResponse_t * payload);
+ } storeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipResponse)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembershipResponse_t * payload);
+ } getSceneMembershipResponse;
+} ZCL_ScenesClusterCommands_t;
+
+
+#endif /* _ZCLSCENESCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h
new file mode 100644
index 00000000..e91cd669
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h
@@ -0,0 +1,190 @@
+/***************************************************************************//**
+ \file zclSecurityManager.h
+
+ \brief
+ The header file describes the ZCL Security Manager and its interface
+
+ The file describes the types and interface of the ZCL Security Manager
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 17.03.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLSECURITYMANAGER_H
+#define _ZCLSECURITYMANAGER_H
+
+#ifdef _ZCL_SECURITY_
+#include <zcl.h>
+#include <zdo.h>
+#include <genericEcc.h>
+
+typedef enum
+{
+ ZCL_SECURITY_STATUS_SUCCESS = 0x00,
+#ifdef _CERTICOM_SECURITY_
+ ZCL_SECURITY_STATUS_DISCOVERY_FAIL = 0x01,
+ ZCL_SECURITY_STATUS_APS_BINDING_FAIL = 0x02,
+ ZCL_SECURITY_STATUS_TIMEOUT = 0x03,
+ ZCL_SECURITY_STATUS_TERMINATED = 0x04,
+ ZCL_SECURITY_STATUS_SEND_COMMAND_FAIL = 0x05,
+ ZCL_SECURITY_STATUS_INVALID_SETTINGS = 0x06,
+#endif //#ifdef _CERTICOM_SECURITY_
+} ZCL_SecurityStatus_t;
+
+
+/*************************************************************************//**
+ Status of ZCL operation
+ \brief
+ Used to return status of ZCL operation.
+*****************************************************************************/
+/*
+typedef enum
+{
+ ZCL_SUCCESS_STATUS = 0x00,
+ ZCL_UNSUPPORTED_ATTRIBUTE_STATUS = 0x01,
+ ZCL_INVALID_ATTRIBUTE_VALUE_STATUS = 0x02,
+ ZCL_TC_PERMISSION_TABLE_ERROR_STATUS = 0x03,
+ ZCL_APS_LINK_KEY_ERROR_STATUS = 0x04
+} ZCL_Status_t;
+*/
+
+BEGIN_PACK
+
+typedef struct PACK
+{
+ ExtAddr_t addr; //!<Destination node 64-bit IEEE address
+ uint8_t key[SECURITY_KEY_SIZE]; //!<APS Link Key
+} ZCL_LinkKeyDesc_t;
+
+typedef struct PACK
+{
+ ProfileId_t profileId;
+ uint8_t additional[8];
+} ZclKEProfileAttributeData_t;
+
+typedef struct PACK
+{
+ uint8_t publicReconstrKey[SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE]; //22-byte
+ ExtAddr_t subject; //8-bytes
+ ExtAddr_t issuer; //8-byte
+ ZclKEProfileAttributeData_t profileAttributeData; //10-byte
+} ZclCertificate_t;
+
+#ifdef _CERTICOM_SECURITY_
+typedef struct PACK
+{
+ uint8_t publicKey[SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE]; //!<CA Public Key shared between all nodes in network
+ uint8_t privateKey[SECT163K1_PRIVATE_KEY_SIZE]; //!<Node secret key
+ uint8_t certificate[SECT163K1_CERTIFICATE_SIZE ]; //!<Node certificate derived from CA
+} ZCL_CertificateDesc_t;
+
+typedef struct PACK
+{
+ uint8_t publicKey[SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE]; //!<CA Public Key shared between all nodes in network
+ uint8_t privateKey[SECT163K1_PRIVATE_KEY_SIZE]; //!<Node secret key
+ ZclCertificate_t certificate; //!<Node certificate derived from CA
+} ZCL_KECertificateDescriptor_t;
+
+#endif //#ifdef _CERTICOM_SECURITY_
+
+END_PACK
+
+
+/*************************************************************************//**
+ Security variable identifier type
+ \brief
+ Used by functions ZCL_Set and ZCL_Get. To define variable to write or read.
+*****************************************************************************/
+typedef enum
+{
+#ifdef _CERTICOM_SECURITY_
+ /* Certificate for Key Establishment */
+ ZCL_CERTIFICATE_DESC_ID = 0x00,
+#endif //#ifdef _CERTICOM_SECURITY_
+ /* Link key descriptor*/
+ ZCL_LINK_KEY_DESC_ID = 0x01,
+ /* Not used */
+ ZCL_REMOVE_LINK_KEY_ID = 0x02,
+#ifdef _CERTICOM_SECURITY_
+ /* Endpoint asssigned for Key Establishment cluster */
+ ZCL_KE_ACTIVE_ENDPOINT_ID = 0x03,
+#endif //#ifdef _CERTICOM_SECURITY_
+ /* Network key */
+ ZCL_NETWORK_KEY_ID = 0x04
+} ZCL_SecurityAttrId_t;
+
+typedef union
+{
+#ifdef _CERTICOM_SECURITY_
+ ZCL_CertificateDesc_t *certificateDesc; //Used with ZCL_CERTIFICATE_DESC_ID
+ Endpoint_t endpoint; //Used with ZCL_KE_ACTIVE_ENDPOINT_ID
+#endif //#ifdef _CERTICOM_SECURITY_
+ ZCL_LinkKeyDesc_t *linkKeyDesc; //Used with ZCL_LINK_KEY_DESC_ID
+ uint8_t *networkKey; //Used with ZCL_NETWORK_KEY_ID
+ ExtAddr_t extAddr; //Used with ZCL_REMOVE_LINK_KEY_ID
+} ZCL_SecurityAttrValue_t;
+
+typedef struct
+{
+ ZCL_SecurityAttrId_t id;
+ uint8_t length;
+ ZCL_SecurityAttrValue_t value;
+} ZCL_SecurityAttr_t;
+
+typedef struct
+{
+ ZCL_SecurityAttr_t attr;
+ ZCL_Status_t status;
+} ZCL_Set_t;
+
+typedef struct
+{
+ ZCL_SecurityAttr_t attr;
+ ZCL_Status_t status;
+} ZCL_Get_t;
+
+typedef struct
+{
+ ZCL_SecurityStatus_t status;
+} ZCL_StartSecurityConf_t;
+
+typedef struct
+{
+ ZCL_StartSecurityConf_t confirm;
+ void (* ZCL_StartSecurityConf)(ZCL_StartSecurityConf_t *conf);
+} ZCL_StartSecurityReq_t;
+//API
+
+extern bool keSrvMode;
+extern Endpoint_t clKEEndpoint;
+extern Endpoint_t srvKEEndpoint;
+
+void ZCL_ResetSecurity(void);
+
+void ZCL_Set(ZCL_Set_t *req);
+
+void ZCL_Get(ZCL_Get_t *req);
+
+void ZCL_StartSecurityReq(ZCL_StartSecurityReq_t *req);
+
+#ifdef _CERTICOM_SECURITY_
+/*************************************************************************************//**
+ \brief Notifies that Key Establishment is finished with status specified in parameters.
+
+ \param status - status of Key Establishment.
+******************************************************************************************/
+void keNotification(ZCL_SecurityStatus_t status);
+#endif
+
+#endif //#ifdef _ZCL_SECURITY_
+#endif //#ifndef _ZCLSECURITYMANAGER_H
+
+//eof zclSecurityManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h
new file mode 100644
index 00000000..e96f8043
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h
@@ -0,0 +1,175 @@
+/************************************************************************//**
+ \file zclMemoryManager.h
+
+ \brief
+ The header file describes the ZCL Simple Metering Cluster
+
+ The header file describes the ZCL Simple Metering Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 27.11.08 A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _SIMPLEMETERINGCLUSTER_H
+#define _SIMPLEMETERINGCLUSTER_H
+
+#include <zcl.h>
+#include <clusters.h>
+
+#define CURRENT_SUMMATION_DELIVERED_ATTRIBUTE_ID 0x00
+
+/*************************************************************************//**
+ \brief Simple Metering Cluster attributes amount
+*****************************************************************************/
+#define SIMPLE_METERING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+#define SIMPLE_METERING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/*************************************************************************//**
+ \brief Simple Metering Cluster commands amount
+*****************************************************************************/
+#define SIMPLE_METERING_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+#define SIMPLE_METERING_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+#define DEFINE_SIMPLE_METERING_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(currentSummationDelivered, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0000), ZCL_U48BIT_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(meterStatus, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0200), ZCL_8BIT_BITMAP_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(unitofMeasure, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0300), ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(summationFormatting, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0303), ZCL_8BIT_BITMAP_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(meteringDeviceType, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0306), ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+#define SIMPLE_METERING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = SIMPLE_METERING_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = SIMPLE_METERING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = SIMPLE_METERING_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define SIMPLE_METERING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = SIMPLE_METERING_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = SIMPLE_METERING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = SIMPLE_METERING_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define DEFINE_SIMPLE_METERING_CLUSTER(cltype, clattributes, clcommands) SIMPLE_METERING_CLUSTER_##cltype(clattributes, clcommands)
+
+BEGIN_PACK
+
+/*************************************************************************//**
+ \brief ZCL Simple Metering Cluster Descriptor
+
+ For internal use
+*****************************************************************************/
+typedef struct PACK
+{
+ //!Reading information attribute set (Id = 0x00)
+ //!Current Summation Delivered Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000)
+ uint8_t type; //!<Attribute data type (Unsignet 48 bit Integer)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[6]; //!<Attribute value
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange[6]; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } currentSummationDelivered;
+
+ //!Meter status attribute set (Id = 0x02)
+ //!Meter Status Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ //!Attribute value
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(8,(
+ uint8_t checkMeter :1, //!<Check Meter
+ uint8_t lowBattery :1, //!<Low Battery
+ uint8_t tamperDetect :1, //!<Tamper Detect
+ uint8_t powerFailure :1, //!<Power Failure
+ uint8_t powerQuality :1, //!<Power Quality
+ uint8_t leakDetect :1, //!<Leak Detect
+ uint8_t serviceDisconnectOpen :1, //!<Service Disconnect Open
+ uint8_t reserved :1 //!<Reserved
+ ))
+ } value;
+ } meterStatus;
+
+ //!Formating attribute set (Id = 0x03)
+ //!UnitofMeasure Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0300)
+ uint8_t type; //!<Attribute type (8-bit Enumeration)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value
+ } unitofMeasure;
+
+ //!Summation Formatting Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0303)
+ uint8_t type; //!<Attribute type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ /**
+ \brief Attribute value
+ Summation Formatting provides a method to properly decipher the number of digits
+ and the decimal location of the values found in the Summation Information Set
+ of the attributes.
+ */
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(3,(
+ uint8_t right :3, //!<Number of Digits to the right of the Decimal Point
+ uint8_t left :4, //!<Number of Digits to the left of the Decimal Point
+ uint8_t zeros :1 //!<If set, suppress leading zeros
+ ))
+ } value;
+ } summationFormatting;
+
+ //!Metering Device Type Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0306)
+ uint8_t type; //!<Attribute type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ /**
+ \brief Attribute value
+ MeteringDeviceType provides a lable for identifying of metering device present.
+ The attribute are enumerated values presenting Energy, GAs, Water, Thermal, and
+ mirrored metering device.
+ */
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(6,(
+ uint8_t electricMetering :1, //!<Electric Metering (0)
+ uint8_t gasMetering :1, //!<Gas Metering (1)
+ uint8_t waterMetering :1, //!<Water Metering (2)
+ uint8_t thermalMetering :1, //!<Thermal Metering (3)
+ uint8_t pressureMetering :1, //!<Pressure Metering (4)
+ uint8_t reserved :3 //!<Reserved
+ ))
+ } value;
+ } meteringDeviceType;
+} SimpleMeteringServerClusterAttributes_t;
+END_PACK
+#endif // _SIMPLEMETERINGCLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h
new file mode 100644
index 00000000..9e4e7ffc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h
@@ -0,0 +1,71 @@
+/************************************************************************//**
+ \file zclTaskManager.h
+
+ \brief
+ The header file describes the public interface of ZCL Task Manager
+
+ The file describes the public interface and types of ZCL Task Manager
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTMs).
+
+ \internal
+ History:
+ 01.12.08 A. Poptashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLTASKMANAGER_H
+#define _ZCLTASKMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include "types.h"
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** Identifiers of ZCL task handlers. */
+typedef enum _ZclTaskId_t
+{
+ ZCL_CAPS_TASK_ID,
+ ZCL_SUBTASK_ID,
+ ZCL_PARSER_TASK_ID,
+ ZCL_TASKS_SIZE
+} ZclTaskId_t;
+
+/** Bit array of ZCL task. If bit is '1' the task is posted. */
+typedef uint8_t ZclTaskBitMask_t;
+
+/** Type of iterator for task identifiers. */
+typedef uint8_t ZclTaskIdIter_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+ \brief ZCL Task Manager post task function
+ \param[in] taskId - Determines the task Id to be posted (ZclTaskId_t should be used)
+*****************************************************************************/
+void zclPostTask(ZclTaskId_t taskId);
+
+/*************************************************************************//**
+ \brief Task Manager task handler function
+*****************************************************************************/
+void ZCL_TaskHandler(void);
+
+#endif //#ifndef _ZCLTASKMANAGER_H
+
+//eof zclTaskManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h
new file mode 100644
index 00000000..813313d9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ \file zclTemperatureMeasurement.h
+
+ \brief
+ The file describes the types and interface of the Temperature Measurement cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 18.01.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _ZCLTEMPERATUREMEASUREMENT_H_
+#define _ZCLTEMPERATUREMEASUREMENT_H_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <types.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+* \brief server attributes amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 3
+
+/**
+* \brief server commands amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+/**
+* \brief client attributes amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+* \brief client commands amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+
+/**
+* \brief Supported attribue id
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+
+/**
+ * \brief server define attributes macros
+*/
+#define ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES(reportMin, reportMax) \
+ DEFINE_REPORTABLE_ATTRIBUTE(measuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID, reportMin, reportMax), \
+ DEFINE_ATTRIBUTE(minMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(maxMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = TEMPERATURE_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) (clattributes), \
+ .commandsAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT() \
+ { \
+ .id = TEMPERATURE_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK {
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ int16_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } measuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } minMeasuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } maxMeasuredValue ;
+} ZCL_TemperatureMeasurementClusterAttributes_t ;
+END_PACK
+
+
+#endif /* _ZCLTEMPERATUREMEASUREMENT_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h
new file mode 100644
index 00000000..c88f7cbd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h
@@ -0,0 +1,214 @@
+/***************************************************************************//**
+ \file zclThermostatCluster.h
+
+ \brief
+ The header file describes the ZCL Thermostat Cluster and its interface
+
+ The file describes the types and interface of the ZCL Thermostat Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 01.07.10 A. Egorov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLTHERMOSTATCLUSTER_H
+#define _ZCLTHERMOSTATCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+\brief Thermostat Cluster server attributes amount
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/***************************************************************************//**
+\brief Thermostat Cluster client attributes amount. Clinet doesn't have attributes
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/***************************************************************************//**
+\brief Thermostat Cluster commands amount
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_COMMANDS_AMOUNT 1
+
+/***************************************************************************//**
+\brief Thermostat Cluster server's attributes identifiers
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_LOCAL_TEMPERATURE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_THERMOSTAT_CLUSTER_OCCUPIED_COOLING_SETPOINT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+#define ZCL_THERMOSTAT_CLUSTER_OCCUPIED_HEATING_SETPOINT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+#define ZCL_THERMOSTAT_CLUSTER_CONTROL_SEQUENCE_OF_OPERATION_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001b)
+#define ZCL_THERMOSTAT_CLUSTER_SYSTEM_MODE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001c)
+
+/***************************************************************************//**
+\brief Thermostat Cluster client's command identifiers
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_SETPOINT_RAISE_LOWER_COMMAND_ID 0x00
+
+/***************************************************************************//**
+\brief Thermostat Cluster server define attributes macros
+*******************************************************************************/
+
+#define ZCL_DEFINE_THERMOSTAT_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(localTemperature, ZCL_READONLY_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_LOCAL_TEMPERATURE_SERVER_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID, min, max),\
+ DEFINE_ATTRIBUTE(occupiedCoolingSetpoint, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_OCCUPIED_COOLING_SETPOINT_SERVER_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(occupiedHeatingSetpoint, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_OCCUPIED_HEATING_SETPOINT_SERVER_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(controlSequenceofOperation, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_CONTROL_SEQUENCE_OF_OPERATION_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(systemMode, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_SYSTEM_MODE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+
+/***************************************************************************//**
+\brief Thermostat Cluster define commands macros
+*******************************************************************************/
+
+#define ZCL_DEFINE_THERMOSTAT_CLUSTER_COMMANDS(setpointCommandInd) \
+ DEFINE_COMMAND(setpointCommand, ZCL_THERMOSTAT_CLUSTER_SETPOINT_RAISE_LOWER_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ setpointCommandInd)
+
+
+/***************************************************************************//**
+\brief Thermostat Cluster definition macros
+*******************************************************************************/
+
+#define THERMOSTAT_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = THERMOSTAT_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_THERMOSTAT_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_THERMOSTAT_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define THERMOSTAT_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = THERMOSTAT_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_THERMOSTAT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_THERMOSTAT_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_THERMOSTAT_CLUSTER(cltype, clattributes, clcommands) \
+ THERMOSTAT_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/***************************************************************************//**
+\brief Setpoint Raise/Lower Command Payload format
+*******************************************************************************/
+typedef struct PACK
+{
+ int8_t mode;
+ int8_t amount;
+} ZCL_SetpointRaiseLower_t;
+
+/***************************************************************************//**
+\brief Thermostat Cluster server's attributes
+*******************************************************************************/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ int16_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } localTemperature ;
+
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } occupiedCoolingSetpoint;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } occupiedHeatingSetpoint;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int8_t value;
+ } controlSequenceofOperation;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int8_t value;
+ } systemMode;
+} ZCL_ThermostatClusterServerAttributes_t;
+
+END_PACK
+
+/***************************************************************************//**
+\brief Thermostat Cluster commands
+*******************************************************************************/
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*setpointCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_SetpointRaiseLower_t * payload);
+ } setpointCommand;
+} ZCL_ThermostatClusterCommands_t;
+
+
+#endif /* _ZCLTHERMOSTATCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h
new file mode 100644
index 00000000..d2e30218
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h
@@ -0,0 +1,220 @@
+/***************************************************************************//**
+ \file zclTimeCluster.h
+
+ \brief
+ The header file describes the ZCL Time Cluster and its interface
+
+ The file describes the types and interface of the ZCL Time Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 02.01.09 A. Potashov - Created.
+*******************************************************************************/
+#ifndef _ZCLTIMECLUSTER_H
+#define _ZCLTIMECLUSTER_H
+
+/*!
+This cluster provides a basic interface to a real-time clock. The clock time may be
+read and also written, in order to synchronize the clock (as close as practical) to a
+time standard. This time standard is the number of seconds since 0 hrs 0 mins 0
+sec on 1st January 2000 UTC (Universal Coordinated Time).
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster server side commands amount
+*******************************************************************************/
+#define ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+//The Time and TimeStatus attributes
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster client side commands amount
+*******************************************************************************/
+#define ZCL_TIME_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There is no any attributes at client cluster side
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster commands amount
+*******************************************************************************/
+#define ZCL_TIME_CLUSTER_COMMANDS_AMOUNT 0
+//There is no any commands at client cluster side
+
+
+//!ZCL Time Cluster server side Time attribute id
+#define ZCL_TIME_CLUSTER_SERVER_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+//!ZCL Time Cluster server side TimeStatus attribute id
+#define ZCL_TIME_CLUSTER_SERVER_TIME_STATUS_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Time Cluster server side TimeZone attribute id
+#define ZCL_TIME_CLUSTER_SERVER_TIME_ZONE_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Time Cluster server side DstStart attribute id
+#define ZCL_TIME_CLUSTER_SERVER_DST_START_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+//!ZCL Time Cluster server side DstEnd attribute id
+#define ZCL_TIME_CLUSTER_SERVER_DST_END_ATRIBUTE_ID CCPU_TO_LE16(0x0004)
+//!ZCL Time Cluster server side DstShift attribute id
+#define ZCL_TIME_CLUSTER_SERVER_DST_SHIFT_ATTRIBUTE_ID CCPU_TO_LE16(0x0005)
+//!ZCL Time Cluster server side StandardTime attribute id
+#define ZCL_TIME_CLUSTER_SERVER_STANDARD_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0006)
+//!ZCL Time Cluster server side LocalTime attribute id
+#define ZCL__TIME_CLUSTER_SERVER_LOCAL_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0007)
+
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Time Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Time Cluster server side related attributes
+ ZCL_TimeClusterServerAttributes_t timeClusterAttributes = ZCL_DEFINE_TIME_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_TIME_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(time, ZCL_READWRITE_ATTRIBUTE, ZCL_TIME_CLUSTER_SERVER_TIME_ATTRIBUTE_ID, ZCL_UTC_TIME_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(timeStatus, ZCL_READWRITE_ATTRIBUTE, ZCL_TIME_CLUSTER_SERVER_TIME_STATUS_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID) \
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster server side defining macros
+
+ This macros should be used with #DEFINE_ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES for
+ ZCL Time Cluster server side defining in application.
+
+ \param attributes - pointer to cluster server attributes (ZCL_TimeClusterServerAttributes_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Time Cluster server side related attributes
+ ZCL_TimeClusterServerAttributes_t timeClusterServerAttributes = DEFINE_ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_TIME_CLUSTER_SERVER(&timeClusterServerAttributes),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define TIME_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = TIME_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_TIME_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster client side defining macros
+
+ This macros should be used for ZCL Time Cluster client side defining in application.
+
+ \return None
+
+ \internal
+ //The typical code is:
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_TIME_CLUSTER_CLIENT(),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define TIME_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = TIME_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY }, \
+ .attributesAmount = ZCL_TIME_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_TIME_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DEFINE_TIME_CLUSTER(cltype, clattributes, clcommands) TIME_CLUSTER_##cltype(clattributes, clcommands)
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Time Cluster attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ \brief Time attribute (R/W, M)
+
+ The Time attribute is 32-bits in length and holds the time value of a real time
+ clock. This attribute has data type UTCTime, but note that it may not actually be
+ synchronised to UTC - see discussion of the TimeStatus attribute below.
+ If the Master bit of the TimeStatus attribute has a value of 0, writing to this
+ attribute shall set the real time clock to the written value, otherwise it cannot be
+ written. The value 0xffffffff indicates an invalid time.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000)
+ uint8_t type; //!<Attribute type (UTCTime - 32-bit) (typeId = 0xe2, #ZCL_UTC_TIME_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ ZCL_UTCTime_t value; //!<Attribute value (default none)
+ } time;
+
+ /*!
+ \brief TimeStatus attribute (R/W, M)
+
+ The Master and Synchronized bits together provide information on how closely
+ the Time attribute conforms to the time standard.
+ The Master bit specifies whether the real time clock corresponding to the Time
+ attribute is internally set to the time standard. This bit is not writeable
+ if a value is written to the TimeStatus attribute, this bit does not change.
+ The Synchronized bit specifies whether Time has been set over the network to
+ synchronize it (as close as may be practical) to the time standard. This
+ bit must be explicitly written to indicate this i.e. it is not set automatically on
+ writing to the Time attribute. If the Master bit is 1, the value of this bit is 0.
+ If both the Master and Synchronized bits are 0, the real time clock has no defined
+ relationship to the time standard (e.g. it may record the number of seconds since
+ the device was initialized).
+ The MasterZoneDst bit specifies whether the TimeZone, DstStart, DstEnd and
+ DstShift attributes are set internally to correct values for the location of the clock.
+ If not, these attributes need to be set over the network. This bit is not writeable if
+ a value is written to the TimeStatus attribute, this bit does not change.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0001)
+ uint8_t type; //!<Attribute type (8-bit bitmap, typeId = 0x18, #ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ struct PACK //!<Attribute value (default 0b00000000)
+ {
+ LITTLE_ENDIAN_OCTET(4,(
+ uint8_t master :1, //!<Master bit (1 - master clock, 0 - not master clock)
+ uint8_t synchronized :1, //!<Synchronized bit (1- synchronized, 0 - not synchronized)
+ uint8_t masterZoneDst :1, //!<MasterZoneDst bit (1 - master for Time Zone and DST, 0 - not master for Time Zone and DST)
+ uint8_t reserved :5 //!<Reserved field
+ ))
+ } value;
+ } timeStatus;
+} ZCL_TimeClusterServerAttributes_t;
+END_PACK
+#endif // #ifndef _ZCLTIMECLUSTER_H
+
+//eof zclTimeCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h
new file mode 100644
index 00000000..66753adf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h
@@ -0,0 +1,155 @@
+/**************************************************************************//**
+ \file zclZll.h
+
+ \brief
+ ZigBee Light Link (ZLL) functions interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 17.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLL_H
+#define _ZCLZLL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <intrpData.h>
+#include <zcl.h>
+#include <clusters.h>
+#include <zclZllFrameFormat.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+/* Default network parameters, for debug purpose */
+#define ZCL_ZLL_DEFAULT_WORKING_CHANNEL 0x0f
+
+/* ZLL Profile Constants */
+#define APLC_INTERPAN_TRANS_ID_LIFE_TIME 8000 // aplcInterPANTransIdLifeTime
+#define APLC_MAX_PERMIT_JOIN_DURATION 60000 // aplcMaxPermitJoinDuration
+#define APLC_MIN_STARTUP_DELAY_TIME 2000 // aplcMinStartupDelayTime
+#define APLC_RX_WINDOW_DURATIO 5000 // aplcRxWindowDuration
+#define APLC_SCAN_TIMEBASE_DURATION 250 // aplcScanTimeBaseDuration
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZCL_ZllStatus_t
+{
+ ZCL_ZLL_SUCCESS_STATUS = 0x00,
+ ZCL_ZLL_SCAN_RESULT_STATUS = 0xf0,
+ ZCL_ZLL_SCAN_FINISHED_STATUS = 0xf1,
+ ZCL_ZLL_SCAN_ABORTED_STATUS = 0xf2,
+ ZCL_ZLL_IDENTIFY_START_STATUS = 0xf3,
+ ZCL_ZLL_IDENTIFY_STOP_STATUS = 0xf4,
+ ZCL_ZLL_INVALID_SCENARIO_STATUS = 0xf5,
+} ZCL_ZllStatus_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset the ZLL layer
+
+This function should be called prior to using any ZLL features. The only
+function called before ZLL reset is ZCL_ZllIbSetAppData(), which provides
+memory that will be used to store application data.
+
+The function restores ZLL and stack parameters from EEPROM as well as
+applicaiton data.
+******************************************************************************/
+void ZCL_ZllReset(void);
+
+/**************************************************************************//**
+\brief Get next output sequence number
+\returns next output sequence number.
+******************************************************************************/
+uint8_t ZCL_ZllGetSeq(void);
+
+/**************************************************************************//**
+\brief Generate new Transaction Identifier and start transaction timer for it
+******************************************************************************/
+void ZCL_ZllGenerateTransactionId(void);
+
+/**************************************************************************//**
+\brief Get current Transaction Identifier
+\returns Current Transaction Identifier.
+******************************************************************************/
+uint32_t ZCL_ZllTransactionId(void);
+
+/**************************************************************************//**
+\brief Generate new Response Identifier
+******************************************************************************/
+void ZCL_ZllGenerateResponseId(void);
+
+/**************************************************************************//**
+\brief Set Response Identifier to specified value
+\param[in] rid - Response Identifier value to be set
+******************************************************************************/
+void ZCL_ZllSetResponseId(uint32_t rid);
+
+/**************************************************************************//**
+\brief Get current Response Identifier
+\returns Current Response Identifier.
+******************************************************************************/
+uint32_t ZCL_ZllResponseId(void);
+
+/**************************************************************************//**
+\brief Get other device's address (after Scan Request has been received)
+\returns Other device's extended address.
+******************************************************************************/
+uint64_t ZCL_ZllOtherDeviceAddress(void);
+
+/**************************************************************************//**
+\brief Check if Scan Response has already been received from the device
+\returns true if Scan Response has already been received from the device.
+******************************************************************************/
+bool ZCL_ZllDublicateRejection(ExtAddr_t ieee);
+
+/**************************************************************************//**
+\brief Assign a new address from the range of free addresses
+\returns Newly assigned address or 0 in case of an error.
+******************************************************************************/
+ShortAddr_t ZCL_ZllAssignAddress(void);
+
+/**************************************************************************//**
+\brief Assign a new group ID from the range of free group IDs
+\returns Newly assigned group ID or 0 in case of an error.
+******************************************************************************/
+uint16_t ZCL_ZllAssignGroupId(void);
+
+/**************************************************************************//**
+\brief Check if the device is in the Factory New state
+
+A router in ZLL applications loses its factory new state after it receives the
+ZLL start network request during commissioning. An end device becomes not a
+factory new device after it commissions the first router, thus creating its own
+network, or joins an existing network through another end device (this is called
+touch link between end devices).
+
+The application may switch a device back to the factory new state by calling the
+ZCL_ZllResetToFactoryNewRequest() function.
+
+\returns Factory New status: \c true if the device is in the Factory New state
+******************************************************************************/
+bool ZCL_ZllIsFactoryNew(void);
+
+/**************************************************************************//**
+\brief Get other device's address (after Scan Request has been received)
+\param[in] header - pointer to the header to be filled
+\param[in] commandId - command ID to be set in the header
+******************************************************************************/
+void zclZllFillFrameHeader(ZclZllFrameHeader_t *header, ZclZllCommandId_t commandId);
+
+#endif // _ZCLZLL_H
+
+// eof zclZll.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h
new file mode 100644
index 00000000..1c74eddb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h
@@ -0,0 +1,308 @@
+/***************************************************************************//**
+ \file zclZllBasicCluster.h
+
+ \brief
+ The header file describes the ZLL Basic Cluster and its interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 03.01.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLBASICCLUSTER_H
+#define _ZCLZLLBASICCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 9
+//The ZCLVersion and PowerSource attributes
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+//There are no any commands at the server side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+//There are no any commands at the client side
+
+
+//Atribute Ids of Basic Device Information Attribute Set at the server side
+//!ZCL Basic Cluster server side ZCLVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+//!ZCL Basic Cluster server side ApplicationVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Basic Cluster server side StackVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Basic Cluster server side HWVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+//!ZCL Basic Cluster server side ManufacturerName attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+//!ZCL Basic Cluster server side ModelIdentifier attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID CCPU_TO_LE16(0x0005)
+//!ZCL Basic Cluster server side DateCode attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID CCPU_TO_LE16(0x0006)
+//!ZCL Basic Cluster server side PowerSource attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID CCPU_TO_LE16(0x0007)
+
+//Atribute Ids of Basic Device Settings Attribute Set at the server side
+//!ZCL Basic Cluster server side LocationDescription attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_LOCATION_DESCRIPTION_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+//!ZCL Basic Cluster server side PhysicalEnvironment attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+//!ZCL Basic Cluster server side DeviceEnabled attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DEVICE_ENABLED_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+//!ZCL Basic Cluster server side AlarmMask attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ALARM_MASK_ATTRIBUTE_ID CCPU_TO_LE16(0x0013)
+
+//!ZLL Basic Cluster server side SWBuildID attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_SW_BUILD_ID_ATTRIBUTE_ID CCPU_TO_LE16(0x4000)
+
+//!ZCL Basic Cluster server side ResetToFactoryDeafaults commabd id
+#define ZCL_BASIC_CLUSTER_SERVER_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID 0x00
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Basic Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterAttributes = ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(zclVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID),\
+ DEFINE_ATTRIBUTE(applicationVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(stackVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(hwVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(manufacturerName, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(modelIdentifier, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(dateCode, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(powerSource, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(swBuildId, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_SW_BUILD_ID_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID)
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side defining macros
+
+ This macros should be used with #ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES for
+ ZCL Basic Cluster server side defining in application.
+
+ \param attributes - pointer to cluster server attributes (ZCL_BasicClusterServerAttributes_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterServerAttributes = DEFINE_ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_SERVER(&basicClusterServerAttributes),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side defining macros
+
+ This macros should be used for ZCL Basic Cluster client side defining in application.
+
+ \return None
+
+ \internal
+ //The typical code is:
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_CLIENT(),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_CLIENT() \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, .ackRequest = 1}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Basic Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Basic Device Information attribute set (Id == 0x00)
+
+ /*!ZCL Version attribute (Read only, M)
+ The ZCLVersion attribute is 8-bits in length and specifies the version number of
+ the ZigBee Cluster Library that all clusters on this endpoint conform to. For the
+ initial version of the ZCL, this attribute shall be set to 0x01.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } zclVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0001, #ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } applicationVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0002, #ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } stackVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0003, #ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } hwVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0004, #ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } manufacturerName;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0005, #ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } modelIdentifier;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0006, #ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } dateCode;
+
+ /*!Power Source attribute (Read only, M)
+ The PowerSource attribute is 8-bits in length and specifies the source(s) of power
+ available to the device. Bits b0 of this attribute represent the primary power
+ source of the device and bit b7 indicates whether the device has a secondary power
+ source in the form of a battery backup.
+
+ Bits b0 of this attribute shall be set to one of the non-reserved values:
+ 0x00 - Unknown
+ 0x01 - Mains (single phase)
+ 0x02 - Mains (3 phase)
+ 0x03 - Battery
+ 0x04 - DC source
+ 0x05 - Emergency mains constantly powered
+ 0x06 - Emergency mains and transfer switch
+ 0x07-0x7f - Reserved
+
+ Bit b7 of this attribute shall be set to 1 if the device has a secondary power source
+ in the form of a battery backup. Otherwise, bit b7 shall be set to 0.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0007, #ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (8-bit enumeration, #ZCL_8BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } powerSource;
+
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x4000, #ZCL_BASIC_CLUSTER_SERVER_SW_BUILD_ID_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } swBuildId;
+
+ //!Basic Device Settings attribute set (Id == 0x01)
+} ZCL_BasicClusterServerAttributes_t;
+
+END_PACK
+
+#endif // _ZCLZLLBASICCLUSTER_H
+
+//eof zclZllBasicCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h
new file mode 100644
index 00000000..941f0f62
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h
@@ -0,0 +1,1004 @@
+/************************************************************************//**
+ \file zclZllColorControlCluster.h
+
+ \brief
+ The header file describes the ZLL Color Cluster.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 07.07.11 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _ZCLZLLCOLORCONTROLCLUSTER_H
+#define _ZCLZLLCOLORCONTROLCLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/**
+ * \brief ZLL Server Cluster attributes amount.
+*/
+#define ZCL_COLOR_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 32
+
+/**
+ * \brief ZLL Client Cluster attributes amount.
+*/
+#define ZCL_COLOR_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief ZLL Cluster server's attributes identifiers
+*/
+
+#define ZCL_ZLL_CLUSTER_CURRENT_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_ZLL_CLUSTER_CURRENT_SATURATION_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_ZLL_CLUSTER_REMAINING_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+#define ZCL_ZLL_CLUSTER_CURRENT_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+#define ZCL_ZLL_CLUSTER_CURRENT_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+#define ZCL_ZLL_CLUSTER_COLOR_MODE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0008)
+#define ZCL_ZLL_CLUSTER_NUMBER_OF_PRIMARIES_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+#define ZCL_ZLL_CLUSTER_PRIMARY_1_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+#define ZCL_ZLL_CLUSTER_PRIMARY_1_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+#define ZCL_ZLL_CLUSTER_PRIMARY_1_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0013)
+#define ZCL_ZLL_CLUSTER_PRIMARY_2_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0015)
+#define ZCL_ZLL_CLUSTER_PRIMARY_2_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0016)
+#define ZCL_ZLL_CLUSTER_PRIMARY_2_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0017)
+#define ZCL_ZLL_CLUSTER_PRIMARY_3_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0019)
+#define ZCL_ZLL_CLUSTER_PRIMARY_3_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001A)
+#define ZCL_ZLL_CLUSTER_PRIMARY_3_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001B)
+#define ZCL_ZLL_CLUSTER_PRIMARY_4_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0020)
+#define ZCL_ZLL_CLUSTER_PRIMARY_4_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0021)
+#define ZCL_ZLL_CLUSTER_PRIMARY_4_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0022)
+#define ZCL_ZLL_CLUSTER_PRIMARY_5_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0024)
+#define ZCL_ZLL_CLUSTER_PRIMARY_5_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0025)
+#define ZCL_ZLL_CLUSTER_PRIMARY_5_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0026)
+#define ZCL_ZLL_CLUSTER_PRIMARY_6_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0028)
+#define ZCL_ZLL_CLUSTER_PRIMARY_6_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0029)
+#define ZCL_ZLL_CLUSTER_PRIMARY_6_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x002A)
+/* Additional attributes */
+#define ZCL_ZLL_CLUSTER_ENHANCED_CURRENT_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4000)
+#define ZCL_ZLL_CLUSTER_ENHANCED_COLOR_MODE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4001)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_ACTIVE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4002)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_DIRECTION_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4003)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4004)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_START_ENHANCED_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4005)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_STOP_ENHANCED_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4006)
+
+#define DEFINE_COLOR_CONTROL_CLUSTER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(currentHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_HUE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentSaturation, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_SATURATION_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(remainingTime, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_REMAINING_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentX, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentY, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorMode, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_MODE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(numberOfPrimaries, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_NUMBER_OF_PRIMARIES_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary1X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_1_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary1Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_1_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary1XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_1_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary2X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_2_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary2Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_2_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary2XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_2_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary3X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_3_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary3Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_3_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary3XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_3_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary4X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_4_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary4Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_4_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary4XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_4_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary5X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_5_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary5Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_5_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary5XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_5_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary6X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_6_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary6Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_6_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary6XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_6_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(enhancedCurrentHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_ENHANCED_CURRENT_HUE_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(enhancedColorMode, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_ENHANCED_COLOR_MODE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopActive, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_ACTIVE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopDirection, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_DIRECTION_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopTime, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopStartEnhancedHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_START_ENHANCED_HUE_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopStopEnhancedHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_STOP_ENHANCED_HUE_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/**
+ * \brief ZLL Client Cluster commands amount.
+*/
+#define ZCL_COLOR_CONTROL_CLUSTER_COMMANDS_AMOUNT 16
+
+/**
+ * \brief ZLL Client Cluster commands identifiers.
+*/
+#define MOVE_TO_HUE_COMMAND_ID 0x00
+#define MOVE_HUE_COMMAND_ID 0x01
+#define STEP_HUE_COMMAND_ID 0x02
+#define MOVE_TO_SATURATION_COMMAND_ID 0x03
+#define MOVE_SATURATION_COMMAND_ID 0x04
+#define STEP_SATURATION_COMMAND_ID 0x05
+#define MOVE_TO_HUE_AND_SATURATION_COMMAND_ID 0x06
+#define MOVE_TO_COLOR_COMMAND_ID 0x07
+#define MOVE_COLOR_COMMAND_ID 0x08
+#define STEP_COLOR_COMMAND_ID 0x09
+/* Additional commands */
+#define ENHANCED_MOVE_TO_HUE_COMMAND_ID 0x40
+#define ENHANCED_MOVE_HUE_COMMAND_ID 0x41
+#define ENHANCED_STEP_HUE_COMMAND_ID 0x42
+#define ENHANCED_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID 0x43
+#define COLOR_LOOP_SET_COMMAND_ID 0x44
+#define STOP_MOVE_STEP_COMMAND_ID 0x47
+
+
+#define ZCL_COLOR_CONTROL_CLUSTER_COMMANDS(moveToHueInd, \
+ moveHueInd, \
+ stepHueInd, \
+ moveToSaturationInd, \
+ moveSaturationInd, \
+ stepSaturationInd, \
+ moveToHueAndSaturationInd, \
+ moveToColorInd, \
+ moveColorInd, \
+ stepColorInd, \
+ enhancedMoveToHueInd, \
+ enhancedMoveHueInd, \
+ enhancedStepHueInd, \
+ enhancedMoveToHueAndSaturationInd, \
+ colorLoopSetInd, \
+ stopMoveStepInd) \
+ DEFINE_COMMAND(moveToHueCommand, MOVE_TO_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToHueInd), \
+ DEFINE_COMMAND(moveHueCommand, MOVE_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveHueInd), \
+ DEFINE_COMMAND(stepHueCommand, STEP_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stepHueInd), \
+ DEFINE_COMMAND(moveToSaturationCommand, MOVE_TO_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToSaturationInd), \
+ DEFINE_COMMAND(moveSaturationCommand, MOVE_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveSaturationInd), \
+ DEFINE_COMMAND(stepSaturationCommand, STEP_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stepSaturationInd), \
+ DEFINE_COMMAND(moveToHueAndSaturationCommand, MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToHueAndSaturationInd), \
+ DEFINE_COMMAND(moveToColorCommand, MOVE_TO_COLOR_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToColorInd), \
+ DEFINE_COMMAND(moveColorCommand, MOVE_COLOR_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveColorInd), \
+ DEFINE_COMMAND(stepColorCommand, STEP_COLOR_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stepColorInd), \
+ DEFINE_COMMAND(enhancedMoveToHueCommand, ENHANCED_MOVE_TO_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedMoveToHueInd), \
+ DEFINE_COMMAND(enhancedMoveHueCommand, ENHANCED_MOVE_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedMoveHueInd), \
+ DEFINE_COMMAND(enhancedStepHueCommand, ENHANCED_STEP_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedStepHueInd), \
+ DEFINE_COMMAND(enhancedMoveToHueAndSaturationCommand, ENHANCED_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedMoveToHueAndSaturationInd), \
+ DEFINE_COMMAND(colorLoopSetCommand, COLOR_LOOP_SET_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), colorLoopSetInd), \
+ DEFINE_COMMAND(stopMoveStepCommand, STOP_MOVE_STEP_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stopMoveStepInd)
+
+#define ZLL_COLOR_CONTROL_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = COLOR_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COLOR_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COLOR_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define ZLL_COLOR_CONTROL_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = COLOR_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COLOR_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COLOR_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+#define DEFINE_COLOR_CONTROL_CLUSTER(cltype, clattributes, clcommands) ZLL_COLOR_CONTROL_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Color Control Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentHue;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentSaturation;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } remainingTime;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentX;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentY;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } colorMode;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } numberOfPrimaries;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary1X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary1Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary1XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary2X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary2Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary2XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary3X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary3Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary3XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary4X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary4Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary4XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary5X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary5Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary5XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary6X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary6Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary6XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } enhancedCurrentHue;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } enhancedColorMode;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } colorLoopActive;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } colorLoopDirection;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } colorLoopTime;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } colorLoopStartEnhancedHue;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } colorLoopStopEnhancedHue;
+
+} ZCL_ColorControlClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief MoveToHue command direction values
+*/
+typedef enum _ZCL_ZllMoveToHueDirection_t
+{
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_SHORTEST_DISTANCE = 0x00,
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_LONGEST_DISTANCE = 0x01,
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_UP = 0x02,
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_DOWN = 0x03,
+} ZCL_ZllMoveToHueDirection_t;
+
+/**
+ * \brief MoveHue command moveMode values
+*/
+typedef enum _ZCL_ZllMoveHueMoveMode_t
+{
+ ZCL_ZLL_MOVE_HUE_MOVE_MODE_STOP = 0x00,
+ ZCL_ZLL_MOVE_HUE_MOVE_MODE_UP = 0x01,
+ ZCL_ZLL_MOVE_HUE_MOVE_MODE_DOWN = 0x03,
+} ZCL_ZllMoveHueMoveMode_t;
+
+/**
+ * \brief StepHue command stepMode values
+*/
+typedef enum _ZCL_ZllStepHueStepMode_t
+{
+ ZCL_ZLL_STEP_HUE_STEP_MODE_UP = 0x01,
+ ZCL_ZLL_STEP_HUE_STEP_MODE_DOWN = 0x03,
+} ZCL_ZllStepHueStepMode_t;
+
+/**
+ * \brief MoveSaturation command moveMode values
+*/
+typedef enum _ZCL_ZllMoveSaturationMoveMode_t
+{
+ ZCL_ZLL_MOVE_SATURATION_MOVE_MODE_STOP = 0x00,
+ ZCL_ZLL_MOVE_SATURATION_MOVE_MODE_UP = 0x01,
+ ZCL_ZLL_MOVE_SATURATION_MOVE_MODE_DOWN = 0x03,
+} ZCL_ZllMoveSaturationMoveMode_t;
+
+/**
+ * \brief StepSaturation command stepMode values
+*/
+typedef enum _ZCL_ZllStepSaturationStepMode_t
+{
+ ZCL_ZLL_STEP_SATURATION_STEP_MODE_UP = 0x01,
+ ZCL_ZLL_STEP_SATURATION_STEP_MODE_DOWN = 0x03,
+} ZCL_ZllStepSaturationStepMode_t;
+
+/**
+ * \brief ColorLoopSet command action values
+*/
+typedef enum _ZCL_ZllColorLoopSetAction_t
+{
+ ZCL_ZLL_COLOR_LOOP_SET_ACTION_DEACTIVATE = 0x00,
+ ZCL_ZLL_COLOR_LOOP_SET_ACTION_ACTIVATE = 0x01,
+ ZCL_ZLL_COLOR_LOOP_SET_ACTION_ACTIVATE_ENHANCED = 0x02,
+} ZCL_ZllColorLoopSetAction_t;
+
+/**
+ * \brief ColorLoopSet command direction values
+*/
+typedef enum _ZCL_ZllColorLoopSetDirection_t
+{
+ ZCL_ZLL_COLOR_LOOP_SET_DIRECTION_DECREMENT_HUE = 0x00,
+ ZCL_ZLL_COLOR_LOOP_SET_DIRECTION_INCREMENT_HUE = 0x01,
+} ZCL_ZllColorLoopSetDirection_t;
+
+/**
+ * \brief EnhancedColorMode values
+*/
+typedef enum _ZCL_ZllEnhancedColorMode_t
+{
+ ZCL_ZLL_CURRENT_HUE_AND_CURRENT_SATURATION = 0x00,
+ ZCL_ZLL_CURRENT_X_AND_CURRENT_Y = 0x01,
+ ZCL_ZLL_COLOR_TEMPERATURE = 0x02,
+ ZCL_ZLL_ENHANCED_CURRENT_HUE_AND_CURRENT_SATURATION = 0x03,
+} ZCL_ZllEnhancedColorMode_t;
+
+BEGIN_PACK
+/**
+ * \brief MoveToHue command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToHueCommand_t
+{
+ uint8_t hue;
+ uint8_t direction;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToHueCommand_t;
+
+/**
+ * \brief MoveHue command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveHueCommand_t
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_ZllMoveHueCommand_t;
+
+/**
+ * \brief StepHue command payload format
+*/
+typedef struct PACK _ZCL_ZllStepHueCommand_t
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint8_t transitionTime; /* uint16_t ? */
+} ZCL_ZllStepHueCommand_t;
+
+/**
+ * \brief MoveToSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToSaturationCommand_t
+{
+ uint8_t saturation;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToSaturationCommand_t;
+
+/**
+ * \brief MoveSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveSaturationCommand_t
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_ZllMoveSaturationCommand_t;
+
+/**
+ * \brief StepSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllStepSaturationCommand_t
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint8_t transitionTime; /* uint16_t ? */
+} ZCL_ZllStepSaturationCommand_t;
+
+/**
+ * \brief MoveToHueAndSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToHueAndSaturationCommand_t
+{
+ uint8_t hue;
+ uint8_t saturation;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToHueAndSaturationCommand_t;
+
+/**
+ * \brief MoveToColor command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToColorCommand_t
+{
+ uint16_t colorX;
+ uint16_t colorY;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToColorCommand_t;
+
+/**
+ * \brief MoveColor command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveColorCommand_t
+{
+ int16_t rateX;
+ int16_t rateY;
+} ZCL_ZllMoveColorCommand_t;
+
+/**
+ * \brief StepColor command payload format
+*/
+typedef struct PACK _ZCL_ZllStepColorCommand_t
+{
+ int16_t stepX;
+ int16_t stepY;
+ uint16_t transitionTime;
+} ZCL_ZllStepColorCommand_t;
+
+/**
+ * \brief EnhancedMoveToHue command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedMoveToHueCommand_t
+{
+ uint16_t enhancedHue;
+ uint8_t direction;
+ uint16_t transitionTime;
+} ZCL_ZllEnhancedMoveToHueCommand_t;
+
+/**
+ * \brief EnhancedMoveHue command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedMoveHueCommand_t
+{
+ uint8_t moveMode;
+ uint16_t rate;
+} ZCL_ZllEnhancedMoveHueCommand_t;
+
+/**
+ * \brief EnhancedStepHue command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedStepHueCommand_t
+{
+ uint8_t stepMode;
+ uint16_t stepSize;
+ uint16_t transitionTime;
+} ZCL_ZllEnhancedStepHueCommand_t;
+
+/**
+ * \brief EnhancedMoveToHueAndSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedMoveToHueAndSaturationCommand_t
+{
+ uint16_t enhancedHue;
+ uint8_t saturation;
+ uint16_t transitionTime;
+} ZCL_ZllEnhancedMoveToHueAndSaturationCommand_t;
+
+/**
+ * \brief ColorLoopSet command payload format
+*/
+typedef struct PACK _ZCL_ZllColorLoopSetCommand_t
+{
+ uint8_t updateFlags;
+ uint8_t action;
+ uint8_t direction;
+ uint16_t time;
+ uint16_t startHue;
+} ZCL_ZllColorLoopSetCommand_t;
+
+/**
+ * \brief Color Control Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ uint16_t currentX;
+ uint16_t currentY;
+ uint16_t enhancedCurrentHue;
+ uint16_t currentSaturation;
+} ZCL_ColorControlClusterExtensionFieldSet_t;
+
+END_PACK
+
+/**
+ * \brief Color Control cluster commands
+ */
+typedef struct _ZCL_ZllColorControlClusterCommands_t
+{
+ //! MoveToHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToHueCommand_t *payload);
+ } moveToHueCommand;
+
+ //! MoveHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x01)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveHueCommand_t *payload);
+ } moveHueCommand;
+
+ //! StepHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x02)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*stepHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllStepHueCommand_t *payload);
+ } stepHueCommand;
+
+ //! MoveToSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x03)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToSaturationCommand_t *payload);
+ } moveToSaturationCommand;
+
+ //! MoveSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x04)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveSaturationCommand_t *payload);
+ } moveSaturationCommand;
+
+ //! StepSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x05)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*stepSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllStepSaturationCommand_t *payload);
+ } stepSaturationCommand;
+
+ //! MoveToHueAndSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x06)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToHueAndSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToHueAndSaturationCommand_t *payload);
+ } moveToHueAndSaturationCommand;
+
+ //! MoveToColor command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x07)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToColor)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToColorCommand_t *payload);
+ } moveToColorCommand;
+
+ //! MoveColor command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x08)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveColor)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveColorCommand_t *payload);
+ } moveColorCommand;
+
+ //! StepColor command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x09)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*stepColor)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllStepColorCommand_t *payload);
+ } stepColorCommand;
+
+ /* Additional commands */
+
+ //! EnhancedMoveToHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x40)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedMoveToHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedMoveToHueCommand_t *payload);
+ } enhancedMoveToHueCommand;
+
+ //! EnhancedMoveHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x41)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedMoveHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedMoveHueCommand_t *payload);
+ } enhancedMoveHueCommand;
+
+ //! EnhancedStepHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x42)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedStepHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedStepHueCommand_t *payload);
+ } enhancedStepHueCommand;
+
+ //! EnhancedMoveToHueAndSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x43)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedMoveToHueAndSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedMoveToHueAndSaturationCommand_t *payload);
+ } enhancedMoveToHueAndSaturationCommand;
+
+ //! ColorLoopSet command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x44)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*colorLoopSet)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllColorLoopSetCommand_t *payload);
+ } colorLoopSetCommand;
+
+ //! StopMoveStep command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x47)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload, (no one for this command)
+ \return none
+ */
+ ZCL_Status_t (*stopMoveStep)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void *payload);
+ } stopMoveStepCommand;
+} ZCL_ColorControlClusterCommands_t;
+
+#endif // _ZCLZLLCOLORCONTROLCLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h
new file mode 100644
index 00000000..75fd07cd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h
@@ -0,0 +1,228 @@
+/***************************************************************************//**
+ \file zclZllCommissioningCluster.h
+
+ \brief
+ The header file describes the ZLL Commissioning Cluster and its interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 04.07.11 A. Taradov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLCOMISSIONINGCLUSTER_H
+#define _ZCLZLLCOMISSIONINGCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Commissioning Server Cluster attributes amount.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Commissioning Client Cluster attributes amount.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Commissioning Client Cluster commands amount.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_COMMANDS_AMOUNT 5
+
+/**
+ * \brief Commissioning Server Cluster commands identifiers.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_ENDPOINT_INFORMATION_COMMAND_ID 0x40
+#define ZCL_COMMISSIONING_CLUSTER_GET_GROUP_IDENTIFIERS_RESPONSE_COMMAND_ID 0x41
+#define ZCL_COMMISSIONING_CLUSTER_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID 0x42
+
+/**
+ * \brief Commissioning Client Cluster commands identifiers.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_GET_GROUP_IDENTIFIERS_COMMAND_ID 0x41
+#define ZCL_COMMISSIONING_CLUSTER_GET_ENDPOINT_LIST_COMMAND_ID 0x42
+
+/*
+ * \brief ZCL Commissioning Cluster commands defining macros
+ */
+
+#define ZCL_DEFINE_COMMISSIONING_CLUSTER_COMMANDS(getGroupIdentifiersInd, getEndpointListInd, \
+ endpointInformationResponseInd, getGroupIdentifiersResponseInd, getEndpointListResponseInd) \
+ DEFINE_COMMAND(getGroupIdentifiersCommand, 0x41, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getGroupIdentifiersInd), \
+ DEFINE_COMMAND(getEndpointListCommand, 0x42, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getEndpointListInd), \
+ DEFINE_COMMAND(endpointInformationResponseCommand, 0x40, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), endpointInformationResponseInd), \
+ DEFINE_COMMAND(getGroupIdentifiersResponseCommand, 0x41, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getGroupIdentifiersResponseInd), \
+ DEFINE_COMMAND(getEndpointListResponseCommand, 0x42, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getEndpointListResponseInd)
+
+
+#define COMMISSIONING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = ZLL_COMMISSIONING_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COMMISSIONING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COMMISSIONING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define COMMISSIONING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = ZLL_COMMISSIONING_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COMMISSIONING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COMMISSIONING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define DEFINE_COMMISSIONING_CLUSTER(cltype, clattributes, clcommands) COMMISSIONING_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief Get Group Identifiers command format
+*/
+typedef struct PACK
+{
+ uint8_t startIndex;
+} ZCL_GetGroupIdentifiers_t;
+
+/**
+ * \brief Get Endpoint List command format
+*/
+typedef struct PACK
+{
+ uint8_t startIndex;
+} ZCL_GetEndpointList_t;
+
+/**
+ * \brief Endpoint Information Response command format
+*/
+typedef struct PACK
+{
+ uint64_t ieeeAddress;
+ uint16_t networkAddress;
+ uint8_t endpointId;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+} ZCL_EndpointInformationResponse_t;
+
+/**
+ * \brief Group Information Record format
+*/
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupType;
+} ZCL_GroupInformationRecord_t;
+
+/**
+ * \brief Endpoint Information Record format
+*/
+typedef struct PACK
+{
+ uint16_t networkAddress;
+ uint8_t endpointId;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+} ZCL_EndpointInformationRecord_t;
+
+/**
+ * \brief Get Group Identifiers Response command format
+*/
+typedef struct PACK
+{
+ uint8_t total;
+ uint8_t startIndex;
+ uint8_t count;
+ ZCL_GroupInformationRecord_t recordList[5];
+} ZCL_GetGroupIdentifiersResponse_t;
+
+/**
+ * \brief Get Endpoint List Response command format
+*/
+typedef struct PACK
+{
+ uint8_t total;
+ uint8_t startIndex;
+ uint8_t count;
+ ZCL_EndpointInformationRecord_t recordList[1];
+} ZCL_GetEndpointListResponse_t;
+
+END_PACK
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getGroupIdentifiersCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupIdentifiers_t *payload);
+ } getGroupIdentifiersCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getEndpointListCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetEndpointList_t *payload);
+ } getEndpointListCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*endpointInformationResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EndpointInformationResponse_t *payload);
+ } endpointInformationResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getGroupIdentifiersResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupIdentifiersResponse_t *payload);
+ } getGroupIdentifiersResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getEndpointListResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetEndpointListResponse_t *payload);
+ } getEndpointListResponseCommand;
+} ZCL_CommissioningClusterCommands_t;
+
+
+#endif // _ZCLZLLCOMISSIONINGCLUSTER_H
+
+// eof zclZllCommissioningCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h
new file mode 100644
index 00000000..e09d3023
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h
@@ -0,0 +1,265 @@
+/**************************************************************************//**
+ \file zclZllFrameFormat.h
+
+ \brief
+ Inter-PAN commands frame formats for ZLL.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 16.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLFRAMEFORMAT_H
+#define _ZCLZLLFRAMEFORMAT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define MAX_DEVICE_INFO_ENTRIES_NUMBER 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZclZllCommandId_t
+{
+ ZCL_ZLL_SCAN_REQUEST_COMMAND_ID = 0x00,
+ ZCL_ZLL_SCAN_RESPONSE_COMMAND_ID = 0x01,
+ ZCL_ZLL_DEVICE_INFO_REQUEST_COMMAND_ID = 0x02,
+ ZCL_ZLL_DEVICE_INFO_RESPONSE_COMMAND_ID = 0x03,
+ ZCL_ZLL_IDENTIFY_REQUEST_COMMAND_ID = 0x06,
+ ZCL_ZLL_RESET_TO_FACTORY_NEW_REQUEST_COMMAND_ID = 0x07,
+ ZCL_ZLL_NETWORK_START_REQUEST_COMMAND_ID = 0x10,
+ ZCL_ZLL_NETWORK_START_RESPONSE_COMMAND_ID = 0x11,
+ ZCL_ZLL_NETWORK_JOIN_ROUTER_REQUEST_COMMAND_ID = 0x12,
+ ZCL_ZLL_NETWORK_JOIN_ROUTER_RESPONSE_COMMAND_ID = 0x13,
+ ZCL_ZLL_NETWORK_JOIN_ENDDEVICE_REQUEST_COMMAND_ID = 0x14,
+ ZCL_ZLL_NETWORK_JOIN_ENDDEVICE_RESPONSE_COMMAND_ID = 0x15,
+ ZCL_ZLL_NETWORK_UPDATE_REQUEST_COMMAND_ID = 0x16,
+} ZclZllCommandId_t;
+
+BEGIN_PACK
+typedef struct PACK
+{
+ struct
+ {
+ uint8_t frameType : 2; /*! Frame type sub-field */
+ uint8_t manufacturerSpecific : 1; /*! Manufacturer specific sub-field */
+ uint8_t direction : 1; /*! Direction sub-field */
+ uint8_t defaultResponse : 1; /*! Disable default response sub-field */
+ uint8_t reserved : 3; /*! Reserved bits. Must have a zero value */
+ } frameControl;
+ uint8_t seq;
+ uint8_t commandId;
+} ZclZllFrameHeader_t;
+
+typedef struct PACK
+{
+ uint8_t logicalType : 2;
+ uint8_t rxOnWhenIdle : 1;
+ uint8_t reserved : 5;
+} ZclZllZigBeeInfo_t;
+
+typedef struct PACK
+{
+ uint8_t factoryNew : 1;
+ uint8_t addressAssignment : 1;
+ uint8_t compoundDevice : 1;
+ uint8_t relayedScanRequest : 1;
+ uint8_t touchLinkInitiator : 1;
+ uint8_t touchLinkTimeWindow : 1; /*! This field is reserved in Scan Request frame */
+ uint8_t reserved : 2;
+} ZclZllInfo_t;
+
+typedef struct PACK
+{
+ uint64_t ieeeAddress;
+ uint8_t endpoint;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ uint8_t sort;
+} ZclZllDeviceInfoEntry_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+} ZclZllScanRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t rssiCorrection;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+ uint16_t keyBitMask;
+ uint32_t responseId;
+ uint64_t extPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t networkAddress;
+ uint8_t numberSubDevices;
+ uint8_t totalGroupIds;
+ // next fields are present only if numberSubDevices == 1
+ union
+ {
+ struct
+ {
+ uint8_t endpoint;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ };
+ uint64_t ieeeRelayerScanRequest1;
+ };
+ /*! This field is present only if zllInfo.relayedScanRequest == 1 */
+ uint64_t ieeeRelayerScanRequest2;
+} ZclZllScanResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t startIndex;
+} ZclZllDeviceInfoRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t numberSubDevices;
+ uint8_t startIndex;
+ uint8_t count;
+ ZclZllDeviceInfoEntry_t entries[MAX_DEVICE_INFO_ENTRIES_NUMBER];
+} ZclZllDeviceInfoResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint16_t identifyTime;
+} ZclZllIdentifyRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+} ZclZllResetToFactoryNewRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t keyIndex;
+ uint8_t encryptedNwkKey[SECURITY_KEY_SIZE];
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint16_t freeNwkAddressRangeBegin;
+ uint16_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+ uint64_t edIeeeAddress;
+ uint16_t edNwkAddress;
+} ZclZllNetworkStartRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t status;
+ uint64_t extendedPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+} ZclZllNetworkStartResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t keyIndex;
+ uint8_t encryptedNwkKey[SECURITY_KEY_SIZE];
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint16_t freeNwkAddressRangeBegin;
+ uint16_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+} ZclZllNetworkJoinRouterRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t status;
+} ZclZllNetworkJoinRouterResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t keyIndex;
+ uint8_t encryptedNwkKey[SECURITY_KEY_SIZE];
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint16_t freeNwkAddressRangeBegin;
+ uint16_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+} ZclZllNetworkJoinEndDeviceRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t status;
+} ZclZllNetworkJoinEndDeviceResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+} ZclZllNetworkUpdateRequestFrame_t;
+
+END_PACK
+
+#endif // _ZCLZLLFRAMEFORMAT_H
+
+// eof zclZllFrameFormat.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h
new file mode 100644
index 00000000..b265c49b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h
@@ -0,0 +1,363 @@
+/***************************************************************************//**
+ \file zclZllGroupsCluster.h
+
+ \brief
+ The header file describes the ZCL ZLL Groups Cluster and its interface
+
+ The file describes the types and interface of the ZCL Groups Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLGROUPSCLUSTER_H
+#define _ZCLZLLGROUPSCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define MAX_GROUPS_IN_GROUP_MEMBERSHIP_RESPONSE 5
+
+/**
+ * \brief Groups Cluster group name support bit
+*/
+
+#define GROUP_NAME_SUPPORT_FLAG 0x80
+
+/**
+ * \brief Groups Cluster server attributes amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Groups Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Groups Cluster commands amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT 10
+
+/**
+ * \brief Groups Cluster server's attributes identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Groups Cluster client's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID 0x03
+#define ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID 0x04
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID 0x05
+
+/**
+ * \brief Groups Cluster servers's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID 0x03
+
+/**
+ * \brief Groups Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_COMMANDS(addGroupCommandInd, viewGroupCommandInd, getGroupMembershipCommandInd, \
+ removeGroupCommandInd, removeAllGroupsCommandInd, addGroupIfIdentifyingCommandInd, \
+ addGroupResponseCommandInd, viewGroupResponseCommandInd, getGroupMembershipResponseCommandInd, \
+ removeGroupResponseCommandInd) \
+ DEFINE_COMMAND(addGroupCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupCommandInd), \
+ DEFINE_COMMAND(viewGroupCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipCommandInd), \
+ DEFINE_COMMAND(removeGroupCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupCommandInd), \
+ DEFINE_COMMAND(removeAllGroupsCommand, ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllGroupsCommandInd), \
+ DEFINE_COMMAND(addGroupIfIdentifyingCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupIfIdentifyingCommandInd), \
+ DEFINE_COMMAND(addGroupResponseCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupResponseCommandInd), \
+ DEFINE_COMMAND(viewGroupResponseCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupResponseCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipResponseCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipResponseCommandInd), \
+ DEFINE_COMMAND(removeGroupResponseCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupResponseCommandInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define GROUPS_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define GROUPS_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_GROUPS_CLUSTER(cltype, clattributes, clcommands) \
+ GROUPS_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[1];
+} ZCL_AddGroup_t;
+
+/**
+ * \brief View Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_ViewGroup_t;
+
+/**
+ * \brief Get Group Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t groupCount;
+ uint16_t groupList[1];
+} ZCL_GetGroupMembership_t;
+
+/**
+ * \brief Remove Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveGroup_t;
+
+/**
+ * \brief Add Group if identifying Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[1];
+} ZCL_AddGroupIfIdentifying_t;
+
+/**
+ * \brief Add Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_AddGroupResponse_t;
+
+/**
+ * \brief View Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t groupName[1];
+} ZCL_ViewGroupResponse_t;
+
+/**
+ * \brief Get Group Membership Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t capacity;
+ uint8_t groupCount;
+ uint16_t groupList[MAX_GROUPS_IN_GROUP_MEMBERSHIP_RESPONSE];
+} ZCL_GetGroupMembershipResponse_t;
+
+/**
+ * \brief Remove Group Command Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveGroupResponse_t;
+
+/**
+ * \brief Groups Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_GroupsClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Groups Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroup_t * payload);
+ } addGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroup_t * payload);
+ } viewGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembership_t * payload);
+ } getGroupMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroup_t * payload);
+ } removeGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllGroupsCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void * payload);
+ } removeAllGroupsCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupIfIdentifyingCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupIfIdentifying_t * payload);
+ } addGroupIfIdentifyingCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupResponse_t * payload);
+ } addGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroupResponse_t * payload);
+ } viewGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembershipResponse_t * payload);
+ } getGroupMembershipResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroupResponse_t * payload);
+ } removeGroupResponseCommand;
+} ZCL_GroupsClusterCommands_t;
+
+#endif /* _ZCLZLLGROUPSCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h
new file mode 100644
index 00000000..f3904c0e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h
@@ -0,0 +1,171 @@
+/**************************************************************************//**
+ \file zclZllIB.h
+
+ \brief
+ ZLL Information Base interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 18.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLIB_H
+#define _ZCLZLLIB_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <aps.h>
+#include <zclZllFrameFormat.h>
+#include <zclZllIB.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+// Device Information Table entry
+typedef struct _DitEntry_t
+{
+ uint64_t ieee;
+ uint8_t ep;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ uint8_t sort;
+} ZCL_ZllDitEntry_t;
+
+typedef struct _ZCL_ZllDevice_t
+{
+ uint8_t factoryNew;
+ uint8_t channel;
+ PanId_t panId;
+ ExtPanId_t extPanId;
+ ShortAddr_t nwkAddr;
+ ExtAddr_t extAddr;
+ ShortAddr_t freeNwkAddressRangeBegin;
+ ShortAddr_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint8_t nwkKey[SECURITY_KEY_SIZE];
+} ZCL_ZllDevice_t;
+
+typedef struct _ZCL_ZllIb_t
+{
+ ZCL_ZllDevice_t device;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+ ZCL_ZllDitEntry_t *dit;
+ uint8_t ditSize;
+ uint8_t numberSubDevices;
+ uint8_t totalGroupIds;
+ MAC_CapabilityInf_t capabilityInf;
+ uint8_t *appData;
+ uint16_t appDataSize;
+} ZCL_ZllIb_t;
+
+/******************************************************************************
+ Global variables
+******************************************************************************/
+extern ZCL_ZllIb_t zclZllIB;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Initialize Information Base and restore ZLL parameters and
+application data
+
+This function is invoked by the ZCL_ZllReset() function and therefore should
+not be called by the user directly.
+
+The function restores ZLL parameters and application data from EEPROM and sets
+the restored network and stack parameters in Configuration Server as well.
+******************************************************************************/
+void ZCL_ZllIbReset(void);
+
+/**************************************************************************//**
+\brief Set application data that should be saved and restored
+
+This function specifies the memory which is used to store and restore
+application data. The data will be saved in EEPROM when the ZCL_ZllIbSave()
+function is called, and restored when ZCL_ZllIbReset() or ZCL_ZllReset()
+functions are called (ZCL_ZllReset() invokes ZCL_ZllIbReset()).
+
+This function should be called before ZCL_ZllIbReset() or ZCL_ZllReset() to
+specify the memory to which application data will be restored.
+
+Application data may be any abstract data. However, keeping network and
+stack parameters in application data is unnecunnecessary, because they are
+maintained by ZLL.
+
+\param[in] data - application data
+\param[in] button - button number
+******************************************************************************/
+void ZCL_ZllIbSetAppData(uint8_t *data, uint16_t size);
+
+/**************************************************************************//**
+\brief Save ZLL parameters and application data in EEPROM
+
+The functions saves ZLL parameters and application data in EEPROM so that
+they can be restored after device is reset. ZLL parameters are stored inside
+the stack in the instance of the ZCL_ZllDevice_t type. This function should
+be called each time after the application data is modofied.
+******************************************************************************/
+void ZCL_ZllIbSave(void);
+
+/**************************************************************************//**
+\brief Reset ZLL parameters to factory new settings and store them into EEPROM
+******************************************************************************/
+void ZCL_ZllIbResetToFactoryNew(void);
+
+/**************************************************************************//**
+\brief Set Device Information Table
+
+Device Information Table contains entries desribing logical device type
+implemented on the device. However, most frequently the table has only one entry.
+Since the table stores static information about application functionality, it is
+not writtern into EEPROM, but is typically configured each time the application
+starts.
+
+The following example shows how to fill a table with a single entry:
+
+\code
+\\Global definition of the Device Information table
+ZCL_ZllDitEntry_t deviceInfoTable[DEVICE_INFO_TABLE_ENTRIES];
+...
+CS_ReadParameter(CS_UID_ID, &deviceInfoTable[0].ieee); //Read extended address from the Configuration Server
+deviceInfoTable[0].ep = APP_ENDPOINT_COLOR_SCENE_REMOTE;
+deviceInfoTable[0].profileId = APP_PROFILE_ID;
+deviceInfoTable[0].deviceId = APP_DEVICE_ID;
+deviceInfoTable[0].version = APP_VERSION;
+deviceInfoTable[0].groupIds = APP_GROUP_IDS; //The number of group IDs
+deviceInfoTable[0].sort = 0;
+ZCL_ZllIbSetDeviceInfoTable(deviceInfoTable, 1);
+\endcode
+
+Note that all constants starting with APP_ should be defined by the
+application.
+
+\param[in] dit - pointer to the Device Information table
+\param[in] size - number of entries in the table
+******************************************************************************/
+void ZCL_ZllIbSetDeviceInfoTable(ZCL_ZllDitEntry_t dit[], uint8_t size);
+
+#endif // _ZCLZLLIB_H
+
+// eof zclZllIB.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h
new file mode 100644
index 00000000..ad27466e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h
@@ -0,0 +1,215 @@
+/***************************************************************************//**
+ \file zclZllIdentifyCluster.h
+
+ \brief
+ The header file describes the ZLL Identify Cluster and its interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 04.07.11 A. Taradov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLIDENTIFYCLUSTER_H
+#define _ZCLZLLIDENTIFYCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Identify Server Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Identify Client Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Identify Client Cluster commands amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT 4
+
+/**
+ * \brief Identify Server Cluster attributes identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Identify Server Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_RESPONSE_COMMAND_ID 0x00
+
+/**
+ * \brief Identify Client Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_COMMAND_ID 0x00
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_COMMAND_ID 0x01
+#define ZCL_IDENTIFY_CLUSTER_TRIGGER_EFFECT_COMMAND_ID 0x40
+
+/*
+ *\brief ZCL Idetify Cluster server side attributes defining macros
+ */
+
+#define ZCL_DEFINE_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(identifyTime, ZCL_READWRITE_ATTRIBUTE, ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/*
+ * \brief ZCL Identify Cluster commands defining macros
+ */
+
+#define IDENTIFY_CLUSTER_COMMANDS(identifyCommandInd, identifyQueryCommandInd, triggerEffectCommandInd, identifyQueryResponseCommandInd) \
+ DEFINE_COMMAND(identifyCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyCommandInd), \
+ DEFINE_COMMAND(identifyQueryCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryCommandInd), \
+ DEFINE_COMMAND(triggerEffectCommand, 0x40, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), triggerEffectCommandInd), \
+ DEFINE_COMMAND(identifyQueryResponseCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryResponseCommandInd)
+
+#define IDENTIFY_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define IDENTIFY_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define DEFINE_IDENTIFY_CLUSTER(cltype, clattributes, clcommands) IDENTIFY_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/**
+ * \brief Possible values for the Effect Identifier field.
+*/
+enum
+{
+ ZCL_EFFECT_IDENTIFIER_BLINK = 0x00,
+ ZCL_EFFECT_IDENTIFIER_BREATHE = 0x01,
+ ZCL_EFFECT_IDENTIFIER_OKAY = 0x02,
+ ZCL_EFFECT_IDENTIFIER_CHANNEL_CHANGE = 0x0b,
+ ZCL_EFFECT_IDENTIFIER_FINISH_EFFECT = 0xfe,
+ ZCL_EFFECT_IDENTIFIER_STOP_EFFECT = 0xff,
+};
+
+/**
+ * \brief Possible values for the Effect Variant field.
+*/
+enum
+{
+ ZCL_EFFECT_VARIANT_DEFAULT = 0x00,
+};
+
+BEGIN_PACK
+
+/**
+ * \brief Identify Command Payload format.
+*/
+typedef struct PACK
+{
+ uint16_t identifyTime;
+} ZCL_Identify_t;
+
+/**
+ * \brief Trigger Effect Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t effectIdentifier;
+ uint8_t effectVariant;
+} ZCL_TriggerEffect_t;
+
+/**
+ * \brief Identify Query Response Payload format.
+*/
+typedef struct PACK
+{
+ uint16_t timeout;
+} ZCL_IdentifyQueryResponse_t;
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } identifyTime;
+} ZCL_IdentifyClusterAttributes_t;
+
+END_PACK
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_Identify_t *payload);
+ } identifyCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } identifyQueryCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*triggerEffectCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TriggerEffect_t *payload);
+ } triggerEffectCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_IdentifyQueryResponse_t *payload);
+ } identifyQueryResponseCommand;
+} ZCL_IdentifyClusterCommands_t;
+
+
+#endif // _ZCLZLLIDENTIFYCLUSTER_H
+
+// eof zclZllIdentifyCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h
new file mode 100644
index 00000000..471f8a48
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h
@@ -0,0 +1,71 @@
+/**************************************************************************//**
+ \file zclZllInterPan.h
+
+ \brief
+ ZLL Inter-PAN operation interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 17.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLINTERPAN_H
+#define _ZCLZLLINTERPAN_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _ZCL_ZllInterPanStartConf_t
+{
+ ZCL_ZllStatus_t status;
+} ZCL_ZllInterPanStartConf_t;
+
+typedef struct _ZCL_ZllInterPanStartReq_t
+{
+ ZCL_ZllInterPanStartConf_t confirm;
+ void (*ZCL_ZllInterPanStartConf)(ZCL_ZllInterPanStartConf_t *conf);
+} ZCL_ZllInterPanStartReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset ZLL Inter-PAN module
+******************************************************************************/
+void ZCL_ZllInterPanReset(void);
+
+/**************************************************************************//**
+\brief Prepare stack for Inter-PAN operation
+
+The function prepares the device for Inter-PAN communication. It is required
+for starting network scan (invoked by the ZCL_ZllScanReq() function).
+
+The function is executed asynchronously. Invocation of the callback function
+provided in the \c req->ZCL_ZllInterPanStartConf field indicates request
+completion. If the request has been successful (the reported status equals
+::ZCL_ZLL_SUCCESS_STATUS) ZigBee network features become unavailable.
+
+To restore normal stack operation, when Inter-PAN data exchange has finished,
+call the ZDO_ResetNetworkReq() function.
+******************************************************************************/
+void ZCL_ZllInterPanStartReq(ZCL_ZllInterPanStartReq_t *req);
+
+#endif // _ZCLZLLINTERPAN_H
+
+// eof zclZllInterPan.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h
new file mode 100644
index 00000000..0bd8caa2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h
@@ -0,0 +1,297 @@
+/***************************************************************************//**
+ \file zclZllLevelControlCluster.h
+
+ \brief
+ Interface and types of Level Control Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 22.06.10 D.Loskutnikov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLLEVELCONTROLCLUSTER_H
+#define _ZCLZLLLEVELCONTROLCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define ZLL_LEVEL_CONTROL_UP_DIRECTION 0x00
+#define ZLL_LEVEL_CONTROL_DOWN_DIRECTION 0x01
+
+/**
+ * \brief Amount of Level Control cluster server's attributes
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Client doesn't have attributes.
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Level Control Cluster commands amount
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT 8
+
+/**
+ * \brief Level Control Cluster server's attributes identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID 0x00
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID 0x01
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID 0x02
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID 0x03
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID 0x04
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID 0x05
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID 0x06
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID 0x07
+
+/**
+ * \brief Level Control Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_MANDATORY_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(currentLevel, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(remainingTime, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_OPTIONAL_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(onOffTransitionTime, ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onLevel, ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID)
+
+
+/**
+ * \brief Level Control Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_COMMANDS(moveToLevelCommandInd,\
+ moveCommandInd,\
+ stepCommandInd,\
+ stopCommandInd,\
+ moveToLevelWOnOffCommandInd,\
+ moveWOnOffCommandInd,\
+ stepWOnOffCommandInd,\
+ stopWOnOffCommandInd)\
+ DEFINE_COMMAND(moveToLevelCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelCommandInd), \
+ DEFINE_COMMAND(moveCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveCommandInd), \
+ DEFINE_COMMAND(stepCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepCommandInd), \
+ DEFINE_COMMAND(stopCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopCommandInd), \
+ DEFINE_COMMAND(moveToLevelWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelWOnOffCommandInd), \
+ DEFINE_COMMAND(moveWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveWOnOffCommandInd), \
+ DEFINE_COMMAND(stepWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepWOnOffCommandInd), \
+ DEFINE_COMMAND(stopWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopWOnOffCommandInd)
+
+/**
+ * \brief Level Control Cluster definition macros
+*/
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER(cltype, clattributes, clcommands) \
+ LEVEL_CONTROL_CLUSTER_##cltype(clattributes, clcommands)
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = LEVEL_CONTROL_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .currentLevel = value
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Move To Level Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t level;
+ uint16_t transitionTime;
+} ZCL_MoveToLevel_t;
+
+/**
+ * \brief Move Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_Move_t;
+
+/**
+ * \brief Step Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint16_t transitionTime;
+} ZCL_Step_t;
+
+/**
+ * \brief Level Control Cluster server's attributes
+*/
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } currentLevel;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } remainingTime;
+} ZCL_LevelControlClusterServerAttributes_t;
+
+/**
+ * \brief Level Control Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ uint8_t currentLevel;
+} ZCL_LevelControlClusterExtensionFieldSet_t;
+
+END_PACK
+
+/**
+ * \brief Level Control Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopWOnOffCommand;
+} ZCL_LevelControlClusterCommands_t;
+
+#endif /* _ZCLZLLLEVELCONTROLCLUSTER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h
new file mode 100644
index 00000000..219ed2ee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h
@@ -0,0 +1,95 @@
+/**************************************************************************//**
+ \file zclZllMisc.h
+
+ \brief
+ ZLL miscellaneous functionality interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 19.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLMISC_H
+#define _ZCLZLLMISC_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+#include <zclZllIB.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define ZCL_ZLL_USE_DEFAULT_IDENTIFY_TIME 0xffff
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Identify notification
+
+The function shall be implemented by the application. The ZLL component
+calls this function when an indetify request is received (sent from a remote
+device with the ZCL_ZllIdentifyRequest() function).
+
+Receiving this notification, a router is expected to somehow identify itself
+for the user; for example, a lighting device may blink.
+
+\param[in] status - notification status
+\param[in] time - identification time
+******************************************************************************/
+extern void ZCL_ZllIdentifyInd(ZCL_ZllStatus_t status, uint16_t time);
+
+/**************************************************************************//**
+\brief Reset ZLL miscellaneous module
+******************************************************************************/
+void ZCL_ZllMiscReset(void);
+
+/**************************************************************************//**
+\brief Send Identify Request command
+
+The function sends an identify request to the destination device specified
+with its extended address. On the destination device ZCL_ZllIdentifyInd() is
+called by the stack to indicate identify command reception. The device that
+sends the request should first select the destination device, using the
+ZCL_ZllSelectDeviceReq() function.
+
+The function is used during ZLL commissioning via touch link to allow the
+application to drop the commissioning procedure if something goes wrong
+(for example, the user discovers that wrong device has been selected).
+
+\param[in] addr - destination device extended address pointer
+\param[in] identifyTime - time in 1/10ths of a seconds
+\returns true if the command has been sent
+******************************************************************************/
+bool ZCL_ZllIdentifyRequest(ExtAddr_t *addr, uint16_t identifyTime);
+
+/**************************************************************************//**
+\brief Reset the device to Factory New state
+\param[in] addr - destination short address
+\returns true if command was sent.
+******************************************************************************/
+bool ZCL_ZllResetToFactoryNewRequest(ShortAddr_t addr);
+
+/**************************************************************************//**
+\brief INTRP-DATA.indication primitive
+\param[in] ind - indication parameters
+******************************************************************************/
+void ZCL_ZllMiscDataInd(INTRP_DataInd_t *ind);
+
+#endif // _ZCLZLLMISC_H
+
+// eof zclZllMisc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h
new file mode 100644
index 00000000..adece9aa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h
@@ -0,0 +1,114 @@
+/**************************************************************************//**
+ \file zclZllNetwork.h
+
+ \brief
+ ZLL network functionality interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 22.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLNETWORK_H
+#define _ZCLZLLNETWORK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+#include <zclZllIB.h>
+#include <zclZllScan.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _ZCL_ZllStartNetworkConf_t
+{
+ ZCL_ZllStatus_t status;
+} ZCL_ZllStartNetworkConf_t;
+
+typedef struct _ZCL_ZllStartNetworkReq_t
+{
+ ZCL_ZllStartNetworkConf_t confirm;
+ ZCL_ZllScanDeviceInfo_t *otherDevice;
+ void (*ZCL_ZllStartNetworkConf)(ZCL_ZllStartNetworkConf_t *conf);
+} ZCL_ZllStartNetworkReq_t;
+
+/*! Select ZLL device confirm parameters */
+typedef struct _ZCL_SelectDeviceConf_t
+{
+ /* Operation status */
+ ZCL_ZllStatus_t status;
+} ZCL_SelectDeviceConf_t;
+
+/*! Select ZLL device request parameters */
+typedef struct _ZCL_ZllSelectDeviceReq_t
+{
+ /*! Selected device information */
+ ZCL_ZllScanDeviceInfo_t *deviceInfo;
+ /*! MAC-SET.request primitive */
+ MAC_SetReq_t macSetReq;
+ /*! Confirm callback pointer */
+ void (*ZCL_ZllSelectDeviceConf)(ZCL_SelectDeviceConf_t *conf);
+ /*! Select ZLL device confirm info */
+ ZCL_SelectDeviceConf_t confirm;
+} ZCL_ZllSelectDeviceReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset ZLL network module.
+******************************************************************************/
+void ZCL_ZllNetworkReset(void);
+
+/**************************************************************************//**
+\brief Send ZLL start network request. Should be called only by end devices.
+
+The function sends an Inter-PAN command containing network parameters to
+the selected router. The router is notified about receiving network parameters
+via ZCL_ZllStartInd() (this function should be implemented on the router).
+Upon receiving such indication the router is expected to rejoin the nework,
+using ZDO functions. The end device that has issued the request should also
+rejoin the network to join the router.
+
+The device to which the ZLL start network request will be sent is set
+with the ZCL_ZllSelectDeviceReq() function.
+
+\param req - request parameters
+******************************************************************************/
+void ZCL_ZllStartNetworkReq(ZCL_ZllStartNetworkReq_t *req);
+
+/**************************************************************************//**
+\brief INTRP-DATA.indication primitive
+\param[in] ind - indication parameters
+******************************************************************************/
+void ZCL_ZllNetworkDataInd(INTRP_DataInd_t *ind);
+
+/**************************************************************************//**
+\brief Select a device discovered during scanning
+
+Using this function, the application specifies a device to which it will
+send an identify request and a start network request. Information about the
+device that should be provided for this function is received during network
+scan (performed by ZCL_ZllScanReq()).
+
+\param[in] req - request parameters
+******************************************************************************/
+void ZCL_ZllSelectDeviceReq(ZCL_ZllSelectDeviceReq_t *req);
+
+#endif // _ZCLZLLNETWORK_H
+
+// eof zclZllNetwork.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h
new file mode 100644
index 00000000..f16eaf1e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h
@@ -0,0 +1,281 @@
+/***************************************************************************//**
+ \file zclZllOnOffCluster.h
+
+ \brief
+ The header file describes the ZLL On/Off Cluster and its interface
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 21.03.11 A. Taradov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLONOFFCLUSTER_H
+#define _ZCLZLLONOFFCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define ZCL_ON_OFF_CLUSTER_ACCEPT_ONLY_WHEN_ON 0x01
+
+/**
+ * \brief On/Off Cluster server attributes amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 4
+
+/**
+ * \brief On/Off Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Cluster commands amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT 6
+
+/**
+ * \brief On/Off Cluster server's attributes identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_ONOFF_CLUSTER_GLOBAL_SCENE_CONTROL_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4000)
+#define ZCL_ONOFF_CLUSTER_ON_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4001)
+#define ZCL_ONOFF_CLUSTER_OFF_WAIT_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4002)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID 0x00
+#define ZCL_ONOFF_CLUSTER_ON_COMMAND_ID 0x01
+#define ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID 0x02
+#define ZCL_ONOFF_CLUSTER_OFF_WITH_EFFECT_COMMAND_ID 0x40
+#define ZCL_ONOFF_CLUSTER_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID 0x41
+#define ZCL_ONOFF_CLUSTER_ON_WITH_TIMED_OFF_COMMAND_ID 0x42
+
+/**
+ * \brief On/Off Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(onOff, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(globalSceneControl, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_GLOBAL_SCENE_CONTROL_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onTime, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_ON_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(offWaitTime, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_OFF_WAIT_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_COMMANDS(onCommandInd, offCommandInd, toggleCommandInd, offWithEffectInd, onWithRecallGlobalSceneInd, onWithTimedOffInd) \
+ DEFINE_COMMAND(onCommand, ZCL_ONOFF_CLUSTER_ON_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ onCommandInd), \
+ DEFINE_COMMAND(offCommand, ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ offCommandInd), \
+ DEFINE_COMMAND(toggleCommand, ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ toggleCommandInd), \
+ DEFINE_COMMAND(offWithEffectCommand, ZCL_ONOFF_CLUSTER_OFF_WITH_EFFECT_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ offWithEffectInd), \
+ DEFINE_COMMAND(onWithRecallGlobalSceneCommand, ZCL_ONOFF_CLUSTER_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ onWithRecallGlobalSceneInd), \
+ DEFINE_COMMAND(onWithTimedOffCommand, ZCL_ONOFF_CLUSTER_ON_WITH_TIMED_OFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ onWithTimedOffInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define ONOFF_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define ONOFF_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_ONOFF_CLUSTER(cltype, clattributes, clcommands) \
+ ONOFF_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Cluster server's attributes
+*/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ bool reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } onOff;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ } globalSceneControl;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } onTime;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } offWaitTime;
+} ZCL_OnOffClusterServerAttributes_t;
+
+/**
+ * \brief On/Off Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ bool onOffValue;
+} ZCL_OnOffClusterExtensionFieldSet_t;
+
+typedef struct PACK
+{
+ uint8_t effectIdentifier;
+ uint8_t effectVariant;
+} ZCL_OffWithEffect_t;
+
+typedef struct PACK
+{
+ uint8_t onOffControl;
+ uint16_t onTime;
+ uint16_t offWaitTime;
+} ZCL_OnWithTimedOff_t;
+
+END_PACK
+
+/**
+ * \brief On/Off Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } onCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*offCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } offCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*toggleCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } toggleCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*offWithEffectCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OffWithEffect_t * payload);
+ } offWithEffectCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onWithRecallGlobalSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } onWithRecallGlobalSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onWithTimedOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OnWithTimedOff_t * payload);
+ } onWithTimedOffCommand;
+
+} ZCL_OnOffClusterCommands_t;
+
+#define DEFINE_ONOFF_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = ONOFF_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .onOffValue = value
+
+#endif /* _ZCLZLLONOFFCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h
new file mode 100644
index 00000000..9ccd82c9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h
@@ -0,0 +1,109 @@
+/**************************************************************************//**
+ \file zclZllScan.h
+
+ \brief
+ ZLL Scan functions interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 17.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLSCAN_H
+#define _ZCLZLLSCAN_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+#include <zclZllIB.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+typedef struct _ZCL_ZllScanDeviceInfo_t
+{
+ // Device Information Table entry
+ uint64_t ieee;
+ uint8_t ep;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ uint8_t sort;
+
+ // Common fields
+ uint8_t rssiCorrection;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+ uint16_t keyBitMask;
+ uint32_t responseId;
+ uint64_t extPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t networkAddress;
+ uint8_t numberSubDevices;
+ uint8_t totalGroupIds;
+ uint64_t ieeeRelayerScanRequest;
+ int8_t rssi;
+} ZCL_ZllScanDeviceInfo_t;
+
+typedef struct _ZCL_ZllScanConf_t
+{
+ ZCL_ZllScanDeviceInfo_t info;
+ ZCL_ZllStatus_t status;
+ bool stopScan;
+} ZCL_ZllScanConf_t;
+
+typedef struct _ZCL_ZllScanReq_t
+{
+ ZCL_ZllScanConf_t confirm;
+ void (*ZCL_ZllScanConf)(ZCL_ZllScanConf_t *conf);
+} ZCL_ZllScanReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset ZLL Scan.
+******************************************************************************/
+void ZCL_ZllScanReset(void);
+
+/**************************************************************************//**
+\brief ZLL Scan request. Should be called only by end devices.
+
+The function is called on end devices to discover other devices by scanning
+supported radio channels. Before calling this function the device should be
+prepared to handle Inter-PAN messages: call the ZCL_ZllInterPanStartReq()
+function first.
+
+The callback function specified in the parameters is called once for
+each discovered device.
+
+\param req - request parameters
+******************************************************************************/
+void ZCL_ZllScanReq(ZCL_ZllScanReq_t *req);
+
+/**************************************************************************//**
+\brief INTRP-DATA.indication primitive
+\param[in] ind - indication parameters
+******************************************************************************/
+void ZCL_ZllScanReqDataInd(INTRP_DataInd_t *ind);
+
+#endif // _ZCLZLLSCAN_H
+
+// eof zclZllScan.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h
new file mode 100644
index 00000000..2bf4b100
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h
@@ -0,0 +1,648 @@
+/***************************************************************************//**
+ \file zclScenesCluster.h
+
+ \brief
+ The header file describes the ZCL Scenes Cluster and its interface
+
+ The file describes the types and interface of the ZCL Scenes Cluster
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLSCENESCLUSTER_H
+#define _ZCLSCENESCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+#include <zclZllOnOffCluster.h>
+#include <zclZllLevelControlCluster.h>
+#include <zclZllColorControlCluster.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Scenes Cluster scene name support bit
+*/
+
+#define ZCL_SCENES_CLUSTER_NAME_SUPPORT_FLAG 0x80
+
+#define ZCL_SCENES_CLUSTER_COPY_ALL_SCENES 0x01
+
+/**
+ * \brief Scenes Cluster server attributes amount
+*/
+
+#define ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/**
+ * \brief Scenes Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief Scenes Cluster commands amount
+*/
+
+#define ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT 19
+
+/**
+ * \brief Scenes Cluster server's attributes identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+#define ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+#define ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+
+/**
+ * \brief Scenes Cluster client's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID 0x05
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID 0x06
+#define ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_COMMAND_ID 0x40
+#define ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_COMMAND_ID 0x41
+#define ZCL_SCENES_CLUSTER_COPY_SCENE_COMMAND_ID 0x42
+
+/**
+ * \brief Scenes Cluster servers's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID 0x06
+#define ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_RESPONSE_COMMAND_ID 0x40
+#define ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_RESPONSE_COMMAND_ID 0x41
+#define ZCL_SCENES_CLUSTER_COPY_SCENE_RESPONSE_COMMAND_ID 0x42
+
+/**
+ * \brief Scenes Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(sceneCount, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentScene, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentGroup, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(sceneValid, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_SERVER_COMMANDS(addSceneCommandInd, viewSceneCommandInd, removeSceneCommandInd, \
+ removeAllScenesCommandInd, storeSceneCommandInd, recallSceneCommandInd, \
+ getSceneMembershipCommandInd, enhancedAddSceneCommandInd, enhancedViewSceneCommandInd, copySceneCommandInd) \
+ DEFINE_COMMAND(addSceneCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneCommandInd), \
+ DEFINE_COMMAND(viewSceneCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneCommandInd), \
+ DEFINE_COMMAND(removeSceneCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneCommandInd), \
+ DEFINE_COMMAND(removeAllScenesCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesCommandInd), \
+ DEFINE_COMMAND(storeSceneCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneCommandInd), \
+ DEFINE_COMMAND(recallSceneCommand, ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ recallSceneCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipCommandInd), \
+ DEFINE_COMMAND(enhancedAddSceneCommand, ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedAddSceneCommandInd), \
+ DEFINE_COMMAND(enhancedViewSceneCommand, ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedViewSceneCommandInd), \
+ DEFINE_COMMAND(copySceneCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ copySceneCommandInd)
+
+#define ZCL_DEFINE_SCENES_CLUSTER_CLIENT_COMMANDS(addSceneResponseCommandInd, viewSceneResponseCommandInd, \
+ removeSceneResponseCommandInd, removeAllScenesResponseCommandInd, storeSceneResponseCommandInd, \
+ getSceneMembershipResponseCommandInd, enhancedAddSceneResponseCommandInd, enhancedViewSceneResponseCommandInd, \
+ copySceneResponseCommandInd) \
+ DEFINE_COMMAND(addSceneResponseCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneResponseCommandInd), \
+ DEFINE_COMMAND(viewSceneResponseCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeSceneResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeAllScenesResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesResponseCommandInd), \
+ DEFINE_COMMAND(storeSceneResponseCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneResponseCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipResponseCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipResponseCommandInd), \
+ DEFINE_COMMAND(enhancedAddSceneResponseCommand, ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedAddSceneResponseCommandInd), \
+ DEFINE_COMMAND(enhancedViewSceneResponseCommand, ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedViewSceneResponseCommandInd), \
+ DEFINE_COMMAND(copySceneResponseCommand, ZCL_SCENES_CLUSTER_COPY_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ copySceneResponseCommandInd)
+
+/**
+ * \brief Scene Cluster definition macros
+*/
+
+#define SCENES_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define SCENES_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_SCENES_CLUSTER(cltype, clattributes, clcommands) \
+ SCENES_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t name[1];
+} ZCL_AddScene_t;
+
+/**
+ * \brief View Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_ViewScene_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveScene_t;
+
+/**
+ * \brief Remove All Scenes Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveAllScenes_t;
+
+/**
+ * \brief Store Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreScene_t;
+
+/**
+ * \brief Recall Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RecallScene_t;
+
+/**
+ * \brief Get Scene Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_GetSceneMembership_t;
+
+/**
+ * \brief Enhanced Add Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t name[1];
+ ZCL_OnOffClusterExtensionFieldSet_t onOffClusterExtFields;
+ ZCL_LevelControlClusterExtensionFieldSet_t levelControlClusterExtFields;
+ ZCL_ColorControlClusterExtensionFieldSet_t colorControlClusterExtFields;
+} ZCL_EnhancedAddScene_t;
+
+/**
+ * \brief Enhanced View Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_EnhancedViewScene_t;
+
+/**
+ * \brief Copy Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t mode;
+ uint16_t groupIdFrom;
+ uint16_t sceneIdFrom;
+ uint16_t groupIdTo;
+ uint16_t sceneIdTo;
+} ZCL_CopyScene_t;
+
+/**
+ * \brief Add Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_AddSceneResponse_t;
+
+/**
+ * \brief View Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t nameAndExtField[1]; // string sceneName, extension field.
+} ZCL_ViewSceneResponse_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveSceneResponse_t;
+
+/**
+ * \brief Remove All Scenes Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveAllScenesResponse_t;
+
+/**
+ * \brief Store Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreSceneResponse_t;
+
+/**
+ * \brief Get Scene Membership Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t capacity;
+ uint16_t groupId;
+ uint8_t sceneCount;
+ uint8_t sceneList[16];
+} ZCL_GetSceneMembershipResponse_t;
+
+/**
+ * \brief Enhanced Add Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_EnhancedAddSceneResponse_t;
+
+/**
+ * \brief Enhanced View Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t name[1];
+ ZCL_OnOffClusterExtensionFieldSet_t onOffClusterExtFields;
+ ZCL_LevelControlClusterExtensionFieldSet_t levelControlClusterExtFields;
+ ZCL_ColorControlClusterExtensionFieldSet_t colorControlClusterExtFields;
+} ZCL_EnhancedViewSceneResponse_t;
+
+/**
+ * \brief Copy Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupIdFrom;
+ uint16_t sceneIdFrom;
+ uint16_t groupIdTo;
+ uint16_t sceneIdTo;
+} ZCL_CopySceneResponse_t;
+
+/**
+ * \brief Extension Fields Set format
+ */
+
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+} ZCL_ExtensionFieldSets_t;
+
+/**
+ * \brief Scene Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } sceneCount;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentScene;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentGroup;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ } sceneValid;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_SceneClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Scene Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddScene_t * payload);
+ } addSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewScene_t * payload);
+ } viewSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveScene_t * payload);
+ } removeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenes_t * payload);
+ } removeAllScenesCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreScene_t * payload);
+ } storeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*recallSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RecallScene_t * payload);
+ } recallSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembership_t * payload);
+ } getSceneMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedAddSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedAddScene_t * payload);
+ } enhancedAddSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedViewSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedViewScene_t * payload);
+ } enhancedViewSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*copySceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CopyScene_t * payload);
+ } copySceneCommand;
+
+ // responses
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddSceneResponse_t * payload);
+ } addSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewSceneResponse_t * payload);
+ } viewSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveSceneResponse_t * payload);
+ } removeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenesResponse_t * payload);
+ } removeAllScenesResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreSceneResponse_t * payload);
+ } storeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembershipResponse_t * payload);
+ } getSceneMembershipResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedAddSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedAddSceneResponse_t * payload);
+ } enhancedAddSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedViewSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedViewSceneResponse_t * payload);
+ } enhancedViewSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*copySceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CopySceneResponse_t * payload);
+ } copySceneResponseCommand;
+} ZCL_ScenesClusterCommands_t;
+
+
+#endif /* _ZCLSCENESCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h
new file mode 100644
index 00000000..6dee63df
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h
@@ -0,0 +1,63 @@
+/**************************************************************************//**
+ \file zclZllSecurity.h
+
+ \brief
+ Functions and constants used by the ZLL security module.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 22.06.11 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLSECURITY_H
+#define _ZCLZLLSECURITY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define ZCL_ZLL_DEVELOPMENT_KEY_INDEX 0
+#define ZCL_ZLL_MASTER_KEY_INDEX 4
+#define ZCL_ZLL_CERTIFICATION_KEY_INDEX 15
+
+//#define ZCL_ZLL_SUPPORTED_KEY_INDEX ZCL_ZLL_CERTIFICATION_KEY_INDEX
+//#define ZCL_ZLL_SUPPORTED_SECURITY_KEYS (1u << ZCL_ZLL_SUPPORTED_KEY_INDEX)
+
+#define ZCL_ZLL_SUPPORTED_KEY_INDEX ZCL_ZLL_DEVELOPMENT_KEY_INDEX
+#define ZCL_ZLL_SUPPORTED_SECURITY_KEYS (1u << ZCL_ZLL_DEVELOPMENT_KEY_INDEX)
+
+/*! Certification key */
+#define ZCL_ZLL_SECURITY_KEY "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Encrypt security key
+\param[in] text - key to be encrypted
+\param[in] callback - function to be called after encryption is finished
+******************************************************************************/
+void zclZllEncryptKey(uint8_t text[SECURITY_BLOCK_SIZE], void (*callback)(void));
+
+/**************************************************************************//**
+\brief Decrypt security key
+\param[in] text - key to be decrypted
+\param[in] callback - function to be called after decryption is finished
+******************************************************************************/
+void zclZllDecryptKey(uint8_t text[SECURITY_BLOCK_SIZE], void (*callback)(void));
+
+#endif // _ZCLZLLSECURITY_H
+
+// eof zclZllSecurity.h