/***************************************************************************//** \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 #include /******************************************************************************* 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; //!