Zigbee Protocol Controller 1.6.0
zigpc_common_zigbee.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "sl_status.h"

Go to the source code of this file.

Classes

struct  zcl_frame_t
 
struct  zcl_command
 
struct  zcl_attribute
 
struct  zcl_cluster_type_t
 
struct  zigbee_endpoint_t
 a model for a zigbee ZCL endpoint More...
 
struct  zcl_profile
 
struct  zigbee_binding_t
 
struct  zigbee_node_t
 A model for a Zigbee End Node. More...
 

Macros

#define ZIGBEE_EUI64_SIZE   8
 Size of EUI64 (an IEEE address) in bytes (8) More...
 
#define ZIGBEE_NULL_EUI64
 EUI64 Invalid Identifier. More...
 
#define ZIGBEE_NULL_EUI64_UINT   0xFFFFFFFFFFFFFFFF
 EUI64 Invalid Identifier (int variant) More...
 
#define ZIGBEE_EUI64_HEX_STR_LENGTH   ((ZIGBEE_EUI64_SIZE * 2) + 1)
 Size of EUI64 string buffer. More...
 
#define ZIGBEE_EXTENDED_PAN_ID_SIZE   8
 Size of an extended PAN identifier in bytes (8). More...
 
#define ZIGBEE_INSTALL_CODE_LENGTH   (16 + 2)
 
#define ZIGBEE_MAX_ENDPOINT_COUNT   255
 
#define ZIGBEE_INVALID_APP_ENDPOINT_ID   0
 The default identifier for non-application endpoint identifier also known as the ZDO endpoint. More...
 
#define ZIGBEE_DEFAULT_APP_ENDPOINT_ID   1
 
#define ZCL_DEFAULT_STR_LENGTH   256
 Default string length for strings used in ZCL. More...
 
#define ZCL_DEFAULT_ARR_LENGTH   16
 Default string length for strings used in ZCL. More...
 
#define ZCL_GROUP_NAME_LENGTH   16
 Expected length of a zigbee group name, as supported in the ZCL specification. More...
 
#define ZCL_MIN_CLUSTER_ID   0x0000
 
#define ZCL_MAX_CLUSTER_ID   0x7fff
 
#define ZCL_MIN_MFCTR_ID   0xfc00
 
#define ZCL_MAX_MFCTR_ID   0xffff
 
#define ZCL_MIN_COMMAND_ID   0x00
 
#define ZCL_MAX_COMMAND_ID   0x7f
 
#define ZCL_MIN_STD_ATTR_ID   0x0000
 
#define ZCL_MAX_STD_ATTR_ID   0x4fff
 
#define ZCL_MIN_GLOB_ATTR_ID   0xf000
 
#define ZCL_MAX_GLOB_ATTR_ID   0xfffe
 
#define ZCL_INVALID_CLUSTER_ID   (ZCL_MAX_CLUSTER_ID + 1)
 
#define ZCL_INVALID_ATTR_ID   (ZCL_MAX_STD_ATTR_ID + 1)
 
#define ZCL_INVALID_COMMAND_ID   0x80
 
#define ZCL_MIN_CLUSTER_ID   0x0000
 
#define ZCL_MAX_CLUSTER_ID   0x7fff
 
#define ZCL_MIN_MFCTR_ID   0xfc00
 
#define ZCL_MAX_MFCTR_ID   0xffff
 
#define ZCL_MIN_COMMAND_ID   0x00
 
#define ZCL_MAX_COMMAND_ID   0x7f
 
#define ZCL_FRAME_BUFFER_SIZE_MAX   255
 
#define ZCL_FRAME_CONTROL_FRAME_TYPE_GLOBAL_COMMAND   ((uint8_t)(0x0 << 0))
 ZCL frame will be set as being a ZCL global command frame type. More...
 
#define ZCL_FRAME_CONTROL_FRAME_TYPE_CLUSTER   ((uint8_t)(0x1 << 0))
 ZCL frame will be set as being a cluster frame type. More...
 
#define ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER   ((uint8_t)(0x0 << 3))
 ZCL frame will be sent as a client to server message. More...
 
#define ZCL_GLOBAL_COMMAND_ID_READ_ATTRIBUTES   (0x00)
 
#define ZCL_GLOBAL_COMMAND_ID_WRITE_ATTRIBUTES   (0x02)
 
#define ZCL_ATTRIBUTE_RESPONSE_RECORDS_MAX   20
 

Typedefs

typedef uint8_t zigbee_eui64_t[ZIGBEE_EUI64_SIZE]
 Zigbee Device EUI64 ID. More...
 
typedef uint64_t zigbee_eui64_uint_t
 Zigbee Device Identifier (stored as integer) More...
 
typedef uint8_t zigbee_install_code_t[ZIGBEE_INSTALL_CODE_LENGTH]
 Zigbee 3.0 Install Code. More...
 
typedef uint16_t zigbee_panid_t
 Zigbee Network PAN ID. More...
 
typedef uint8_t zigbee_ext_panid_t[ZIGBEE_EXTENDED_PAN_ID_SIZE]
 Zigbee Network Extended PAN ID. More...
 
typedef uint8_t zigbee_radio_channel_t
 Zigbee Network Radio Channel. More...
 
typedef uint16_t zigbee_group_id_t
 Zigbee Group Id The internal representation of a group_id. More...
 
typedef uint16_t zigbee_multicast_id_t
 
typedef uint8_t zigbee_endpoint_id_t
 A representation of the endpoint id used on the Zigbee protocol. More...
 
typedef uint16_t zcl_cluster_id_t
 A representation of the endpoint cluster id used in ZCL. More...
 
typedef uint16_t zcl_attribute_id_t
 A representation of the endpoint cluster attribute ID used in ZCL. More...
 
typedef uint8_t zcl_command_id_t
 
typedef uint8_t zcl_command_field_t
 
typedef struct zcl_command zcl_command_t
 
typedef enum e_zcl_cluster_side zcl_cluster_side_t
 An enum representing the role of the cluster on the network. More...
 
typedef struct zcl_attribute zcl_attribute_t
 
typedef struct zcl_profile zcl_profile_t
 
typedef enum zigbee_node_network_status zigbee_node_network_status_t
 The possible states that a Zigbee node can be in. More...
 

Enumerations

enum  zcl_command_type_t { ZCL_CLUSTER_GENERATED_COMMAND = 1 , ZCL_CLUSTER_RECEIVED_COMMAND = 2 }
 
enum  zcl_status_type { ZCL_OP_STATUS_SUCCESS = 0 }
 
enum  zcl_frame_data_type {
  ZCL_DATA_TYPE_UNKNOWN = 0 , ZCL_DATA_TYPE_BOOL = 0x10 , ZCL_DATA_TYPE_MAP8 = 0x18 , ZCL_DATA_TYPE_UINT8 = 0x20 ,
  ZCL_DATA_TYPE_UINT16 = 0x21 , ZCL_DATA_TYPE_UINT32 = 0x23 , ZCL_DATA_TYPE_INT8 = 0x28 , ZCL_DATA_TYPE_INT16 = 0x29 ,
  ZCL_DATA_TYPE_INT32 = 0x2A , ZCL_DATA_TYPE_ENUM8 = 0x30 , ZCL_DATA_TYPE_ENUM16 = 0x31 , ZCL_DATA_TYPE_MAX_VAL
}
 
enum  e_zcl_cluster_side { ZCL_CLUSTER_SERVER_SIDE = 1 , ZCL_CLUSTER_CLIENT_SIDE = 2 }
 An enum representing the role of the cluster on the network. More...
 
enum  e_zcl_attribute_type {
  ZCL_ATTR_TYPE_INVALID = -1 , ZCL_ATTR_TYPE_BOOL = 0x10 , ZCL_ATTR_TYPE_MAP8 = 0x18 , ZCL_ATTR_TYPE_UINT8 = 0x20 ,
  ZCL_ATTR_TYPE_UINT16 = 0x21 , ZCL_ATTR_TYPE_INT16 = 0x29 , ZCL_ATTR_TYPE_ENUM8 = 0x30 , ZCL_ATTR_TYPE_FLOAT = 0x38
}
 
enum  zigbee_node_network_status {
  ZIGBEE_NODE_STATUS_INVALID = 0 , ZIGBEE_NODE_STATUS_NODEID_ASSIGNED , ZIGBEE_NODE_STATUS_INCLUDED , ZIGBEE_NODE_STATUS_INTERVIEW_FAIL ,
  ZIGBEE_NODE_STATUS_INTERVIEWING , ZIGBEE_NODE_STATUS_OFFLINE , ZIGBEE_NODE_STATUS_UNAVAILABLE , ZIGBEE_NODE_STATUS_MAX_VAL
}
 The possible states that a Zigbee node can be in. More...
 
enum  zdo_status_t { ZDO_SUCCESS = 0x00 , ZDO_TABLE_FULL = 0x8c , ZDO_DEVICE_BIND_TABLE_FULL = 0x8e }
 

Functions

zigbee_eui64_uint_t zigbee_eui64_to_uint (const zigbee_eui64_t eui64)
 Convert the array EUI64 representation into 64-bit uint representation. More...
 
sl_status_t zigbee_uint_to_eui64 (zigbee_eui64_uint_t src, zigbee_eui64_t dest)
 Convert the 64-bit uint EUI64 representation into array representation. More...
 
void zigbee_eui64_copy_switch_endian (zigbee_eui64_t dst, const zigbee_eui64_t src)
 Copy EUI64 and switch endianness (BE<->LE) If the src EUI64 is LE, the populated dst EUI64 will be BE If the src EUI64 is BE, the populated dst EUI64 will be LE. More...
 
void zigpc_common_switch_endian (uint8_t *source, uint8_t *dest, size_t size)
 Copy a given buffer of data to another destination, inverting the endianness. More...
 
sl_status_t zigbee_eui64_to_str (const zigbee_eui64_t eui64, char *str_buf, const size_t str_length)
 Convert EUI64 (in BE) into string format based on the hex representation. More...
 
sl_status_t str_to_zigbee_eui64 (const char *str_buf, const size_t str_length, zigbee_eui64_t eui64)
 Extract the Zigbee EUI64 from a UNID string. Only the last 8 bytes of the number are considered. More...
 
sl_status_t zigpc_common_eui64_to_unid (const zigbee_eui64_t eui64, char *dest_unid, const size_t dest_unid_length)
 Convert the Zigbee EUI64 to a UNID string with the UNID prefix configured. More...
 
bool is_valid_zcl_command (const zcl_command_t command)
 check if a given zcl command is valid or not More...
 
sl_status_t copy_command (const zcl_command_t source, zcl_command_t *dest)
 Performs a deep copy of a ZCL Command. Does not require a "free"-ing of memory, as the zcl_command_t data structure is simple. More...
 
bool is_valid_zcl_attribute (const zcl_attribute_t attribute)
 checks if a given ZCL attribute is valid or not More...
 
sl_status_t copy_attribute_list (const zcl_attribute_t *const source, zcl_attribute_t *dest, unsigned int list_size)
 Performs a deep copy of a ZCL Attribute. Does not require a "free"-ing of memory, as the zcl_attribute_t data structure is simple. More...
 
bool is_valid_zcl_cluster (const zcl_cluster_type_t cluster)
 checks if a given ZCL cluster is valid or not More...
 
sl_status_t copy_cluster_list (const zcl_cluster_type_t *const source, zcl_cluster_type_t *dest, unsigned int list_size)
 Allocates memory and performs a deep copy of a ZCL Cluster Type. Memory allocated here must be freed. More...
 
bool is_valid_zigbee_node (const zigbee_node_t node)
 checks if a given zigbee node is valid or not. A zigbee node is considered valid if it has a valid EUI64, at least one valid endpoint and is active. More...
 
sl_status_t copy_node (const zigbee_node_t source, zigbee_node_t *dest)
 Allocates memory and performs a deep copy of a Zigbee Node. Memory allocated here must be freed. More...
 
bool is_valid_zigbee_endpoint (const zigbee_endpoint_t endpoint)
 checks if a given zigbee endpoint is valid or not. For now all endpoints are considered valid More...
 
sl_status_t copy_endpoint (const zigbee_endpoint_t source, zigbee_endpoint_t *dest)
 Allocates memory and performs a deep copy of a Zigbee Endpoint. Memory allocated here must be freed. More...
 
sl_status_t copy_endpoint_list (const zigbee_endpoint_t *const source, zigbee_endpoint_t *dest, unsigned int list_size)
 
sl_status_t zigpc_common_zcl_frame_init_command (zcl_frame_t *const frame, zcl_command_id_t command_id, uint8_t frame_control)
 Initialize the ZCL Frame for sending ZCL command. More...
 
sl_status_t zigpc_common_zcl_frame_fill_data (zcl_frame_t *const frame, enum zcl_frame_data_type type, const void *data)
 Populate the given ZCL frame with data. The data copied is dictated by the type passed in. Once successfully copied into the frame, the buffer size is incremented based on the size of the data type passed in. More...
 
sl_status_t zigpc_common_zcl_frame_fill_raw (zcl_frame_t *const frame, const uint8_t *const data, unsigned int data_size)
 Populate the given ZCL frame with data. Copies raw data from a buffer of a specified size. More...
 

Variables

static const zigbee_group_id_t ZIGBEE_NULL_GROUP_ID = 0
 ZIGBEE_NULL_GROUP_ID The NULL group id, usually used for unicast zigbee operations. More...
 
static const bool ATTR_DIRECTION_REPORTED = true
 
static const bool ATTR_DIRECTION_DESIRED = !ATTR_DIRECTION_REPORTED
 
static const zcl_command_t null_command
 a static data structure representing an NULL or INVALID value for ZCL commands More...
 
static const zigbee_binding_t NULL_BINDING = {0}