XBee Firmware Library  1.6.0
Files | Functions | Variables

Files

file  zcl_time.c
 
file  zcl_time.h
 

Functions

uint_fast8_t _zcl_time_time_get (const zcl_attribute_full_t FAR *attribute)
 
int _zcl_time_time_set (const zcl_attribute_full_t FAR *attribute, zcl_attribute_write_rec_t *rec)
 
_zcl_time_debug int _zcl_time_timestatus_set (const zcl_attribute_full_t FAR *attribute, zcl_attribute_write_rec_t *rec)
 
int zcl_time_client (const wpan_envelope_t FAR *envelope, void FAR *context)
 Handle Read Attribute Responses to requests sent as part of the zcl_time_find_servers() process. More...
 
int zcl_time_find_servers (wpan_dev_t *dev, uint16_t profile_id)
 Find Time Servers on the network, query them for the current time and then synchronize this device's clock to that time. More...
 
zcl_utctime_t zcl_time_now (void)
 Returns the current date/time, using the ZCL epoch of January 1, 2000. More...
 

Variables

uint16_t   end_of_list
 
zcl_attribute_full_t   time
 
zcl_attribute_full_t   time_status
 
struct {
   uint16_t   end_of_list
 
   zcl_attribute_full_t   time
 
   zcl_attribute_full_t   time_status
 
zcl_time_attr
 
XBEE_BEGIN_DECLS const zcl_attribute_tree_t zcl_time_attribute_tree []
 
const zcl_attribute_tree_t zcl_time_attribute_tree []
 
int32_t zcl_time_skew = 0
 difference between xbee_seconds_timer() and actual calendar time More...
 
zcl_utctime_t zcl_time_time
 
uint8_t zcl_time_timestatus = ZCL_TIME_STATUS_MASTER
 Current value of TimeStatus Attribute (#ZCL_TIME_ATTR_TIME_STATUS) More...
 

Detailed Description

Function Documentation

_zcl_time_debug uint_fast8_t _zcl_time_time_get ( const zcl_attribute_full_t FAR *  attribute)
_zcl_time_debug int _zcl_time_time_set ( const zcl_attribute_full_t FAR *  attribute,
zcl_attribute_write_rec_t rec 
)
_zcl_time_debug int _zcl_time_timestatus_set ( const zcl_attribute_full_t FAR *  attribute,
zcl_attribute_write_rec_t rec 
)
_zcl_time_debug int zcl_time_client ( const wpan_envelope_t FAR *  envelope,
void FAR *  context 
)

Handle Read Attribute Responses to requests sent as part of the zcl_time_find_servers() process.

This function expects to receive "read attribute response" packets ONLY for reads of Time and TimeStatus.

If responding device is a master or is synchronized with one, use it's Time value to update a "skew" global used to track the offset between system time (which may just be "seconds of uptime") and calendar time.

Parameters
[in]envelopeenvelope from received message
[in]contextpointer to attribute list for cluster (typically passed in via endpoint dispatcher)
Return values
0Command was processed and default response (with either success or error status) was sent.
!0Error sending default response; time may or may not have been set.
int zcl_time_find_servers ( wpan_dev_t dev,
uint16_t  profile_id 
)

Find Time Servers on the network, query them for the current time and then synchronize this device's clock to that time.

Note
This function uses a static buffer to hold context information for the ZDO responder that generates the ZCL Read Attributes request. Wait at least 60 seconds between calls to allow for earlier requests to time out.
This function will only work correctly if the Time Cluster Client in your endpoint table is using the zcl_time_client() function as its callback handler. If you use the ZCL_CLUST_ENTRY_TIME_CLIENT or ZCL_CLUST_ENTRY_TIME_BOTH macro, the client cluster is set up correctly.
Parameters
[in]devdevice to send query on
[in]profile_idprofile ID to match in endpoint table or #WPAN_APS_PROFILE_ANY to use the first endpoint with a Time Cluster Client
Return values
0Successfully issued ZDO Match Descriptor Request to find Time Cluster Servers on the network. No guarantee that we'll get a response.
!0Some sort of error occurred in generating or sending the ZDO Match Descriptor Request.
-EINVALCouldn't find a Time Cluster Client with profile_id in the endpoint table of dev.
zcl_utctime_t zcl_time_now ( void  )

Returns the current date/time, using the ZCL epoch of January 1, 2000.

Assumes that device has connected to a time server and updated its clock accordingly. Returns ZCL_UTCTIME_INVALID if the device has not synchronized its clock.

Do not use this value for tracking elapsed time – use xbee_seconds_timer() or xbee_millisecond_timer() instead. The value may jump forward (or even backward) when the device decides to synchronize with a time server.

Return values
ZCL_UTCTIME_INVALIDClock not synchronized to a time source.
0-0xFFFFFFFENumber of elapsed seconds since midnight UTC on January 1, 2000.
See also
xbee_seconds_timer, xbee_millisecond_timer

Variable Documentation

uint16_t end_of_list
uint16_t end_of_list
zcl_attribute_full_t time_status
zcl_attribute_full_t time_status
const { ... } zcl_time_attr
Initial value:
=
{
{ { ZCL_TIME_ATTR_TIME,
ZCL_ATTRIB_FLAG_FULL,
ZCL_TYPE_TIME_UTCTIME,
{ 0 }, { 0 },
{ { ZCL_TIME_ATTR_TIME_STATUS,
ZCL_ATTRIB_FLAG_FULL,
ZCL_TYPE_BITMAP_8BIT,
{ 0 }, { 0 },
ZCL_ATTRIBUTE_END_OF_LIST
}
uint_fast8_t _zcl_time_time_get(const zcl_attribute_full_t FAR *attribute)
Definition: zcl_time.c:124
uint8_t zcl_time_timestatus
Current value of TimeStatus Attribute (#ZCL_TIME_ATTR_TIME_STATUS)
Definition: zcl_time.c:54
_zcl_time_debug int _zcl_time_timestatus_set(const zcl_attribute_full_t FAR *attribute, zcl_attribute_write_rec_t *rec)
Definition: zcl_time.c:163
int _zcl_time_time_set(const zcl_attribute_full_t FAR *attribute, zcl_attribute_write_rec_t *rec)
Definition: zcl_time.c:81
zcl_utctime_t zcl_time_time
Definition: zcl_time.c:50

Global attribute list used in #ZCL_CLUST_ENTRY_TIME_SERVER and for adding a Time Cluster Server to an endpoint. The Time Cluster Client does not have any attributes.

XBEE_BEGIN_DECLS const zcl_attribute_tree_t zcl_time_attribute_tree[]
const zcl_attribute_tree_t zcl_time_attribute_tree[]
Initial value:
=
{ { ZCL_MFG_NONE, &zcl_time_attr.time.base, NULL } }
const struct @10 zcl_time_attr
int32_t zcl_time_skew = 0

difference between xbee_seconds_timer() and actual calendar time

zcl_utctime_t zcl_time_time

Current value of Time Attribute (#ZCL_TIME_ATTR_TIME), start value doesn't matter since it is set by _zcl_time_time_get().

uint8_t zcl_time_timestatus = ZCL_TIME_STATUS_MASTER

Current value of TimeStatus Attribute (#ZCL_TIME_ATTR_TIME_STATUS)