Functions
The following time-related functions are provided in the NXP implementation of the ZCL:
Note: The time used in the Time cluster and in the ZCL is a UTC (Co-ordinated Universal Time) type UTCTime, which is defined in the ZigBee Specification as follows: “UTCTime is an unsigned 32 bit value representing the number of seconds since 0 hours, 0 minutes, 0 seconds, on the 1st of January, 2000 UTC”
eCLD_TimeCreateTime
teZCL_Status eCLD_TimeCreateTime(
tsZCL_ClusterInstance *psClusterInstance,
bool_t bIsServer,
tsZCL_ClusterDefinition *psClusterDefinition,
void *pvEndPointSharedStructPtr,
uint8 *pu8AttributeControlBits);
Description
This function creates an instance of the Time cluster on the local endpoint. The cluster instance can act as a server or a client, as specified.
The function should only be called when setting up a custom endpoint containing one or more selected clusters (rather than the whole set of clusters supported by a standard ZigBee device). This function will create a Time cluster instance on the endpoint, but instances of other clusters may also be created on the same endpoint by calling their corresponding creation functions.
Note: This function must not be called for an endpoint on which a standard ZigBee device (e.g. Simple Sensor) will be used. In this case, the device and its supported clusters must be registered on the endpoint using the relevant device registration function.
When used, this function must be the first Time cluster function called in the application, and must be called after the stack has been started and after the ZCL has been initialized.
The function requires an array to be declared for internal use, which contains one element (of type uint8) for each attribute of the cluster. The array length should therefore equate to the total number of attributes supported by the Time cluster.
The function initializes the array elements to zero.
Parameters
psClusterInstance: Pointer to structure containing information about the cluster instance to be created (see Section 6.1.16). This structure is updated by the function by initializing individual structure fields.
bIsServer: Type of cluster instance (server or client) to be created:
TRUE - server
FALSE - client
psClusterDefinition: Pointer to structure indicating the type of cluster to be created (see Section 6.1.2). In this case, this structure must contain the details of the Time cluster. This parameter can refer to a pre-filled structure called
sCLD_Timewhich is provided in the Time.h file.pvEndPointSharedStructPtr: Pointer to the shared structure used for attribute storage. This parameter should be the address of the structure of type
tsCLD_Timewhich defines the attributes of Time cluster. The function initializes the attributes with default values.pu8AttributeControlBits: Pointer to an array of uint8 values, with one element for each attribute in the cluster (see above).
Returns
E_ZCL_SUCCESS
E_ZCL_FAIL
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_INVALID_VALUE
Parent topic:Functions
vZCL_SetUTCTime
void vZCL_SetUTCTime(uint32 u32UTCTime);
Description
This function sets the current time (UTC) that is stored in the ZCL (‘ZCL time’).
The application may call this function, for example, when a time update has been received (e.g. via the Time or Price cluster).
Note that this function does not update the time in the Timer cluster - if required, the application must do this by writing to the tsCLD_Time structure (see Section 18.2).
Parameters
u32UTCTime The current time (UTC) to be set, in seconds
Returns
None
Parent topic:Functions
u32ZCL_GetUTCTime
uint32 u32ZCL_GetUTCTime(void);
Description
This function obtains the current time (UTC) that is stored in the ZCL (‘ZCL time’).
Parameters
None
Returns
The current time (UTC), in seconds, obtained from the ZCL
Parent topic:Functions
bZCL_GetTimeHasBeenSynchronised
bool_t bZCL_GetTimeHasBeenSynchronised(void);
Description
This function queries whether the ZCL time on the device has been synchronized.
The clock is considered to be unsynchronized at start-up and is synchronized following a call to vZCL_SetUTCtime(). The ZCL time must be synchronized before using the time-related functions of other clusters.
Parameters
None
Returns
TRUE if the local ZCL time has been synchronized, otherwise FALSE
Parent topic:Functions
vZCL_ClearTimeHasBeenSynchronised
void vZCL_ClearTimeHasBeenSynchronised(void);
Description
This function is used to notify the ZCL that the local ZCL time may no longer be accurate.
Parameters
None
Returns
None
Parent topic:Functions
Parent topic:Time Cluster and ZCL Time