XBee Firmware Library  1.6.0
Modules | Files | Data Structures | Typedefs | Functions | Variables
ZigBee Cluster Library

Modules

 64-bit integer support
 
 Cluster Client support code
 
 Clusters
 
 Datatypes
 

Files

file  zcl.h
 
file  zigbee_zcl.c
 

Data Structures

struct  zcl_array_t
 
struct  zcl_attribute_base_t
 
struct  zcl_attribute_full_t
 
union  zcl_attribute_minmax_t
 
struct  zcl_attribute_tree_t
 
struct  zcl_attribute_write_rec_t
 
struct  zcl_command_t
 
union  zcl_rec_report_t
 
struct  zcl_struct_element_t
 
struct  zcl_struct_t
 

Typedefs

typedef struct zcl_array_t zcl_array_t
 
typedef PACKED_STRUCT zcl_attrib_t
 
typedef struct zcl_attribute_base_t zcl_attribute_base_t
 
typedef struct zcl_attribute_full_t zcl_attribute_full_t
 
typedef union zcl_attribute_minmax_t zcl_attribute_minmax_t
 
typedef struct zcl_attribute_tree_t zcl_attribute_tree_t
 
typedef uint_fast8_t(* zcl_attribute_update_fn) (const struct zcl_attribute_full_t FAR *entry)
 Function pointer assigned to a ZCL attribute record, called to update the value of the given attribute. More...
 
typedef int(* zcl_attribute_write_fn) (const struct zcl_attribute_full_t FAR *entry, zcl_attribute_write_rec_t *rec)
 Function pointer assigned to a ZCL attribute record, called instead of zcl_decode_attribute() to process a Write Request for the attribute. More...
 
typedef struct zcl_attribute_write_rec_t zcl_attribute_write_rec_t
 
typedef struct zcl_command_t zcl_command_t
 
typedef PACKED_STRUCT zcl_default_response_t
 Used for #ZCL_CMD_DEFAULT_RESP. More...
 
typedef PACKED_STRUCT zcl_discover_attrib_resp_t
 Used for #ZCL_CMD_DISCOVER_ATTRIB_RESP. More...
 
typedef PACKED_STRUCT zcl_discover_attrib_t
 Used for #ZCL_CMD_DISCOVER_ATTRIB. More...
 
typedef PACKED_STRUCT zcl_header_common_t
 Common portion of ZCL header (appears after optional Manufacturer Code) More...
 
typedef PACKED_STRUCT zcl_header_nomfg_t
 
typedef PACKED_STRUCT zcl_header_response_t
 
typedef PACKED_STRUCT zcl_header_t
 
typedef PACKED_STRUCT zcl_header_withmfg_t
 
typedef PACKED_STRUCT zcl_read_struct_attrib_t
 
typedef PACKED_STRUCT zcl_rec_attrib_report_t
 Used for #ZCL_CMD_DISCOVER_ATTRIB_RESP. More...
 
typedef PACKED_STRUCT zcl_rec_read_attrib_array_resp_t
 
typedef PACKED_STRUCT zcl_rec_read_attrib_error_resp_t
 
typedef PACKED_STRUCT zcl_rec_read_attrib_resp_t
 Used for #ZCL_CMD_READ_ATTRIB_RESP. More...
 
typedef PACKED_STRUCT zcl_rec_read_attrib_struct_resp_t
 
typedef PACKED_STRUCT zcl_rec_read_report_cfg_t
 
typedef PACKED_STRUCT zcl_rec_report_error_resp_t
 
typedef PACKED_STRUCT zcl_rec_report_receive_resp_t
 
typedef PACKED_STRUCT zcl_rec_report_receive_t
 
typedef PACKED_STRUCT zcl_rec_report_send_resp_t
 
typedef PACKED_STRUCT zcl_rec_report_send_t
 
typedef union zcl_rec_report_t zcl_rec_reporting_config_t
 
typedef PACKED_STRUCT zcl_rec_reporting_status_t
 
typedef PACKED_STRUCT zcl_rec_write_attrib_status_t
 Used for #ZCL_CMD_WRITE_ATTRIB_RESP. More...
 
typedef PACKED_STRUCT zcl_rec_write_struct_attrib_resp_t
 
typedef PACKED_STRUCT zcl_rec_write_struct_attrib_t
 
typedef PACKED_STRUCT zcl_selector_t
 
typedef struct zcl_struct_element_t zcl_struct_element_t
 
typedef struct zcl_struct_t zcl_struct_t
 

Functions

int _zcl_discover_attributes (zcl_command_t *cmd)
 
zigbee_zcl_debug int _zcl_encode_array_value (uint8_t FAR *buffer, int16_t bufsize, const zcl_array_t FAR *array)
 
zigbee_zcl_debug int _zcl_encode_struct_value (uint8_t FAR *buffer, int16_t bufsize, const zcl_struct_t FAR *zcl_struct)
 
int _zcl_read_attributes (zcl_command_t *cmd)
 
int _zcl_write_attributes (zcl_command_t *cmd)
 
const zcl_attribute_base_t FAR * zcl_attribute_get_next (const zcl_attribute_base_t FAR *entry)
 Return a pointer to the next attribute entry from an attribute table. More...
 
int zcl_build_header (zcl_header_response_t *rsp, zcl_command_t *cmd)
 Support function to fill in a ZCL response header. More...
 
int zcl_check_minmax (const zcl_attribute_base_t FAR *entry, const uint8_t FAR *buffer_le)
 Checks whether a new value from a Write Attributes command is within the limits specified for a given attribute. More...
 
int zcl_command_build (zcl_command_t *cmd, const wpan_envelope_t FAR *envelope, zcl_attribute_tree_t FAR *tree)
 Parse a ZCL request and store in a zcl_command_t structure with fields in fixed locations (therefore easier to use than the variable-length frame header). More...
 
void zcl_command_dump (const zcl_command_t *cmd)
 Debugging routine that dumps contents of a parsed ZCL command structure to STDOUT. More...
 
uint32_t zcl_convert_24bit (const void FAR *value_le, bool_t extend_sign)
 Convert a 24-bit (3-byte) little-endian value to a 32-bit value in host byte order. More...
 
int zcl_decode_attribute (const zcl_attribute_base_t FAR *entry, zcl_attribute_write_rec_t *rec)
 Decode attribute value from a Write Attribute Request or Read Attribute Response record and optionally write to entry. More...
 
int zcl_default_response (zcl_command_t *request, uint8_t status)
 Send a Default Response (#ZCL_CMD_DEFAULT_RESP) to a given command. More...
 
int zcl_encode_attribute_value (uint8_t FAR *buffer, int16_t bufsize, const zcl_attribute_base_t FAR *entry)
 Format a ZCL attribute's value for a Read Attributes Response or a Write Attributes Request. More...
 
void zcl_envelope_payload_dump (const wpan_envelope_t *envelope)
 Debugging routine that parses an envelope payload as a ZCL command and dumps a parsed copy to STDOUT. More...
 
const zcl_attribute_base_t FAR * zcl_find_attribute (const zcl_attribute_base_t FAR *entry, uint16_t search_id)
 Search the attribute table starting at entry, for attribute ID search_id. More...
 
int zcl_general_command (const wpan_envelope_t FAR *envelope, void FAR *context)
 Handler for ZCL General Commands. More...
 
int zcl_invalid_cluster (const wpan_envelope_t FAR *envelope, wpan_ep_state_t FAR *ep_state)
 Called if a request comes in for an invalid endpoint/cluster combination. More...
 
int zcl_invalid_command (const wpan_envelope_t FAR *envelope)
 Called if a request comes in for an invalid command on a valid endpoint/cluster combination. More...
 
int zcl_parse_attribute_record (const zcl_attribute_base_t FAR *entry, zcl_attribute_write_rec_t *write_rec)
 Parse an attribute record from a Write Attributes Request or a Read Attributes Response and possibly store the new attribute value. More...
 
int zcl_send_response (zcl_command_t *request, const void FAR *response, uint16_t length)
 Send a response to a ZCL command. More...
 
const char * zcl_status_text (uint_fast8_t status)
 Converts a ZCL status byte (one of the ZCL_STATUS_* macros) into a string. More...
 

Variables

float _float
 
int32_t _signed
 
uint32_t _unsigned
 
zcl_rec_attrib_report_t attrib [1]
 
uint16_t attrib_id_le
 
uint16_t attrib_id_le
 
uint8_t attrib_type
 
const zcl_attribute_base_t FAR * attributes
 
zcl_attribute_base_t base
 
const void FAR * base_address
 base address of structure More...
 
const uint8_t FAR * buffer
 Source data to write to attribute. More...
 
int16_t buflen
 Number of bytes in buffer. More...
 
const zcl_attribute_base_t FAR * client
 List of attributes for the CLIENT cluster (or NULL if none). More...
 
uint8_t command
 
uint8_t command
 command byte from the ZCL header More...
 
zcl_header_common_t   common
 
 common
 
uint16_t count_le
 number of elements to follow More...
 
uint16_t current_count
 current number of elements More...
 
uint8_t direction
 
const zcl_struct_element_t FAR * element
 elements in the structure More...
 
uint16_t element_count
 number of elements in structure More...
 
uint16_t element_size
 number of bytes in each element More...
 
uint8_t element_type
 
uint8_t elements [1]
 mult. uint8_t type and variable-length value More...
 
const wpan_envelope_t FAR * envelope
 
uint8_t flags
 Parsing flags (see ZCL_ATTR_WRITE_FLAG_* macros for valid flags). More...
 
uint8_t flags
 
uint8_t frame_control
 frame control byte from the ZCL header More...
 
uint16_t id
 
uint16_t id
 
uint16_t id_le
 
uint16_t index_le [15]
 
int16_t length
 length of the ZCL payload More...
 
uint16_t manufacturer_id
 ID for manufacturer-specific attributes or ZCL_MFG_NONE if general. More...
 
zcl_attribute_minmax_t max
 
uint16_t max_count
 maximum number of elements to store More...
 
uint16_t max_interval_le
 
uint8_t max_return_count
 
   mfg
 manufacturer-specific extension More...
 
uint16_t mfg_code
 
uint16_t mfg_code_le
 
zcl_attribute_minmax_t min
 
uint16_t min_interval_le
 
uint16_t offset
 offset into structure More...
 
   PACKED_STRUCT
 
 PACKED_STRUCT
 
uint8_t payload [1]
 first byte of variable-length field More...
 
zcl_attribute_update_fn read
 
zcl_rec_report_receive_t receive
 
zcl_rec_report_send_t report_cfg
 
zcl_selector_t selector
 
zcl_rec_report_send_t send
 
uint8_t sequence
 
uint8_t sequence
 sequence byte from the ZCL header More...
 
const zcl_attribute_base_t FAR * server
 List of attributes for the SERVER cluster (or NULL if none). More...
 
uint8_t status
 
uint8_t status
 
   std
 standard More...
 
uint16_t timeout_period_le
 
union {
   zcl_header_common_t   common
 
      mfg
 manufacturer-specific extension More...
 
      PACKED_STRUCT
 
      std
 standard More...
 
type
 see zigbee/zcl_types.h More...
 
uint8_t type
 
uint8_t type
 type of data stored in array More...
 
uint8_t value [1]
 variable length, depending on type More...
 
const void FAR * value
 
const void FAR * value
 
zcl_attribute_write_fn write
 
const zcl_attribute_tree_t FAR zcl_attributes_none [1]
 
const zcl_attribute_tree_t FAR zcl_attributes_none [1]
 
const void FAR * zcl_payload
 pointer to the ZCL payload (first byte after ZCL header) More...
 
uint8_t zcl_type
 ZCL data type of element. More...
 

Detailed Description

Typedef Documentation

typedef struct zcl_array_t zcl_array_t

If a zcl_attribute_base_t has a type of ZCL_TYPE_ARRAY, its .value points to this structure. It's possible to read and write values of the array by accessing

1 (uint8_t FAR *)arr->value + index * arr->element_size
Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453

General format for an attribute, used for Write Attributes and Report Attributes commands.

Basic structure for storing a list of attributes in a cluster. If .min and .max are both set to 0, there isn't a limit

Note
Consider putting type after id – it would then be possible to have macros for attributes that include the id AND type.

Use this structure for attributes with min/max values or the need to have a read/write function. Be sure to set the ZCL_ATTRIB_FLAG_FULL flag in .base.flags so the attribute is parsed with the correct type.

typedef uint_fast8_t(* zcl_attribute_update_fn) (const struct zcl_attribute_full_t FAR *entry)

Function pointer assigned to a ZCL attribute record, called to update the value of the given attribute.

Necessary for attributes that are tied to physical hardware (only updated when requested) or attributes that change over time (as with the ZCL Identify cluster).

If the return value is not ZCL_STATUS_SUCCESS, the ZCL Read Attributes handler will return that as an error in the response frame.

Parameters
[in,out]entryattribute to update
Return values
ZCL_STATUS_SUCCESSsuccessfully updated value
ZCL_STATUS_HARDWARE_FAILUREunable to update value due to hardware problem
ZCL_STATUS_SOFTWARE_FAILUREunable to update value due to software problem
See also
zcl_attribute_write_fn(), zcl_attribute_full_t
typedef int(* zcl_attribute_write_fn) (const struct zcl_attribute_full_t FAR *entry, zcl_attribute_write_rec_t *rec)

Function pointer assigned to a ZCL attribute record, called instead of zcl_decode_attribute() to process a Write Request for the attribute.

This function typically calls zcl_decode_attribute() to convert the request to a temporary variable and then perform additional checks on it before assigning to the actual variable.

Parameters
[in]entryattribute to update
[in,out]recrecord from Write Request with new value
Returns
number of bytes consumed from Write Request
See also
zcl_attribute_update_fn(), zcl_attribute_full_t
typedef struct zcl_command_t zcl_command_t

Structure populated by zcl_command_build() with the ZCL header from a received ZCL command frame. Does not look at the ZCL payload.

Initial value:
{
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
uint8_t command
Definition: zcl.h:155

Used for #ZCL_CMD_DEFAULT_RESP.

Initial value:
{
uint8_t discovery_complete
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

Used for #ZCL_CMD_DISCOVER_ATTRIB_RESP.

Initial value:
{
uint16_t start_attrib_id_le
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46

Used for #ZCL_CMD_DISCOVER_ATTRIB.

Initial value:
{
uint8_t sequence
Definition: zcl.h:189
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

Common portion of ZCL header (appears after optional Manufacturer Code)

Initial value:
{
uint8_t frame_control
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

ZLC header structure used when building a normal (non-manufacturer-specific response frame.

Initial value:
{
union {
uint8_t frame_control;
} mfg;
uint16_t dummy;
uint8_t frame_control;
} std;
} u
uint16_t mfg_code_le
Definition: zcl.h:197
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
mfg
manufacturer-specific extension
Definition: zcl.h:168
std
standard
Definition: zcl.h:171
PACKED_STRUCT
Definition: zcl.h:165

ZCL header structure used for building response frames that may or may not be manufacturer-specific. Frame is sent starting with element .u.mfg.frame_control or .u.std.frame_control.

Initial value:
{
uint8_t frame_control
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

General header for casting onto an incoming frame. Reference .type.mfg if (.frame_control & ZCL_FRAME_MFG_SPECIFIC != 0). Reference .type.std otherwise.

Initial value:
{
uint8_t frame_control
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

ZLC header structure used when building a manufacturer-specific response frame.

Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t attrib_id_le
Definition: zcl.h:465
Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453

Used for #ZCL_CMD_DISCOVER_ATTRIB_RESP.

Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453
Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453
Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453

Used for #ZCL_CMD_READ_ATTRIB_RESP.

Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453
Initial value:
{
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
uint8_t direction
Definition: zcl.h:496
Initial value:
{
uint8_t status
Definition: zcl.h:423
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
Initial value:
{
uint8_t status
Definition: zcl.h:423
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
Initial value:
{
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
uint8_t direction
Definition: zcl.h:496
Initial value:
{
uint8_t status
Definition: zcl.h:423
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
Initial value:
{
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
uint8_t direction
Definition: zcl.h:496
Initial value:
{
uint8_t status
Definition: zcl.h:423
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
Initial value:
{
uint8_t status
Definition: zcl.h:423
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

Used for #ZCL_CMD_WRITE_ATTRIB_RESP.

Initial value:
{
uint8_t status
Definition: zcl.h:423
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43
Initial value:
{
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
uint16_t id_le
Definition: zcl.h:453
Initial value:
{
uint8_t indicator
unsigned char uint8_t
A unsigned char variable 8 bits.
Definition: types.h:43

A zcl_struct_t contains an array of these elements, describing each element in the structure and its offset from the zcl_struct_t.base_address.

typedef struct zcl_struct_t zcl_struct_t

If a zcl_attribute_base_t has a type of ZCL_TYPE_STRUCT, its .value points to this structure.

Function Documentation

zigbee_zcl_debug int _zcl_discover_attributes ( zcl_command_t cmd)
zigbee_zcl_debug int _zcl_encode_array_value ( uint8_t FAR *  buffer,
int16_t  bufsize,
const zcl_array_t FAR *  array 
)
zigbee_zcl_debug int _zcl_encode_struct_value ( uint8_t FAR *  buffer,
int16_t  bufsize,
const zcl_struct_t FAR *  zcl_struct 
)
zigbee_zcl_debug int _zcl_read_attributes ( zcl_command_t cmd)
zigbee_zcl_debug int _zcl_write_attributes ( zcl_command_t cmd)
zigbee_zcl_debug const zcl_attribute_base_t FAR * zcl_attribute_get_next ( const zcl_attribute_base_t FAR *  entry)

Return a pointer to the next attribute entry from an attribute table.

Parameters
[in]entrycurrent entry from the table
Return values
NULLentry was NULL
!NULLpointer to next attribute record
Note
If entry points to the last entry in the table, this function will return the same address instead of advancing off the end of the table.
See also
zcl_find_attribute
zigbee_zcl_debug int zcl_build_header ( zcl_header_response_t rsp,
zcl_command_t cmd 
)

Support function to fill in a ZCL response header.

Set the frame_control, sequence and optional mfg_code fields of the ZCL response header, and return the offset to the actual start of the header (non-mfg specific skips the first two bytes).

Parameters
[out]rspbuffer to store header of response
[in]cmdcommand we're responding to
Return values
0responding to manufacturer-specific command
2responding to non-manufacturer-specific command
-EINVALinvalid parameter passed to function
zigbee_zcl_debug int zcl_check_minmax ( const zcl_attribute_base_t FAR *  entry,
const uint8_t FAR *  buffer_le 
)

Checks whether a new value from a Write Attributes command is within the limits specified for a given attribute.

Parameters
[in]entryentry to use for min/max check
[in]buffer_lebuffer with new value (in little-endian byte order), from write attributes command
Return values
0new value is within range (or attribute doesn't have a min/max)
-EINVALinvalid parameter passed to function
!0value is out of range
zigbee_zcl_debug int zcl_command_build ( zcl_command_t cmd,
const wpan_envelope_t FAR *  envelope,
zcl_attribute_tree_t FAR *  tree 
)

Parse a ZCL request and store in a zcl_command_t structure with fields in fixed locations (therefore easier to use than the variable-length frame header).

Also uses the direction bit and manufacturer ID to search the attribute tree for the correct list of attributes.

Parameters
[out]cmdbuffer to store parsed ZCL command
[in]envelopeenvelope from received message
[in]treepointer to attribute tree for cluster or NULL if the cluster doesn't have any attributes (typically passed in via endpoint dispatcher)
Return values
0parsed payload from envelope into cmd
-EINVALinvalid parameter passed to function
-EBADMSGframe is too small for ZCL header's frame_control value
zigbee_zcl_debug void zcl_command_dump ( const zcl_command_t cmd)

Debugging routine that dumps contents of a parsed ZCL command structure to STDOUT.

Parameters
[in]cmdzcl_command_t structure populated by zcl_command_build()
zigbee_zcl_debug uint32_t zcl_convert_24bit ( const void FAR *  value_le,
bool_t  extend_sign 
)

Convert a 24-bit (3-byte) little-endian value to a 32-bit value in host byte order.

Parameters
[in]value_lepointer to 3 bytes to convert
[in]extend_signif TRUE, set high byte of result to 0xFF if top bit of 24-bit value is set
Returns
A 32-bit, host-byte-order version of the 24-bit, little-endian value passed in.
zigbee_zcl_debug int zcl_decode_attribute ( const zcl_attribute_base_t FAR *  entry,
zcl_attribute_write_rec_t rec 
)

Decode attribute value from a Write Attribute Request or Read Attribute Response record and optionally write to entry.

Parameters
[in]entryentry from attribute table
[in,out]recstate information for parsing write request
Return values
>=0number of bytes consumed from rec->buffer
-EINVALinvalid parameter passed to function
zigbee_zcl_debug int zcl_default_response ( zcl_command_t request,
uint8_t  status 
)

Send a Default Response (#ZCL_CMD_DEFAULT_RESP) to a given command.

Parameters
[in]requestcommand we're responding to
[in]statusstatus to use in the response (see ZCL_STATUS_* macros under "ZCL Status Enumerations" in zigbee/zcl.h)
Return values
0successfully sent response, or response not required (message was broadcast, sent to the broadcast endpoint, or sender set the disable default response bit)
!0error on send
-EINVALinvalid parameter passed to function
zigbee_zcl_debug int zcl_encode_attribute_value ( uint8_t FAR *  buffer,
int16_t  bufsize,
const zcl_attribute_base_t FAR *  entry 
)

Format a ZCL attribute's value for a Read Attributes Response or a Write Attributes Request.

Copies the value of attribute entry to buffer in little-endian byte order. Will not write more than bufsize bytes. Used to build ZCL frames.

Parameters
[out]bufferbuffer to store encoded attribute
[in]bufsizenumber of bytes available in buffer
[in]entryattribute to encode into buffer
Return values
-ZCL_STATUS_SOFTWARE_FAILUREinvalid parameter passed in
-ZCL_STATUS_DEFINED_OUT_OF_BANDghost attribute with NULL value
-ZCL_STATUS_INSUFFICIENT_SPACEbuffer too small to encode value
-ZCL_STATUS_FAILUREunknown/unsupported attribute type
-ZCL_STATUS_HARDWARE_FAILUREfailure updating attribute value
-ZCL_STATUS_SOFTWARE_FAILUREfailure updating attribute value
>=0number of bytes written
void zcl_envelope_payload_dump ( const wpan_envelope_t envelope)

Debugging routine that parses an envelope payload as a ZCL command and dumps a parsed copy to STDOUT.

Parameters
[in]envelopewpan_envelope_t structure with a ZCL command payload
zigbee_zcl_debug const zcl_attribute_base_t FAR * zcl_find_attribute ( const zcl_attribute_base_t FAR *  entry,
uint16_t  search_id 
)

Search the attribute table starting at entry, for attribute ID search_id.

Parameters
[in]entrystarting entry for search
[in]search_idattribute ID to look for
Return values
NULLattribute id search_id not in list
!NULLpointer to attribute record
zigbee_zcl_debug int zcl_general_command ( const wpan_envelope_t FAR *  envelope,
void FAR *  context 
)

Handler for ZCL General Commands.

Used as the handler for attribute-only clusters (e.g., Basic Cluster), or called from a cluster's handler for commands it doesn't handle.

Will send a Default Response for commands it can't handle.

Currently does not support attribute reporting.

Parameters
[in]envelopeenvelope from received message
[in]contextpointer to attribute tree for cluster or NULL if the cluster doesn't have any attributes (typically passed in via endpoint dispatcher)
Return values
0command was processed, including sending a possible response
!0error sending response or processing command
zigbee_zcl_debug int zcl_invalid_cluster ( const wpan_envelope_t FAR *  envelope,
wpan_ep_state_t FAR *  ep_state 
)

Called if a request comes in for an invalid endpoint/cluster combination.

Sends a Default Response (#ZCL_CMD_DEFAULT_RESP) of #ZCL_STATUS_FAILURE unless the received command was a Default Response or was broadcast.

Parameters
[in]envelopeenvelope from received message
[in]ep_statepointer to endpoint's wpan_ep_state_t
Return values
0command was a default response (and therefore ignored), or a default response was successfully sent
!0error sending response
zigbee_zcl_debug int zcl_invalid_command ( const wpan_envelope_t FAR *  envelope)

Called if a request comes in for an invalid command on a valid endpoint/cluster combination.

Sends a Default Response (#ZCL_CMD_DEFAULT_RESP) unless the received command was a Default Response or was broadcast. Depending on the command received, the response will be one of:

  • ZCL_STATUS_UNSUP_CLUSTER_COMMAND
  • ZCL_STATUS_UNSUP_GENERAL_COMMAND
  • ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND
  • ZCL_STATUS_UNSUP_MANUF_GENERAL_COMMAND
Parameters
[in]envelopeenvelope from received message
Return values
0default response was successfully sent, or command did not require a default response
!0error building or sending response
zigbee_zcl_debug int zcl_parse_attribute_record ( const zcl_attribute_base_t FAR *  entry,
zcl_attribute_write_rec_t write_rec 
)

Parse an attribute record from a Write Attributes Request or a Read Attributes Response and possibly store the new attribute value.

If #ZCL_ATTR_WRITE_FLAG_READ_RESP is set in write_rec->flags, write_rec->buffer will be parsed as a Read Attributes Response record. Otherwise, it's parsed as a Write Attributes Request record.

Parameters
[in]entryattribute table to search or NULL if there aren't any attributes on this cluster
[in,out]write_recstate information for parsing write request
Return values
>=0number of bytes consumed from buffer
-EINVALinvalid parameter passed to function
zigbee_zcl_debug int zcl_send_response ( zcl_command_t request,
const void FAR *  response,
uint16_t  length 
)

Send a response to a ZCL command.

Uses information from the command received to populate fields in the response.

Parameters
[in]requestcommand to respond to
[in]responsepayload to send as response
[in]lengthnumber of bytes in response
Return values
0successfully sent response
!0error on send
zigbee_zcl_debug const char * zcl_status_text ( uint_fast8_t  status)

Converts a ZCL status byte (one of the ZCL_STATUS_* macros) into a string.

Parameters
[in]statusstatus byte to convert
Returns
pointer to an unmodifiable string with a description of the status

Variable Documentation

float _float
int32_t _signed
uint32_t _unsigned
uint16_t attrib_id_le
uint16_t attrib_id_le
uint8_t attrib_type
const zcl_attribute_base_t FAR* attributes

Appropriate list of attributes on this device, related to the command. Based on the direction bit from frame_control and the mfg_code field.

const void FAR* base_address

base address of structure

const uint8_t FAR* buffer

Source data to write to attribute.

int16_t buflen

Number of bytes in buffer.

const zcl_attribute_base_t FAR* client

List of attributes for the CLIENT cluster (or NULL if none).

uint8_t command
uint8_t command

command byte from the ZCL header

common
uint16_t count_le

number of elements to follow

uint16_t current_count

current number of elements

uint8_t direction
const zcl_struct_element_t FAR* element

elements in the structure

uint16_t element_count

number of elements in structure

uint16_t element_size

number of bytes in each element

uint8_t element_type
uint8_t elements[1]

mult. uint8_t type and variable-length value

const wpan_envelope_t FAR* envelope

envelope for the received command, envelope's payload and length include the ZCL header

uint8_t flags

Parsing flags (see ZCL_ATTR_WRITE_FLAG_* macros for valid flags).

uint8_t flags
uint8_t frame_control

frame control byte from the ZCL header

uint16_t id_le
uint16_t index_le[15]
int16_t length

length of the ZCL payload

uint16_t manufacturer_id

ID for manufacturer-specific attributes or ZCL_MFG_NONE if general.

Maximum value for attribute, assumes 32-bit limit. For string attributes, the maximum length that can be stored at value.

uint16_t max_count

maximum number of elements to store

uint16_t max_interval_le
uint8_t max_return_count
mfg

manufacturer-specific extension

mfg

manufacturer-specific extension

uint16_t mfg_code

manufacturer code from the ZCL header, in host byte order, or 0x0000 if not mfg specific

uint16_t mfg_code_le

Minimum value for attribute (currently unused until I pick a value to represent "none").

uint16_t min_interval_le
uint16_t offset

offset into structure

PACKED_STRUCT
Initial value:
PACKED_STRUCT
Initial value:
{
uint16_t mfg_code_le
Definition: zcl.h:197
unsigned int uint16_t
An unsigned integer variable 16 bits.
Definition: types.h:46
PACKED_STRUCT
Initial value:
uint8_t payload[1]

first byte of variable-length field

On an attribute read, the ZCL dispatcher will call the .read function to refresh the attribute's value before responding to the request. Do I need a return value in the function to pass an error up?

zcl_selector_t selector
uint8_t sequence
uint8_t sequence

sequence byte from the ZCL header

const zcl_attribute_base_t FAR* server

List of attributes for the SERVER cluster (or NULL if none).

uint8_t status
uint8_t status

Set to #ZCL_STATUS_SUCCESS if data is valid, or some other ZCL_STATUS_* macro if there's an error.

std

standard

std

standard

uint16_t timeout_period_le
uint8_t type

see zigbee/zcl_types.h

always ZCL_TYPE_STRUCT

one of ZCL_TYPE_ARRAY, ZCL_TYPE_SET, ZCL_TYPE_BAG

only included if status == ZCL_STATUS_SUCCESS

uint8_t type

The ZCL Attribute Type, should be one of the ZCL_TYPE_* macros defined in zigbee/zcl_types.h

uint8_t type

type of data stored in array

uint8_t value[1]

variable length, depending on type

variable length, only if ZCL_STATUS_SUCCESS

const void FAR* value

Pointer to global variable of correct type, set as const to allow for both const and non-const values. (If const, flags should be include #ZCL_ATTRIB_FLAG_READONLY.) If NULL, the ZCL stack will respond to attempts to read/write with ZCL_STATUS_DEFINED_OUT_OF_BAND.

const void FAR* value

On an attribute write, the ZCL dispatcher will call the .write function with a structure containing information about the write request. See the documentation for zcl_attribute_write_fn() for the API, and the Time and Identify clusters for examples of its use.

const zcl_attribute_tree_t FAR zcl_attributes_none[1]
Initial value:
=
{ { ZCL_MFG_NONE, NULL, NULL } }

If a cluster doesn't have attributes, use zcl_attributes_none (a single, empty attribute list) in the cluster definition. Don't use NULL, since the APS dispatcher will use endpoint's context if the cluster's context is NULL.

const zcl_attribute_tree_t FAR zcl_attributes_none[1]

If a cluster doesn't have attributes, use zcl_attributes_none (a single, empty attribute list) in the cluster definition. Don't use NULL, since the APS dispatcher will use endpoint's context if the cluster's context is NULL.

const void FAR* zcl_payload

pointer to the ZCL payload (first byte after ZCL header)

uint8_t zcl_type

ZCL data type of element.