Digi XBee(R) ANSI C Host Library
Macros | Functions | Variables
zigbee_zcl.c File Reference

Process General Commands for ZigBee Cluster Library and provide support functions to other layers of the stack. More...

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include "xbee/platform.h"
#include "xbee/byteorder.h"
#include "wpan/aps.h"
#include "zigbee/zcl.h"
#include "zigbee/zcl_types.h"

Macros

#define zigbee_zcl_debug
 
#define ZCL_DISCOVER_ATTRIB_MAX   20
 

Functions

int zcl_send_response (zcl_command_t *request, const void FAR *response, uint16_t length)
 Send a response to a ZCL command. More...
 
const zcl_attribute_base_t FARzcl_attribute_get_next (const zcl_attribute_base_t FAR *entry)
 Return a pointer to the next attribute entry from an attribute table. More...
 
const zcl_attribute_base_t FARzcl_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_build_header (zcl_header_response_t *rsp, zcl_command_t *cmd)
 Support function to fill in a ZCL response header. 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_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_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...
 
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_write_attributes (zcl_command_t *cmd)
 Process the three types of Write Attributes requests. More...
 
int _zcl_encode_struct_value (uint8_t FAR *buffer, int16_t bufsize, const zcl_struct_t FAR *zcl_struct)
 Format a ZCL struct for a Read Attributes Response or a Write Attributes Request. More...
 
int _zcl_encode_array_value (uint8_t FAR *buffer, int16_t bufsize, const zcl_array_t FAR *array)
 Format a ZCL array for a Read Attributes Response or a Write Attributes Request. 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...
 
int _zcl_read_attributes (zcl_command_t *cmd)
 Process the Read Attributes Command (ZCL_CMD_READ_ATTRIB). More...
 
int _zcl_discover_attributes (zcl_command_t *cmd)
 Process the Discover Attributes Command (ZCL_CMD_DISCOVER_ATTRIB). 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...
 
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...
 
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_general_command (const wpan_envelope_t FAR *envelope, void FAR *context)
 Handler for ZCL General Commands. 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

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. More...
 

Detailed Description

Process General Commands for ZigBee Cluster Library and provide support functions to other layers of the stack.

Note
For performance, on a low-resource, single-threaded system, the zcl_command_t object should be a global instead of building it on the stack of zcl_general_command and then passing a pointer around to the other functions.