XBee Firmware Library  1.6.0
Files | Data Structures | Typedefs | Functions | Variables
Cluster Client support code

Files

file  zcl_client.c
 
file  zcl_client.h
 

Data Structures

struct  zcl_client_read
 

Typedefs

typedef XBEE_BEGIN_DECLS struct zcl_client_read zcl_client_read_t
 
typedef const char *(* zcl_format_utctime_fn) (char dest[40], zcl_utctime_t utctime)
 

Functions

const char * _zcl_format_utctime (char dest[40], zcl_utctime_t utctime)
 
int _zcl_send_read_from_zdo_match (wpan_conversation_t FAR *conversation, const wpan_envelope_t FAR *envelope)
 
int zcl_client_read_attributes (wpan_envelope_t FAR *envelope, const zcl_client_read_t *client_read)
 Send a Read Attributes request for attributes listed in client_read. More...
 
int zcl_create_attribute_records (void FAR *buffer, uint8_t bufsize, const zcl_attribute_base_t FAR **p_attr_list)
 From a list of attributes, write ID (in little-endian byte order), type and value to a buffer as would be done in a Write Attributes Request. More...
 
int zcl_find_and_read_attributes (wpan_dev_t *dev, const uint16_t *clusters, const zcl_client_read_t FAR *cr)
 Use ZDO Match Descriptor Requests to find devices with a given profile/cluster and then automatically send a ZCL Read Attributes request for some of that cluster's attributes. More...
 
int zcl_print_array_value (const void *value, int value_length)
 Print Read Attributes Response value of an array attribute. More...
 
int zcl_print_attribute_value (uint8_t type, const void *value, int value_length)
 
int zcl_print_struct_value (const void *value, int value_length)
 Print Read Attributes Response value of a structure attribute. More...
 
int zcl_process_read_attr_response (zcl_command_t *zcl, const zcl_attribute_base_t FAR *attr_table)
 Process a Read Attributes Response and populate the attibute values into an attribute table as if it was a Write Attributes Request. More...
 
int zcl_send_write_attributes (wpan_envelope_t *envelope, const zcl_attribute_base_t FAR *attr_list)
 
int zdo_send_match_desc (wpan_dev_t *dev, const uint16_t *clusters, uint16_t profile_id, wpan_response_fn callback, const void FAR *context)
 Send a ZDO Match Descriptor request for a list of cluster IDs. More...
 

Variables

const uint16_t FAR * attribute_list
 
uint16_t cluster_id
 
const wpan_endpoint_table_entry_tep
 
uint16_t mfg_id
 
zcl_format_utctime_fn zcl_format_utctime
 Pointer to function that converts a zcl_utctime_t value to a human-readable timestamp. More...
 
zcl_format_utctime_fn zcl_format_utctime = _zcl_format_utctime
 Pointer to function that converts a zcl_utctime_t value to a human-readable timestamp. More...
 

Detailed Description

Typedef Documentation

typedef XBEE_BEGIN_DECLS struct zcl_client_read zcl_client_read_t
typedef const char*(* zcl_format_utctime_fn) (char dest[40], zcl_utctime_t utctime)

Function Documentation

const char* _zcl_format_utctime ( char  dest[40],
zcl_utctime_t  utctime 
)
zcl_client_debug int _zcl_send_read_from_zdo_match ( wpan_conversation_t FAR *  conversation,
const wpan_envelope_t FAR *  envelope 
)
zcl_client_debug int zcl_client_read_attributes ( wpan_envelope_t FAR *  envelope,
const zcl_client_read_t client_read 
)

Send a Read Attributes request for attributes listed in client_read.

Parameters
[in,out]envelopeaddressing information for sending a ZCL Read Attributes request; this function fills in the payload and length
[in]client_readdata structure used by ZCL clients to do ZDO discovery followed by ZCL attribute reads
Return values
0successfully sent request
!0error sending request
zcl_client_debug int zcl_create_attribute_records ( void FAR *  buffer,
uint8_t  bufsize,
const zcl_attribute_base_t FAR **  p_attr_list 
)

From a list of attributes, write ID (in little-endian byte order), type and value to a buffer as would be done in a Write Attributes Request.

The attribute list should be an array of attribute records, ending with an attribute ID of ZCL_ATTRIBUTE_END_OF_LIST.

Parameters
[out]bufferbuffer to write values to
[in]bufsizesize of buffer
[in,out]p_attr_listpointer to the attribute list to encode in buffer; points to next attribute to encode if buffer is filled
Returns
number of bytes written to buffer
zcl_client_debug int zcl_find_and_read_attributes ( wpan_dev_t dev,
const uint16_t clusters,
const zcl_client_read_t FAR *  cr 
)

Use ZDO Match Descriptor Requests to find devices with a given profile/cluster and then automatically send a ZCL Read Attributes request for some of that cluster's attributes.

Parameters
[in]devdevice to use for time request
[in]clusterspointer to list of server clusters to search for, must end with #WPAN_CLUSTER_END_OF_LIST
[in]crzcl_client_read record containing information on the request (endpoint, attributes, etc.); must be a static object (not an auto variable) since the ZDO responder will need to access it
Return values
0request sent
!0error sending request
int zcl_print_array_value ( const void *  value,
int  value_length 
)

Print Read Attributes Response value of an array attribute.

Helper function for zcl_print_attribute_value(), takes a pointer to the "value" field of a Read Attributes Response for an array type, formats it and prints to stdout.

1  Example:
2 of 3 UNSIGNED_8BIT
3  [0] = 0x54 = 84
4  [1] = 0x42 = 66
5  [2] = 0x43 = 67
    @param[in]      value                           pointer to ZCL-encoded array value
    @param[in]      value_length    number of bytes at value

    @retval -EINVAL \p value is NULL or \value_length is too small
    @retval >=3             number of bytes from \p value consumed by function

    @sa zcl_print_attribute_value, zcl_print_struct_value
int zcl_print_attribute_value ( uint8_t  type,
const void *  value,
int  value_length 
)

Formats an attribute value and prints it to stdout.

Parameters
[in]typeZCL datatype of attribute's value
[in]valuepointer to the ZCL-encoded value
[in]value_lengthnumber of bytes at value
Return values
-EINVALvalue is NULL or is too small
>=2number of bytes from value consumed by function
See also
zcl_print_array_value, zcl_print_struct_value
int zcl_print_struct_value ( const void *  value,
int  value_length 
)

Print Read Attributes Response value of a structure attribute.

Helper function for zcl_print_attribute_value(), takes a pointer to the "value" field of a Read Attributes Response for a structure type, formats it and prints to stdout.

1  Example:
2 with 3 elements
3  .element0 (TIME_UTCTIME) = 2012-01-01 00:00:00
4  .element1 (UNSIGNED_8BIT) = 0xAA = 170
5  .element2 (SIGNED_8BIT) = 0xAA = -86
    @param[in]      value                           pointer to ZCL-encoded structure value
    @param[in]      value_length    number of bytes at value

    @retval -EINVAL \p value is NULL or \value_length is too small
    @retval >=2             number of bytes from \p value consumed by function

    @sa zcl_print_attribute_value, zcl_print_array_value
zcl_client_debug int zcl_process_read_attr_response ( zcl_command_t zcl,
const zcl_attribute_base_t FAR *  attr_table 
)

Process a Read Attributes Response and populate the attibute values into an attribute table as if it was a Write Attributes Request.

Used in ZCL clients that want to read a lot of ZCL attributes. The client has a mirrored copy of the attributes on the target, and this function is used to populate that copy using the Read Attributes Responses.

Parameters
[in]zclZCL command to process
[in]attr_liststart of the attribute list to use for storing attribute responses
Returns
ZCL status value to send in a default response
zcl_client_debug int zcl_send_write_attributes ( wpan_envelope_t envelope,
const zcl_attribute_base_t FAR *  attr_list 
)
zcl_client_debug int zdo_send_match_desc ( wpan_dev_t dev,
const uint16_t clusters,
uint16_t  profile_id,
wpan_response_fn  callback,
const void FAR *  context 
)

Send a ZDO Match Descriptor request for a list of cluster IDs.

Parameters
[in]devdevice to use for time request
[in]clusterspointer to list of server clusters to search for, must end with #WPAN_CLUSTER_END_OF_LIST
[in]profile_idprofile ID associated with the cluster IDs (cannot be WPAN_APS_PROFILE_ANY)
[in]callbackfunction that will process the ZDO Match Descriptor responses; see wpan_response_fn for the callback's API
[in]contextcontext to pass to callback in the wpan_conversation_t structure
Return values
0request sent
!0error sending request
See also
zcl_find_and_read_attributes()

update API to allow for unicast request in addition to broadcast

Variable Documentation

const uint16_t FAR* attribute_list
uint16_t cluster_id
uint16_t mfg_id
zcl_format_utctime_fn zcl_format_utctime

Pointer to function that converts a zcl_utctime_t value to a human-readable timestamp.

Defaults to a function that formats timestamps as "YYYY-MM-DD HH:MM:SS UTC" or "[Invalid Timestamp] if utctime is 0xFFFFFFFF. Can be overriden by the user program to a function that uses another format. Strings must be limited to 40 characters.

Parameters
[out]destbuffer to hold the formatted string
[in]utctimetime value to format
Returns
Value of parameter dest.

Pointer to function that converts a zcl_utctime_t value to a human-readable timestamp.

Defaults to a function that formats timestamps as "YYYY-MM-DD HH:MM:SS UTC" or "[Invalid Timestamp] if utctime is 0xFFFFFFFF. Can be overriden by the user program to a function that uses another format. Strings must be limited to 40 characters.

Parameters
[out]destbuffer to hold the formatted string
[in]utctimetime value to format
Returns
Value of parameter dest.