34 #ifndef __ZIGBEE_ZCL_H 35 #define __ZIGBEE_ZCL_H 46 #define ZCL_CLUST_BASIC 0x0000 47 #define ZCL_CLUST_POWER_CONFIG 0x0001 48 #define ZCL_CLUST_DEVICE_TEMP_CONFIG 0x0002 49 #define ZCL_CLUST_IDENTIFY 0x0003 50 #define ZCL_CLUST_GROUPS 0x0004 51 #define ZCL_CLUST_SCENES 0x0005 52 #define ZCL_CLUST_ONOFF 0x0006 53 #define ZCL_CLUST_ONOFF_SWITCH_CONFIG 0x0007 54 #define ZCL_CLUST_LEVEL_CONTROL 0x0008 55 #define ZCL_CLUST_ALARMS 0x0009 56 #define ZCL_CLUST_TIME 0x000a 57 #define ZCL_CLUST_RSSI_LOCATION 0x000b 58 #define ZCL_CLUST_ANALOG_IN 0x000c 59 #define ZCL_CLUST_ANALOG_OUT 0x000d 60 #define ZCL_CLUST_ANALOG_VALUE 0x000e 61 #define ZCL_CLUST_BINARY_IN 0x000f 62 #define ZCL_CLUST_BINARY_OUT 0x0010 63 #define ZCL_CLUST_BINARY_VALUE 0x0011 64 #define ZCL_CLUST_MULTI_IN 0x0012 65 #define ZCL_CLUST_MULTI_OUT 0x0013 66 #define ZCL_CLUST_MULTI_VALUE 0x0014 67 #define ZCL_CLUST_COMMISSIONING 0x0015 73 #define ZCL_CLUST_SHADE_CONFIG 0x0100 79 #define ZCL_CLUST_PUMP_CONFIG 0x0200 80 #define ZCL_CLUST_THERMOSTAT 0x0201 81 #define ZCL_CLUST_FAN_CONTROL 0x0202 82 #define ZCL_CLUST_DEHUMIDIFY_CONTROL 0x0203 83 #define ZCL_CLUST_THERMOSTAT_UI_CONFIG 0x0204 89 #define ZCL_CLUST_COLOR_CONTROL 0x0300 90 #define ZCL_CLUST_BALLAST_CONFIG 0x0301 96 #define ZCL_CLUST_ILLUM_MEASURE 0x0400 97 #define ZCL_CLUST_ILLUM_LEVEL_SENSING 0x0401 98 #define ZCL_CLUST_TEMP_MEASURE 0x0402 99 #define ZCL_CLUST_PRESSURE_MEASURE 0x0403 100 #define ZCL_CLUST_FLOW_MEASURE 0x0404 101 #define ZCL_CLUST_HUMIDITY_MEASURE 0x0405 102 #define ZCL_CLUST_OCCUPANCY_SENSING 0x0406 108 #define ZCL_CLUST_IAS_ZONE 0x0500 109 #define ZCL_CLUST_IAS_ACE 0x0501 110 #define ZCL_CLUST_IAS_WD 0x0502 116 #define ZCL_CLUST_GENERIC_TUNNEL 0x0600 117 #define ZCL_CLUST_BACNET_TUNNEL 0x0601 118 #define ZCL_CLUST_BACNET_REG_ANALOG_IN 0x0602 119 #define ZCL_CLUST_BACNET_EXT_ANALOG_IN 0x0603 120 #define ZCL_CLUST_BACNET_REG_ANALOG_OUT 0x0604 121 #define ZCL_CLUST_BACNET_EXT_ANALOG_OUT 0x0605 122 #define ZCL_CLUST_BACNET_REG_ANALOG_VALUE 0x0606 123 #define ZCL_CLUST_BACNET_EXT_ANALOG_VALUE 0x0607 124 #define ZCL_CLUST_BACNET_REG_BINARY_IN 0x0608 125 #define ZCL_CLUST_BACNET_EXT_BINARY_IN 0x0609 126 #define ZCL_CLUST_BACNET_REG_BINARY_OUT 0x060a 127 #define ZCL_CLUST_BACNET_EXT_BINARY_OUT 0x060b 128 #define ZCL_CLUST_BACNET_REG_BINARY_VALUE 0x060c 129 #define ZCL_CLUST_BACNET_EXT_BINARY_VALUE 0x060d 130 #define ZCL_CLUST_BACNET_REG_MULTI_IN 0x060e 131 #define ZCL_CLUST_BACNET_EXT_MULTI_IN 0x060f 132 #define ZCL_CLUST_BACNET_REG_MULTI_OUT 0x0610 133 #define ZCL_CLUST_BACNET_EXT_MULTI_OUT 0x0611 134 #define ZCL_CLUST_BACNET_REG_MULTI_VALUE 0x0612 135 #define ZCL_CLUST_BACNET_EXT_MULTI_VALUE 0x0613 208 #define ZCL_FRAME_TYPE_MASK 0x03 209 #define ZCL_FRAME_TYPE_PROFILE 0x00 211 #define ZCL_FRAME_TYPE_CLUSTER 0x01 213 #define ZCL_FRAME_TYPE_RESERVED1 0x02 215 #define ZCL_FRAME_TYPE_RESERVED2 0x03 217 #define ZCL_FRAME_GENERAL 0x00 218 #define ZCL_FRAME_MFG_SPECIFIC 0x04 222 #define ZCL_FRAME_DIRECTION 0x08 223 #define ZCL_FRAME_CLIENT_TO_SERVER 0 225 #define ZCL_FRAME_SERVER_TO_CLIENT ZCL_FRAME_DIRECTION 229 #define ZCL_FRAME_DISABLE_DEF_RESP 0x10 230 #define ZCL_FRAME_RESERVED_BITS 0xE0 254 #define ZCL_CMD_MATCH(p, mfg, dir, type) \ 255 ((*(const uint8_t FAR *)(p) & \ 256 (ZCL_FRAME_MFG_SPECIFIC | ZCL_FRAME_DIRECTION | ZCL_FRAME_TYPE_MASK)) == \ 257 (ZCL_FRAME_ ## mfg | ZCL_FRAME_ ## dir | ZCL_FRAME_TYPE_ ## type)) 272 #define ZCL_CMD_IS_PROFILE(p) \ 273 (ZCL_FRAME_TYPE_PROFILE == (*(const uint8_t FAR *)(p) & ZCL_FRAME_TYPE_MASK)) 286 #define ZCL_CMD_IS_MFG_CLUSTER(p) \ 287 ((ZCL_FRAME_TYPE_CLUSTER | ZCL_FRAME_MFG_SPECIFIC) == \ 288 ((const uint8_t FAR *)(p) & (ZCL_FRAME_TYPE_MASK | ZCL_FRAME_MFG_SPECIFIC))) 301 #define ZCL_CMD_IS_CLUSTER(p) (ZCL_FRAME_TYPE_CLUSTER == \ 302 (*(const uint8_t FAR *)(p) & (ZCL_FRAME_TYPE_MASK | ZCL_FRAME_MFG_SPECIFIC))) 309 #define ZCL_STATUS_SUCCESS 0x00 310 #define ZCL_STATUS_FAILURE 0x01 311 #define ZCL_STATUS_NOT_AUTHORIZED 0x7e 312 #define ZCL_STATUS_RESERVED_FIELD_NOT_ZERO 0x7f 313 #define ZCL_STATUS_MALFORMED_COMMAND 0x80 314 #define ZCL_STATUS_UNSUP_CLUSTER_COMMAND 0x81 315 #define ZCL_STATUS_UNSUP_GENERAL_COMMAND 0x82 316 #define ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND 0x83 317 #define ZCL_STATUS_UNSUP_MANUF_GENERAL_COMMAND 0x84 318 #define ZCL_STATUS_INVALID_FIELD 0x85 319 #define ZCL_STATUS_UNSUPPORTED_ATTRIBUTE 0x86 320 #define ZCL_STATUS_INVALID_VALUE 0x87 321 #define ZCL_STATUS_READ_ONLY 0x88 322 #define ZCL_STATUS_INSUFFICIENT_SPACE 0x89 323 #define ZCL_STATUS_DUPLICATE_EXISTS 0x8a 324 #define ZCL_STATUS_NOT_FOUND 0x8b 325 #define ZCL_STATUS_UNREPORTABLE_ATTRIBUTE 0x8c 326 #define ZCL_STATUS_INVALID_DATA_TYPE 0x8d 327 #define ZCL_STATUS_INVALID_SELECTOR 0x8e 328 #define ZCL_STATUS_WRITE_ONLY 0x8f 329 #define ZCL_STATUS_INCONSISTENT_STARTUP_STATE 0x90 330 #define ZCL_STATUS_DEFINED_OUT_OF_BAND 0x91 331 #define ZCL_STATUS_ABORT 0x95 332 #define ZCL_STATUS_INVALID_IMAGE 0x96 333 #define ZCL_STATUS_WAIT_FOR_DATA 0x97 334 #define ZCL_STATUS_NO_IMAGE_AVAILABLE 0x98 335 #define ZCL_STATUS_REQUIRE_MORE_IMAGE 0x99 336 #define ZCL_STATUS_HARDWARE_FAILURE 0xc0 337 #define ZCL_STATUS_SOFTWARE_FAILURE 0xc1 338 #define ZCL_STATUS_CALIBRATION_ERROR 0xc2 351 #define ZCL_CMD_READ_ATTRIB 0x00 356 #define ZCL_CMD_READ_ATTRIB_RESP 0x01 360 #define ZCL_CMD_WRITE_ATTRIB 0x02 365 #define ZCL_CMD_WRITE_ATTRIB_UNDIV 0x03 371 #define ZCL_CMD_WRITE_ATTRIB_RESP 0x04 376 #define ZCL_CMD_WRITE_ATTRIB_NORESP 0x05 378 #define ZCL_CMD_CONFIGURE_REPORT 0x06 380 #define ZCL_CMD_CONFIGURE_REPORT_RESP 0x07 382 #define ZCL_CMD_READ_REPORT_CFG 0x08 384 #define ZCL_CMD_READ_REPORT_CFG_RESP 0x09 386 #define ZCL_CMD_REPORT_ATTRIB 0x0a 390 #define ZCL_CMD_DEFAULT_RESP 0x0b 395 #define ZCL_CMD_DISCOVER_ATTRIB 0x0c 401 #define ZCL_CMD_DISCOVER_ATTRIB_RESP 0x0d 403 #define ZCL_CMD_READ_STRUCT_ATTRIB 0x0e 405 #define ZCL_CMD_WRITE_STRUCT_ATTRIB 0x0f 407 #define ZCL_CMD_WRITE_STRUCT_ATTRIB_RESP 0x10 460 #define ZCL_DIRECTION_SEND 0x00 // attributes sent (or reported) 461 #define ZCL_DIRECTION_RECEIVE 0x01 // attributes received 478 typedef union zcl_rec_report_t {
603 #define ZCL_INDICATOR_INDICES_MASK 0x0F 605 #define ZCL_INDICATOR_ACTION_MASK 0xF0 606 #define ZCL_INDICATOR_REPLACE 0x00 607 #define ZCL_INDICATOR_ADD_ELEMENT 0x10 608 #define ZCL_INDICATOR_REMOVE_ELEMENT 0x20 693 #define ZCL_ATTR_WRITE_FLAG_NONE 0x00 694 #define ZCL_ATTR_WRITE_FLAG_ASSIGN 0x01 699 #define ZCL_ATTR_WRITE_FLAG_WRITE_REQ 0x00 700 #define ZCL_ATTR_WRITE_FLAG_READ_RESP 0x02 743 #define ZCL_ATTRIB_FLAG_NONE 0x00 744 #define ZCL_ATTRIB_FLAG_WRITEONLY 0x01 745 #define ZCL_ATTRIB_FLAG_READONLY 0x02 746 #define ZCL_ATTRIB_FLAG_HAS_MIN 0x04 747 #define ZCL_ATTRIB_FLAG_HAS_MAX 0x08 748 #define ZCL_ATTRIB_FLAG_REPORTABLE 0x10 751 #define ZCL_ATTRIB_FLAG_UNUSED1 0x20 753 #define ZCL_ATTRIB_FLAG_RAW 0x40 759 #define ZCL_ATTRIB_FLAG_FULL 0x80 819 const void FAR *value;
851 #define ZCL_ATTRIBUTE_END_OF_LIST 0xFFFF 853 #define ZCL_MFG_NONE 0x0000 941 #endif // __ZIGBEE_ZCL_H 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.
Definition: zigbee_zcl.c:118
unsigned long uint32_t
32-bit unsigned integer
Definition: platform_config.h:43
uint8_t type
type of data stored in array
Definition: zcl.h:818
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...
Definition: zigbee_zcl.c:326
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.
Definition: zigbee_zcl.c:613
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...
Definition: zigbee_zcl.c:1660
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
int zcl_default_response(zcl_command_t *cmd, uint8_t status)
Send a Default Response (ZCL_CMD_DEFAULT_RESP) to a given command.
Definition: zigbee_zcl.c:248
zcl_attribute_minmax_t max
Maximum value for attribute, assumes 32-bit limit.
Definition: zcl.h:789
uint8_t status
Set to #ZCL_STATUS_SUCCESS if data is valid, or some other ZCL_STATUS_* macro if there's an error...
Definition: zcl.h:705
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
const zcl_struct_element_t FAR * element
elements in the structure
Definition: zcl.h:843
uint16_t offset
offset into structure
Definition: zcl.h:829
uint16_t manufacturer_id
ID for manufacturer-specific attributes or ZCL_MFG_NONE if general.
Definition: zcl.h:857
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 attribut...
Definition: zcl.h:680
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 ...
Definition: zigbee_zcl.c:1473
uint16_t current_count
current number of elements
Definition: zcl.h:816
Structure populated by zcl_command_build() with the ZCL header from a received ZCL command frame...
Definition: zcl.h:876
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 optionall...
Definition: zigbee_zcl.c:652
const void FAR * base_address
base address of structure
Definition: zcl.h:841
Volatile part of an endpoint record used to track conversations (requests waiting for responses)...
Definition: aps.h:529
const zcl_attribute_base_t FAR * client
List of attributes for the CLIENT cluster (or NULL if none).
Definition: zcl.h:863
Used for ZCL_CMD_DISCOVER_ATTRIB.
Definition: zcl.h:581
const zcl_attribute_base_t FAR * server
List of attributes for the SERVER cluster (or NULL if none).
Definition: zcl.h:860
General format for an attribute, used for Write Attributes and Report Attributes commands.
Definition: zcl.h:417
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.
Definition: zigbee_zcl.c:159
Basic structure for storing a list of attributes in a cluster.
Definition: zcl.h:735
uint16_t element_count
number of elements in structure
Definition: zcl.h:839
A zcl_struct_t contains an array of these elements, describing each element in the structure and its ...
Definition: zcl.h:826
const uint8_t FAR * buffer
Source data to write to attribute.
Definition: zcl.h:686
If a zcl_attribute_base_t has a type of ZCL_TYPE_ARRAY, its .value points to this structure...
Definition: zcl.h:813
int zcl_parse_attribute_record(const zcl_attribute_base_t FAR *entry, zcl_attribute_write_rec_t *rec)
Parse an attribute record from a Write Attributes Request or a Read Attributes Response and possibly ...
Definition: zigbee_zcl.c:437
Used for ZCL_CMD_DEFAULT_RESP.
Definition: zcl.h:575
int zcl_general_command(const wpan_envelope_t FAR *envelope, void FAR *context)
Handler for ZCL General Commands.
Definition: zigbee_zcl.c:1802
uint8_t zcl_type
ZCL data type of element.
Definition: zcl.h:828
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
uint8_t type
The ZCL Attribute Type, should be one of the ZCL_TYPE_* macros defined in zigbee/zcl_types.h.
Definition: zcl.h:764
uint16_t max_count
maximum number of elements to store
Definition: zcl.h:815
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
Use this structure for attributes with min/max values or the need to have a read/write function...
Definition: zcl.h:779
Used for ZCL_CMD_DISCOVER_ATTRIB_RESP.
Definition: zcl.h:587
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 proc...
Definition: zcl.h:724
If a zcl_attribute_base_t has a type of ZCL_TYPE_STRUCT, its .value points to this structure...
Definition: zcl.h:836
Used for ZCL_CMD_READ_ATTRIB_RESP.
Definition: zcl.h:425
uint16_t mfg_code
manufacturer code from the ZCL header, in host byte order, or 0x0000 if not mfg specific ...
Definition: zcl.h:884
uint8_t frame_control
frame control byte from the ZCL header
Definition: zcl.h:881
Cluster/Endpoint layer for WPAN networks (ZigBee and DigiMesh).
const wpan_envelope_t FAR * envelope
envelope for the received command, envelope's payload and length include the ZCL header ...
Definition: zcl.h:879
zcl_attribute_minmax_t min
Minimum value for attribute (currently unused until I pick a value to represent "none").
Definition: zcl.h:785
< always ZCL_TYPE_STRUCT number of elements to follow mult.
Definition: zcl.h:447
const void FAR * value
Pointer to global variable of correct type, set as const to allow for both const and non-const values...
Definition: zcl.h:770
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.
Definition: zigbee_zcl.c:1701
uint16_t element_size
number of bytes in each element
Definition: zcl.h:817
int16_t buflen
Number of bytes in buffer.
Definition: zcl.h:689
Used for ZCL_CMD_WRITE_ATTRIB_RESP.
Definition: zcl.h:450
< one of ZCL_TYPE_ARRAY, ZCL_TYPE_SET, ZCL_TYPE_BAG
Definition: zcl.h:439
short int16_t
16-bit signed integer
Definition: platform_config.h:40
zcl_attribute_write_fn write
On an attribute write, the ZCL dispatcher will call the .write function with a structure containing i...
Definition: zcl.h:800
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...
Definition: zigbee_zcl.c:1086
uint8_t command
command byte from the ZCL header
Definition: zcl.h:888
const char * zcl_status_text(uint_fast8_t status)
Converts a ZCL status byte (one of the ZCL_STATUS_* macros) into a string.
Definition: zigbee_zcl.c:1901
Used for ZCL_CMD_DISCOVER_ATTRIB_RESP.
Definition: zcl.h:597
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
long int32_t
32-bit signed integer
Definition: platform_config.h:42
uint8_t sequence
sequence byte from the ZCL header
Definition: zcl.h:886
const zcl_attribute_base_t FAR * attributes
Appropriate list of attributes on this device, related to the command.
Definition: zcl.h:892
int zcl_build_header(zcl_header_response_t *rsp, zcl_command_t *cmd)
Support function to fill in a ZCL response header.
Definition: zigbee_zcl.c:199
const void FAR * zcl_payload
pointer to the ZCL payload (first byte after ZCL header)
Definition: zcl.h:894
int bool_t
Variable that can hold 0 or 1, may be an int for speed purporses or uint8_t for size optimization...
Definition: platform_config.h:51
The "envelope" is used to gather all necessary information about a given frame on the network...
Definition: aps.h:40
int zcl_send_response(zcl_command_t *cmd, const void FAR *payload, uint16_t length)
Send a response to a ZCL command.
Definition: zigbee_zcl.c:69
int16_t length
length of the ZCL payload
Definition: zcl.h:896
Macros and structures related to the ZCL datatypes.
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...
Definition: zigbee_zcl.c:49
zcl_attribute_update_fn read
On an attribute read, the ZCL dispatcher will call the .read function to refresh the attribute's valu...
Definition: zcl.h:794
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.
Definition: zigbee_zcl.c:1746
uint8_t flags
Parsing flags (see ZCL_ATTR_WRITE_FLAG_* macros for valid flags).
Definition: zcl.h:692
void zcl_command_dump(const zcl_command_t *cmd)
Debugging routine that dumps contents of a parsed ZCL command structure to STDOUT.
Definition: zigbee_zcl.c:1559