Initial commit: ESP32-C6 Zigbee sensor switch project

This commit is contained in:
2025-11-01 11:57:33 +11:00
commit a8fc24fdf5
1792 changed files with 279851 additions and 0 deletions

View File

@@ -0,0 +1,712 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "esp_err.h"
#include "esp_zigbee_type.h"
#include "esp_zigbee_zdo_common.h"
/* MATCH DESC REQ ZCL configuration */
#define ESP_ZB_MATCH_DESC_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for finding */
#define ESP_ZB_MATCH_DESC_REQ_ROLE ESP_ZB_NWK_BROADCAST_RX_ON_WHEN_IDLE /* find non-sleep Zigbee device, 0xFFFD */
#define ESP_ZB_IEEE_ADDR_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for ieee address request */
#define ESP_ZB_NWK_ADDR_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for nwk address request */
#define ESP_ZB_NODE_DESC_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for node descriptor request */
#define ESP_ZB_BIND_DEVICE_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for binding request */
#define ESP_ZB_ACTIVE_EP_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for active endpoint request */
#define ESP_ZB_SIMPLE_DESC_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for simple descriptor request */
#define ESP_ZB_PERMIT_JOIN_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for permit join request */
#define ESP_ZB_DEVICE_LEAVE_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for device leave request */
#define ESP_ZB_DEVICE_BIND_TABLE_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for device bind table request */
#define ESP_ZB_DEVICE_MGMT_LQI_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for zdo mgmt lqi request */
#define ESP_ZB_POWER_DESC_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for zdo power descriptor request */
#define ESP_ZB_NWK_UPDATE_REQ_TIMEOUT (5 * ESP_ZB_TIME_ONE_SECOND) /* timeout for zdo network update request */
/**
* @brief The network address list of associated devices.
*
*/
typedef struct esp_zb_zdo_nwk_addr_list_s {
uint8_t start_index; /*!< Starting index into the list of associated devices for this report. */
uint8_t total; /*!< Count of the number of 16-bit short addresses to follow.*/
uint8_t count; /*!< Number of short addresses in the list. */
uint16_t *nwk_addresses; /*!< Array of network address. */
} esp_zb_zdo_nwk_addr_list_t;
/**
* @brief The Zigbee ZDO nwk_addr response struct.
*
*/
typedef struct esp_zb_zdo_nwk_addr_rsp_s {
esp_zb_ieee_addr_t ieee_addr; /*!< 64-bit address for the Remote Device. */
uint16_t nwk_addr; /*!< 16-bit address for the Remote Device. */
esp_zb_zdo_nwk_addr_list_t *ext_resp; /*!< Extended response: network address of associated devices.
This field only existed when the request was sent with RequestType = 1. */
} esp_zb_zdo_nwk_addr_rsp_t;
/**
* @brief The Zigbee ZDO power desc response struct.
*
*/
typedef struct esp_zb_zdo_power_desc_rsp_s {
uint8_t status; /*!< The status of the Power_Desc_req command, @see esp_zb_zdp_status_t */
uint16_t nwk_addr_of_interest; /*!< NWK address for the request. */
esp_zb_af_node_power_desc_t desc; /*!< Node power descriptor of remote device */
} esp_zb_zdo_power_desc_rsp_t;
/**
* @brief The Zigbee ZDO ieee_addr response struct.
*
* @anchor esp_zb_zdo_ieee_addr_rsp_t
*/
typedef esp_zb_zdo_nwk_addr_rsp_t esp_zb_zdo_ieee_addr_rsp_t;
/** Find device callback
*
* @brief A ZDO match desc request callback for user to get response info.
*
* @note User's callback get response from the remote device that local node wants to find a particular device on endpoint.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] addr A short address of the device response, 0xFFFF - invalid address
* @param[in] endpoint An endpoint of the device response, 0xFF - invalid endpoint
* @param[in] user_ctx User information context, set in `esp_zb_zdo_find_xxx()`
*
*/
typedef void (*esp_zb_zdo_match_desc_callback_t)(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t endpoint, void *user_ctx);
/** IEEE address request callback
*
* @brief A ZDO ieee address request callback for user to get response info.
*
* @note User's callback get response from the remote device that local node wants to get ieee address.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] resp The response of ieee address request, see @ref esp_zb_zdo_ieee_addr_rsp_t.
* @param[in] user_ctx User information context, set in `esp_zb_zdo_ieee_addr_req()`
*
*/
typedef void (*esp_zb_zdo_ieee_addr_callback_t)(esp_zb_zdp_status_t zdo_status, esp_zb_zdo_ieee_addr_rsp_t *resp, void *user_ctx);
/** Network address request callback
*
* @brief A ZDO network address request callback for user to get response info.
*
* @note User's callback gets response from the remote device that local node wants to get network address.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] resp The response of network address request, see @ref esp_zb_zdo_nwk_addr_rsp_s.
* @param[in] user_ctx User information context, set in `esp_zb_zdo_nwk_addr_req()`
*
*/
typedef void (*esp_zb_zdo_nwk_addr_callback_t)(esp_zb_zdp_status_t zdo_status, esp_zb_zdo_nwk_addr_rsp_t *resp, void *user_ctx);
/** Node descriptor callback
*
* @brief A ZDO Node descriptor request callback for user to get node desc info.
*
* @note User's callback get response from the remote device that local node wants to get node descriptor response.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] addr A short address of the device response, 0xFFFF - invalid address
* @param[in] node_desc A pointer to the node desc @ref esp_zb_af_node_desc_s
* @param[in] user_ctx User information context, set in `esp_zb_zdo_node_desc_req()`
*
*/
typedef void (*esp_zb_zdo_node_desc_callback_t)(esp_zb_zdp_status_t zdo_status, uint16_t addr, esp_zb_af_node_desc_t *node_desc, void *user_ctx);
/** Power descriptor callback
*
* @brief A ZDO power descriptor request callback for user to get node power desc info.
*
* @note User's callback get response from the remote device that local node wants to get power descriptor response.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] addr A short address of the device response, 0xFFFF - invalid address
* @param[in] power_desc A pointer to the power desc, refer to esp_zb_af_node_power_desc_t
* @param[in] user_ctx User information context, set in `esp_zb_zdo_power_desc_req()`
*
*/
typedef void (*esp_zb_zdo_power_desc_callback_t)(esp_zb_zdo_power_desc_rsp_t *power_desc, void *user_ctx);
/** Bind request callback
*
* @brief A ZDO bind request callback for user to get response info.
*
* @note user's callback get response from the remote device that local node wants to bind.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] user_ctx User information context, set in `esp_zb_zdo_device_bind_req()`
*
*/
typedef void (*esp_zb_zdo_bind_callback_t)(esp_zb_zdp_status_t zdo_status, void *user_ctx);
/** Active endpoint callback
*
* @brief A ZDO active endpoint request callback for user to get response info.
*
* @note User's callback get response from the remote device that local node wants to get active endpoint.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] ep_count A number of active endpoint
* @param[in] ep_id_list A pointer of the endpoint id list
* @param[in] user_ctx User information context, set in `esp_zb_zdo_active_ep_req()`
*
*/
typedef void (*esp_zb_zdo_active_ep_callback_t)(esp_zb_zdp_status_t zdo_status, uint8_t ep_count, uint8_t *ep_id_list, void *user_ctx);
/** Simple descriptor callback
*
* @brief A ZDO simple descriptor request callback for user to get simple desc info.
*
* @note User's callback get response from the remote device that local node wants to get simple desc.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] simple_desc A pointer to the simple desc @ref esp_zb_af_simple_desc_1_1_s
* @param[in] user_ctx User information context, set in `esp_zb_zdo_simple_desc_req()`
*
*/
typedef void (*esp_zb_zdo_simple_desc_callback_t)(esp_zb_zdp_status_t zdo_status, esp_zb_af_simple_desc_1_1_t *simple_desc, void *user_ctx);
/** Permit join request callback
*
* @brief A ZDO permit join request callback for user to get permit join response info.
*
* @note User's callback get response from the node requested to permit join.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] user_ctx User information context, set in `esp_zb_zdo_permit_joining_req()`
*
*/
typedef void (*esp_zb_zdo_permit_join_callback_t)(esp_zb_zdp_status_t zdo_status, void *user_ctx);
/** Leave request callback
*
* @brief A ZDO leave request callback for user to get leave status.
*
* @note User's callback get response from the device that wants to leave.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
* @param[in] user_ctx User information context, set in `esp_zb_zdo_device_leave_req()`
*
*/
typedef void (*esp_zb_zdo_leave_callback_t)(esp_zb_zdp_status_t zdo_status, void *user_ctx);
/**
* @brief The Zigbee ZDO bind command struct
*
* @note Current implementation of the API ONLY supports 64 bit extended address's address mode. Other address mode will support later.
*
* @note Be aware of the one req_dst_addr is address that command send to, while dst_address is the destination of the binding entry.
*
* @note NOW the dst_addr_mode is default by ZB_BIND_DST_ADDR_MODE_64_BIT_EXTENDED. Later SDK will support other address mode.
*
*/
typedef struct esp_zb_zdo_bind_req_param_s {
esp_zb_ieee_addr_t src_address; /*!< The IEEE address for the source */
uint8_t src_endp; /*!< The source endpoint for the binding entry */
uint16_t cluster_id; /*!< The identifier of the cluster on the source device that is bound to the destination */
uint8_t dst_addr_mode; /*!< The destination address mode ref to esp_zb_zdo_bind_dst_addr_mode_t*/
esp_zb_addr_u dst_address_u; /*!< The destination address for the binding entry */
uint8_t dst_endp; /*!< This field shall be present only if the
* DstAddrMode field has a value of
* refer to ZB_BIND_DST_ADDR_MODE_64_BIT_EXTENDED refer to bind_dst_addr_mode
* and, if present, shall be the
* destination endpoint for the binding entry. */
uint16_t req_dst_addr; /*!< Destination address of the request send to */
} esp_zb_zdo_bind_req_param_t;
/**
* @brief The Zigbee ZDO match descriptor command struct
*/
typedef struct esp_zb_zdo_match_desc_req_param_s {
uint16_t dst_nwk_addr; /*!< NWK address that request sent to */
uint16_t addr_of_interest; /*!< NWK address of interest */
uint16_t profile_id; /*!< Profile ID to be match at the destination which refers to esp_zb_af_profile_id_t */
uint8_t num_in_clusters; /*!< The number of input clusters provided for matching cluster server */
uint8_t num_out_clusters; /*!< The number of output clusters provided for matching cluster client */
uint16_t *cluster_list; /*!< Pointer to an array of uint16_t cluster IDs, with total size
equal to (num_in_clusters + num_out_clusters).
Input cluster IDs start from index 0,
output cluster IDs start from index num_in_clusters. */
} esp_zb_zdo_match_desc_req_param_t;
/**
* @brief The Zigbee ZDO ieee_addr request command struct
*
*/
typedef struct esp_zb_zdo_ieee_addr_req_param_s {
uint16_t dst_nwk_addr; /*!< NWK address that request sent to */
uint16_t addr_of_interest; /*!< NWK address of interest */
uint8_t request_type; /*!< Request type for this command: 0x00 Single device response 0x01 Extended response */
uint8_t start_index; /*!< If the Request type for this command is Extended response, the StartIndex provides the
* starting index for the requested elements of the associated devices list */
} esp_zb_zdo_ieee_addr_req_param_t;
/**
* @brief The Zigbee ZDO nwk_addr request command struct
*
*/
typedef struct esp_zb_zdo_nwk_addr_req_param_s {
uint16_t dst_nwk_addr; /*!< NWK address that request sent to */
esp_zb_ieee_addr_t ieee_addr_of_interest; /*!< IEEE address to be matched by the remote device */
uint8_t request_type; /*!< Request type for this command: 0x00 Single device response 0x01 Extended response */
uint8_t start_index; /*!< If the Request type for this command is Extended response, the StartIndex provides the
* starting index for the requested elements of the associated devices list */
} esp_zb_zdo_nwk_addr_req_param_t;
/**
* @brief The Zigbee ZDO node descriptor command struct
*
*/
typedef struct esp_zb_zdo_node_desc_req_param_s {
uint16_t dst_nwk_addr; /*!< NWK address that is used for IEEE address mapping. */
} esp_zb_zdo_node_desc_req_param_t;
/**
* @brief The Zigbee ZDO power descriptor command struct
*
*/
typedef struct esp_zb_zdo_power_desc_req_param_s {
uint16_t dst_nwk_addr; /*!< NWK address for the request. */
} esp_zb_zdo_power_desc_req_param_t;
/**
* @brief The Zigbee ZDO simple descriptor command struct
*
*/
typedef struct esp_zb_zdo_simple_desc_req_param_s {
uint16_t addr_of_interest; /*!< NWK address of interest */
uint8_t endpoint; /*!< Endpoint of interest */
} esp_zb_zdo_simple_desc_req_param_t;
/**
* @brief The Zigbee ZDO active endpoint command struct
*
*/
typedef struct esp_zb_zdo_active_ep_req_param_s {
uint16_t addr_of_interest; /*!< NWK address of interest */
} esp_zb_zdo_active_ep_req_param_t;
/**
* @brief The Zigbee ZDO permit join command struct
*
*/
typedef struct esp_zb_zdo_permit_joining_req_param_s {
uint16_t dst_nwk_addr; /*!< NWK address that request sent to */
uint8_t permit_duration; /*!< The length of time in seconds. 0x00 and 0xff indicate that permission is disabled or enabled */
uint8_t tc_significance; /*!< If this is set to 0x01 and the remote device is the Trust Center, the command affects the Trust Center
* authentication policy as described in the sub-clauses below; If this is set to 0x00, there is no effect
* on the Trust Center */
} esp_zb_zdo_permit_joining_req_param_t;
/**
* @brief The Zigbee ZDO leave command struct
*
*/
typedef struct esp_zb_zdo_mgmt_leave_req_param_s {
esp_zb_ieee_addr_t device_address; /*!< 64-bit IEEE address on device */
uint16_t dst_nwk_addr; /*!< NWK address that request sent to */
unsigned int reserved: 6; /*!< Reserved */
unsigned int remove_children: 1; /*!< Bitfield of remove children or not */
unsigned int rejoin: 1; /*!< Bitfield of rejoin or not */
} esp_zb_zdo_mgmt_leave_req_param_t;
/**
* @brief The Zigbee ZDO binding table request struct
*
*/
typedef struct esp_zb_zdo_mgmt_bind_param_s {
uint8_t start_index; /*!< The starting index for the requested elements of the Binding Table */
uint16_t dst_addr; /*!< The destination address */
} esp_zb_zdo_mgmt_bind_param_t;
/**
* @brief The Zigbee ZDO binding table record struct
*
*/
typedef struct esp_zb_zdo_binding_table_record_s {
esp_zb_ieee_addr_t src_address; /*!< The source IEEE address for the binding entry. */
uint8_t src_endp; /*!< The source endpoint for the binding entry. */
uint16_t cluster_id; /*!< The identifier of the cluster on the source device that is bound to the destination device. */
uint8_t dst_addr_mode; /*!< Destination address mode @ref esp_zb_zdo_bind_dst_addr_mode_t */
esp_zb_addr_u dst_address; /*!< The destination address for the binding entry.16 or 64 bit. As specified by the dst_addr_mode field.*/
uint8_t dst_endp; /*!< The destination endpoint for binding entry, this field shall be present only if the DstAddrMode field has a value of 0x03
refer to esp_zb_zdo_bind_dst_addr_mode_t */
struct esp_zb_zdo_binding_table_record_s *next; /*!< The next binding table record */
} esp_zb_zdo_binding_table_record_t;
/**
* @brief The Zigbee ZDO binding table information struct for users
*
*/
typedef struct esp_zb_zdo_binding_table_info_s {
uint8_t status; /*!< The status of binding table information refer to esp_zb_zdp_status */
uint8_t index; /*!< The index of binding table record */
uint8_t total; /*!< The total number of records in the binding table for requests */
uint8_t count; /*!< The number of binding table records in the response */
esp_zb_zdo_binding_table_record_t *record; /*!< The binding table record list */
} esp_zb_zdo_binding_table_info_t;
/**
* @brief Structure of network descriptor request of active scan response
*/
typedef struct esp_zb_network_descriptor_s{
uint16_t short_pan_id; /*!< PAN id */
bool permit_joining; /*!< Indicates that at least one router / coordinator on the network currently permits joining */
esp_zb_ieee_addr_t extended_pan_id; /*!< Extended PAN id, the MAC address which forms the network */
uint8_t logic_channel; /*!< The current logical channel occupied by the network. */
bool router_capacity; /*!< This value is set to true if the device is capable of accepting join requests from router-capable
devices and set to FALSE otherwise. */
bool end_device_capacity; /*!< This value is set to true if the device is capable of accepting join requests from end devices
and set to FALSE otherwise.*/
} esp_zb_network_descriptor_t;
/**
* @brief Channel information of Energy Detect
*
*/
typedef struct esp_zb_energy_detect_channel_info_s {
uint8_t channel_number; /*!< The channel of energy detect */
int8_t energy_detected; /*!< The energy value of channel in dbm */
} esp_zb_energy_detect_channel_info_t;
/**
* @brief Structure of Zigbee ZDO Mgmt_Lqi_req command
*
*/
typedef struct esp_zb_zdo_mgmt_lqi_req_param_s {
uint8_t start_index; /*!< Starting Index for the requested elements of the Neighbor Table */
uint16_t dst_addr; /*!< The destination network short address of request */
} esp_zb_zdo_mgmt_lqi_req_param_t;
/**
* @brief Structure of Zigbee ZDO Mgmt_NWK_Update_req command
*
*/
typedef struct esp_zb_zdo_mgmt_nwk_update_req_param_s {
uint32_t scan_channels; /*!< Indicate which channels are to be scanned */
uint8_t scan_duration; /*!< A value used to calculate the length of time to spend scanning each channel. This field is within the range of 0x00 to 0x05 or 0xfe or 0xff.
If it has a value of 0xfe this is a request for channel change.
If it has a value of 0xff this is a request to change the apsChannelMaskList and nwkManagerAddr attributes. */
uint8_t scan_count; /*!< This field represents the number of energy scans to be conducted and reported.
This field shall be present only if the scan_duration is within the range of 0x00 to 0x05. */
uint16_t nwk_manager_addr; /*!< This field shall be present only if the scan_duration is set to 0xff, and, where present,
indicates the NWK address for the device with the Network Manager bit set in its Node Descriptor.*/
uint16_t dst_addr; /*!< The destination network short address of request */
} esp_zb_zdo_mgmt_nwk_update_req_param_t;
/**
* @brief Structure of neighbor table list record for Zigbee ZDO Mgmt_Lqi_rsp
*
*/
typedef struct esp_zb_zdo_neighbor_table_list_record_s {
esp_zb_ext_pan_id_t extended_pan_id; /*!< 64-bit extended pan id of the neighboring device */
esp_zb_ieee_addr_t extended_addr; /*!< 64-bit IEEE address that is unique to every device */
uint16_t network_addr; /*!< The 16-bit network address of the neighboring device */
uint8_t device_type:2; /*!< The type of the neighbor device @see esp_zb_nwk_device_type_t */
uint8_t rx_when_idle:2; /*!< Indicates if neighbor's receiver is enabled during idle portions of the CAP
0x00 = Receiver is off
0x01 = Receiver is on
0x02 = Unknown */
uint8_t relationship:3; /*!< The relationship between the neighbor and the current device,
@see esp_zb_nwk_relationship_t */
uint8_t reserved:1; /*!< This reserved bit shall be set to 0 */
uint8_t permit_join; /*!< An indication of whether the neighbor device is accepting join requests */
uint8_t depth; /*!< The tree depth of the neighbor device. A value of 0x00 indicates that the
device is the ZigBee coordinator for the network */
uint8_t lqi; /*!< The estimated link quality for RF transmissions from this device */
} esp_zb_zdo_neighbor_table_list_record_t;
/**
* @brief Structure of Zigbee ZDO Mgmt_Lqi_rsp
*
*/
typedef struct esp_zb_zdo_mgmt_lqi_rsp_s {
uint8_t status; /*!< The status of the Mgmt_Lqi_req command */
uint8_t neighbor_table_entries; /*!< Total number of Neighbor Table entries within the Remote Device. */
uint8_t start_index; /*!< Starting index within the Neighbor Table to begin reporting for the
NeighborTableList.*/
uint8_t neighbor_table_list_count; /*!< Number of Neighbor Table entries included within NeighborTableList. */
esp_zb_zdo_neighbor_table_list_record_t *neighbor_table_list; /*!< A list of descriptors, beginning with the StartIndex element and
continuing for neighbor_table_list_count, of the elements in the
Remote Device's Neighbor Table */
} esp_zb_zdo_mgmt_lqi_rsp_t;
/**
* @brief Structure of Zigbee ZDO Mgmt_Update_notify
*
*/
typedef struct esp_zb_zdo_mgmt_update_notify_s {
uint8_t status; /*!< The status of the Mgmt_NWK_Update_notify command, refer to esp_zb_zdp_status_t */
uint32_t scanned_channels; /*!< The (b27,...,b31) represent the binary encoded Channel Page, (b0, b1,... b26) indicate
which channels were scanned (1 = scan, 0 = do not scan) for each of the 27 valid channels. */
uint16_t total_transmission; /*!< Count of the total transmissions reported by the device. */
uint16_t transmission_failures; /*!< Sum of the total transmission failures reported by the device. */
uint8_t scanned_channels_list_count; /*!< The list shall contain the number of records contained in the EnergyValues parameter. */
uint8_t energy_values[27]; /*!< The result of an energy measurement made on these channels */
} esp_zb_zdo_mgmt_update_notify_t;
/** Active scan network callback
*
* @brief A ZDO active scan request callback for user to get scan list status.
*
* @note User's callback get response from the device that found in network.
*
* @param[in] zdo_status The ZDO response status, refer to esp_zb_zdp_status_t
* @param[in] count Number of discovered networks @p nwk_descriptor
* @param[in] nwk_descriptor The pointer to all discovered networks see refer to esp_zb_network_descriptor_t
*
*/
typedef void (*esp_zb_zdo_scan_complete_callback_t)(esp_zb_zdp_status_t zdo_status, uint8_t count,
esp_zb_network_descriptor_t *nwk_descriptor);
/**
* @brief ZDO energy detect callback
*
* @param[in] status The status of callback, refer to esp_zb_zdp_status_t
* @param[in] count The size of energy detect list
* @param[in] ed_list The list of energy detect information, refer to esp_zb_energy_detect_channel_info_t
*
*/
typedef void (*esp_zb_zdo_energy_detect_callback_t)(esp_zb_zdp_status_t status, uint16_t count,
esp_zb_energy_detect_channel_info_t *channel_info);
/** Binding table request callback
*
* @brief A ZDO binding table request callback for user to get the binding table record of remote device.
*
* @param[in] table_info The binding table record which is only accessed by read, refer to esp_zb_zdo_binding_table_info_s
* @param[in] user_ctx User information context, set in `esp_zb_zdo_binding_table_req()`
*
*/
typedef void (*esp_zb_zdo_binding_table_callback_t)(const esp_zb_zdo_binding_table_info_t *table_info, void *user_ctx);
/** Management LQI Response Callback
*
* @brief A ZDO Mgmt_Lqi_rsp callback for user to get the mgmt lqi record of remote device.
*
* @param[in] rsp The response structure of ZDO mgmt lqi, refer to esp_zb_zdo_mgmt_lqi_rsp_t
* @param[in] user_ctx User information context, set in esp_zb_zdo_mgmt_lqi_req()
*/
typedef void (*esp_zb_zdo_mgmt_lqi_rsp_callback_t)(const esp_zb_zdo_mgmt_lqi_rsp_t *rsp, void *user_ctx);
/** NWK update notify callback
*
* @brief A ZDO Mgmt_NWK_Update_req callback for user to get status of request.
*
* @param[in] zdo_status The ZDO response status, refer to `esp_zb_zdp_status`
*
*/
typedef void (*esp_zb_zdo_mgmt_nwk_update_notify_callback_t)(const esp_zb_zdo_mgmt_update_notify_t *notify, void *user_ctx);
/********************* Declare functions **************************/
/* ZDO command list, more ZDO command will be supported later like node_desc, power_desc */
/**
* @brief Active scan available network.
*
* Network discovery service for scanning available network
*
* @param[in] channel_mask Valid channel mask is from 0x00000800 (only channel 11) to 0x07FFF800 (all channels from 11 to 26)
* @param[in] scan_duration Time spent scanning each channel, in units of ((1 << scan_duration) + 1) * a beacon time.
* @param[in] user_cb A user callback to get the active scan result please refer to esp_zb_zdo_scan_complete_callback_t
*/
void esp_zb_zdo_active_scan_request(uint32_t channel_mask, uint8_t scan_duration, esp_zb_zdo_scan_complete_callback_t user_cb);
/**
* @brief Energy detect request
*
* @param[in] channel_mask The channel mask that will trigger the energy detection, with a range from 0x00000800 to 0x07FFF800.
* @param[in] duration The detection duration on each channel, in units of ((1 << scan_duration) + 1) * a beacon time.
* @param[in] cb A user callback to receive the energy detection result, see esp_zb_zdo_energy_detect_callback_t.
*/
void esp_zb_zdo_energy_detect_request(uint32_t channel_mask, uint8_t duration, esp_zb_zdo_energy_detect_callback_t cb);
/**
* @brief Send bind device request command
*
* @param[in] cmd_req Pointer to the bind request command @ref esp_zb_zdo_bind_req_param_s
* @param[in] user_cb A user callback that will be called if received bind response refer to esp_zb_zdo_bind_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_device_bind_req(esp_zb_zdo_bind_req_param_t *cmd_req, esp_zb_zdo_bind_callback_t user_cb, void *user_ctx);
/**
* @brief Send unbind device request command
*
* @param[in] cmd_req Pointer to the bind request command @ref esp_zb_zdo_bind_req_param_s
* @param[in] user_cb A user callback that will be called if received bind response refer to esp_zb_zdo_bind_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_device_unbind_req(esp_zb_zdo_bind_req_param_t *cmd_req, esp_zb_zdo_bind_callback_t user_cb, void *user_ctx);
/**
* @brief Send find on-off device request command
*
* @param[in] cmd_req Pointer to the find request command @ref esp_zb_zdo_match_desc_req_param_s
* @param[in] user_cb A user callback that will be called if received find response refer to esp_zb_zdo_match_desc_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_find_on_off_light(esp_zb_zdo_match_desc_req_param_t *cmd_req, esp_zb_zdo_match_desc_callback_t user_cb, void *user_ctx);
/**
* @brief Send find color_dimmable device request command
*
* @param[in] cmd_req Pointer to the find request command @ref esp_zb_zdo_match_desc_req_param_s
* @param[in] user_cb A user callback that will be called if received find response refer to esp_zb_zdo_match_desc_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_find_color_dimmable_light(esp_zb_zdo_match_desc_req_param_t *cmd_req, esp_zb_zdo_match_desc_callback_t user_cb, void *user_ctx);
/**
* @brief Send match desc request to find matched Zigbee device
*
* @param[in] param Pointer to @ref esp_zb_zdo_match_desc_req_param_s that will be used to match device
* @param[in] user_cb A user callback that will be called if received find response refer to esp_zb_zdo_match_desc_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
* @return
* - ESP_OK: Success in send match desc request
* - ESP_ERR_NO_MEM: Failed to allocate the memory for the request
* - ESP_ERR_INVALID_SIZE: The size of cluster list is wrong in @p param
*/
esp_err_t esp_zb_zdo_match_cluster(esp_zb_zdo_match_desc_req_param_t *param, esp_zb_zdo_match_desc_callback_t user_cb,
void *user_ctx);
/**
* @brief Send ieee_addr request command
*
* @param[in] cmd_req Pointer to the ieee address request command @ref esp_zb_zdo_ieee_addr_req_param_s
* @param[in] user_cb A user callback that will be called if received ieee address response refer to esp_zb_zdo_ieee_addr_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_ieee_addr_req(esp_zb_zdo_ieee_addr_req_param_t *cmd_req, esp_zb_zdo_ieee_addr_callback_t user_cb, void *user_ctx);
/**
* @brief Send nwk_addr request command
*
* @param[in] cmd_req Pointer to the nwk address request command @ref esp_zb_zdo_nwk_addr_req_param_s
* @param[in] user_cb A user callback that will be called if received nwk address response refer to esp_zb_zdo_nwk_addr_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_nwk_addr_req(esp_zb_zdo_nwk_addr_req_param_t *cmd_req, esp_zb_zdo_nwk_addr_callback_t user_cb, void *user_ctx);
/**
* @brief Send node descriptor request command
*
* @param[in] cmd_req Pointer to the node descriptor request command @ref esp_zb_zdo_node_desc_req_param_s
* @param[in] user_cb A user callback that will be called if received node desc response refer to esp_zb_zdo_node_desc_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_node_desc_req(esp_zb_zdo_node_desc_req_param_t *cmd_req, esp_zb_zdo_node_desc_callback_t user_cb, void *user_ctx);
/**
* @brief Send power descriptor request command
*
* @param[in] cmd_req Pointer to the power descriptor request command @ref esp_zb_zdo_power_desc_req_param_s
* @param[in] user_cb A user callback that will be called if received power desc response refer to esp_zb_zdo_power_desc_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_power_desc_req(esp_zb_zdo_power_desc_req_param_t *cmd_req, esp_zb_zdo_power_desc_callback_t user_cb, void *user_ctx);
/**
* @brief Send simple descriptor request command
*
* @param[in] cmd_req Pointer to the simple descriptor request command @ref esp_zb_zdo_simple_desc_req_param_s
* @param[in] user_cb A user callback that will be called if received simple desc response refer to esp_zb_zdo_simple_desc_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_simple_desc_req(esp_zb_zdo_simple_desc_req_param_t *cmd_req, esp_zb_zdo_simple_desc_callback_t user_cb, void *user_ctx);
/**
* @brief Send active endpoint request command
*
* @param[in] cmd_req Pointer to the active endpoint request command @ref esp_zb_zdo_active_ep_req_param_s
* @param[in] user_cb A user callback that will be called if received active ep response refer to esp_zb_zdo_active_ep_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_active_ep_req(esp_zb_zdo_active_ep_req_param_t *cmd_req, esp_zb_zdo_active_ep_callback_t user_cb, void *user_ctx);
/**
* @brief Send leave request command
*
* @param[in] cmd_req Pointer to the leave request command @ref esp_zb_zdo_mgmt_leave_req_param_s
* @param[in] user_cb A user callback that will be called if received leave response refer to esp_zb_zdo_leave_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_device_leave_req(esp_zb_zdo_mgmt_leave_req_param_t *cmd_req, esp_zb_zdo_leave_callback_t user_cb, void *user_ctx);
/**
* @brief Send permit join request command
*
* @param[in] cmd_req Pointer to the permit join request command @ref esp_zb_zdo_permit_joining_req_param_s
* @param[in] user_cb A user callback that will be called if received permit join response refer to esp_zb_zdo_permit_join_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_permit_joining_req(esp_zb_zdo_permit_joining_req_param_t *cmd_req, esp_zb_zdo_permit_join_callback_t user_cb, void *user_ctx);
/**
* @brief Send binding table request command
*
* @param[in] cmd_req Pointer to the zdo mgmt bind request command @ref esp_zb_zdo_mgmt_bind_param_s
* @param[in] user_cb A user callback that will be called if received binding table response refer to esp_zb_zdo_binding_table_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*
*/
void esp_zb_zdo_binding_table_req(esp_zb_zdo_mgmt_bind_param_t *cmd_req, esp_zb_zdo_binding_table_callback_t user_cb, void *user_ctx);
/**
* @brief Send device announcement command
*
*/
void esp_zb_zdo_device_announcement_req(void);
/**
* @brief Send ZDO management lqi request command
*
* @param[in] cmd_req A pointer indicates the fields of the Mgmt_Lqi_req command, @ref esp_zb_zdo_mgmt_lqi_req_param_s
* @param[in] user_cb A user callback that will be called if received Mgmt_Lqi_req response refer to esp_zb_zdo_mgmt_lqi_rsp_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when user_cb is triggered
*/
void esp_zb_zdo_mgmt_lqi_req(esp_zb_zdo_mgmt_lqi_req_param_t *cmd_req, esp_zb_zdo_mgmt_lqi_rsp_callback_t user_cb, void* user_ctx);
/**
* @brief Send ZDO Mgmt_NWK_Update_req command
*
* If the request is broadcast with a scan_duration of 0xFE or 0xFF, no response will be received. As a result, the user_cb will be
* triggered with ESP_ZB_ZDP_STATUS_TIMEOUT after ESP_ZB_NWK_UPDATE_REQ_TIMEOUT seconds.
*
* @param[in] cmd_req A pointer indicates the fields of the Mgmt_NWK_Update_req command, @ref esp_zb_zdo_mgmt_nwk_update_req_param_s
* @param[in] user_cb A user callback that will be called if received Mgmt_NWK_Update_notify refer to esp_zb_zdo_binding_table_callback_t
* @param[in] user_ctx A void pointer that contains the user defines additional information when callback trigger
*/
void esp_zb_zdo_mgmt_nwk_update_req(esp_zb_zdo_mgmt_nwk_update_req_param_t *cmd_req, esp_zb_zdo_mgmt_nwk_update_notify_callback_t user_cb, void* user_ctx);
/**
* @brief Stringify the Zigbee Device Object signal
*
* @param[in] signal A @ref esp_zb_app_signal_type_t object that expect to stringified
* @return A string pointer of esp_zb_app_signal_type_t
*/
const char *esp_zb_zdo_signal_to_string(esp_zb_app_signal_type_t signal);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,827 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "esp_zigbee_type.h"
#ifdef CONFIG_ZB_GP_ENABLED
#include "zgp/esp_zigbee_zgp.h"
#endif /* CONFIG_ZB_GP_ENABLED */
/**
* @brief ZDP status values
* @anchor esp_zb_zdp_status
* @note the status feedback for the zdo command
*/
typedef enum {
ESP_ZB_ZDP_STATUS_SUCCESS = 0x00, /*!< The requested operation or transmission was completed successfully. */
ESP_ZB_ZDP_STATUS_INV_REQUESTTYPE = 0x80, /*!< The supplied request type was invalid. */
ESP_ZB_ZDP_STATUS_DEVICE_NOT_FOUND = 0x81, /*!< The requested device did not exist on a device following a child descriptor request to a parent.*/
ESP_ZB_ZDP_STATUS_INVALID_EP = 0x82, /*!< The supplied endpoint was equal to 0x00 or between 0xf1 and 0xff. */
ESP_ZB_ZDP_STATUS_NOT_ACTIVE = 0x83, /*!< The requested endpoint is not described by simple descriptor. */
ESP_ZB_ZDP_STATUS_NOT_SUPPORTED = 0x84, /*!< The requested optional feature is not supported on the target device. */
ESP_ZB_ZDP_STATUS_TIMEOUT = 0x85, /*!< A timeout has occurred with the requested operation. */
ESP_ZB_ZDP_STATUS_NO_MATCH = 0x86, /*!< The end device bind request was unsuccessful due to a failure to match any suitable clusters.*/
ESP_ZB_ZDP_STATUS_NO_ENTRY = 0x88, /*!< The unbind request was unsuccessful due to the coordinator or source device not having an entry in its binding table to unbind.*/
ESP_ZB_ZDP_STATUS_NO_DESCRIPTOR = 0x89, /*!< A child descriptor was not available following a discovery request to a parent. */
ESP_ZB_ZDP_STATUS_INSUFFICIENT_SPACE = 0x8a, /*!< The device does not have storage space to support the requested operation. */
ESP_ZB_ZDP_STATUS_NOT_PERMITTED = 0x8b, /*!< The device is not in the proper state to support the requested operation. */
ESP_ZB_ZDP_STATUS_TABLE_FULL = 0x8c, /*!< The device does not have table space to support the operation. */
ESP_ZB_ZDP_STATUS_NOT_AUTHORIZED = 0x8d, /*!< The permissions configuration table on the target indicates that the request is not authorized from this device.*/
ESP_ZB_ZDP_STATUS_BINDING_TABLE_FULL = 0x8e, /*!< The device doesn't have binding table space to support the operation */
ESP_ZB_ZDP_STATUS_INVALID_INDEX = 0x8f, /*!< The index in the received command is out of bounds. */
} esp_zb_zdp_status_t;
/**
* @brief signal passed to the esp_zb_application_signal_handler
* @anchor esp_zb_app_signal_type_t
*/
typedef enum {
/**
* Overview:
* - The device has started in non-BDB commissioning mode.
*
* When generated:
* - After the device has started and completed non-BDB commissioning.
* - In case of a commissioning error.
*
* Status code:
* - ESP_OK: Device has started and joined the network.
* - ESP_FAIL: Device startup failure.
*
* Payload:
* - None.
*/
ESP_ZB_ZDO_SIGNAL_DEFAULT_START = 0x00,
/**
* Overview:
* - Stack framework (scheduler, buffer pool, NVRAM, etc.) startup complete,
* ready for initializing bdb commissioning.
*
* When generated:
* - When the stack starts using the esp_zb_start(false) method.
*
* Status code:
* - ESP_OK: Stack framework has been initialized.
*
* Payload:
* - None.
*/
ESP_ZB_ZDO_SIGNAL_SKIP_STARTUP = 0x01,
/**
* Overview:
* - Indicates that a Zigbee device has joined or rejoined the network.
*
* When generated:
* - Upon receiving the device_annce command.
*
* Status code:
* - ESP_OK: device_annce command was received.
*
* Payload:
* - Refer to esp_zb_zdo_signal_device_annce_params_t
*/
ESP_ZB_ZDO_SIGNAL_DEVICE_ANNCE = 0x02,
/**
* Overview:
* - Indicates that the device itself has left the network.
*
* When generated:
* - Upon receiving the Leave command.
*
* Status code:
* - ESP_OK: Leave command was received.
*
* Payload:
* - Refer to esp_zb_zdo_signal_leave_params_t
*/
ESP_ZB_ZDO_SIGNAL_LEAVE = 0x03,
/**
* Overview:
* - Indicates corrupted or incorrect signal information.
*
* When generated:
* - When incorrect signal information is detected.
*
* Status code:
* - None
*
* Payload:
* - None
*/
ESP_ZB_ZDO_SIGNAL_ERROR = 0x04,
/**
* Overview:
* - Indicate the basic network information of factory new device has been initialized,
* ready for Zigbee commissioning
*
* When generated:
* - Upon the basic device behavior has been initialization
*
* Status code:
* - ESP_OK: Factory new device initialization complete
* - ESP_FAIL: Factory new device commissioning failed
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START = 0x05,
/**
* Overview:
* - Indicate device joins or rejoins network from the configured network information.
*
* When generated:
* - Upon the device joining or rejoining Zigbee network using configuration network information.
*
* Status code:
* - ESP_OK: Join or rejoin successfully
* - ESP_FAIL: Join or rejoin failed
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT = 0x06,
/**
* Overview:
* - Indicates that the Touchlink initiator has successfully started a network with the target and is ready
* for rejoining.
*
* When generated:
* - Upon receiving the Network Start response during the Touchlink commissioning procedure.
*
* Status code:
* - ESP_OK: The new network has been started successfully.
*
* Payload:
* - Refer to esp_zb_bdb_signal_touchlink_nwk_started_params_t
*/
ESP_ZB_BDB_SIGNAL_TOUCHLINK_NWK_STARTED = 0x07,
/**
* Overview:
* - Indicate Touchlink target has join the initiator network.
*
* When generated:
* - Upon Touchlink initiator receives the Network Start response during the Touchlink commissioning procedure.
*
* Status code:
* - ESP_OK: Touchlink target join successfully
*
* Payload:
* - Refer to esp_zb_bdb_signal_touchlink_nwk_joined_router_t
*/
ESP_ZB_BDB_SIGNAL_TOUCHLINK_NWK_JOINED_ROUTER = 0x08,
/**
* Overview:
* - Indicates the result of the Touchlink initiator commissioning process.
*
* When generated:
* - When the Touchlink initiator initiates network commission.
*
* Status code:
* - ESP_OK: Commissioning successful.
* - ESP_FAIL: No valid scan response received.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_TOUCHLINK = 0x09,
/**
* Overview:
* - Indicates the completion of BDB network steering.
*
* When generated:
* - When the device initiates the network steering commissioning process.
*
* Status code:
* - ESP_OK: Network steering completed successfully.
* - ESP_FAIL: Network steering failed or was canceled.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_STEERING = 0x0a,
/**
* Overview:
* - Indicates the completion of BDB network formation.
*
* When generated:
* - When the device initiates the network formation commissioning process.
*
* Status code:
* - ESP_OK: Network formation completed successfully.
* - ESP_FAIL: Network formation failed or was canceled.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_FORMATION = 0x0b,
/**
* Overview:
* - Indicates the completion of BDB finding and binding (F&B) for a target endpoint.
*
* When generated:
* - When F&B target timeout.
*
* Status code:
* - ESP_OK: F&B target identifying time is expired.
* - ESP_FAIL: F&B target identifying is cancelled.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_FINDING_AND_BINDING_TARGET_FINISHED = 0x0c,
/**
* Overview:
* - Indicates the BDB F&B with a Target succeeded or F&B initiator timeout expired or cancelled.
*
* When generated:
* - When F&B target timeout.
*
* Status code:
* - ESP_OK: On success.
* - ESP_FAIL: Expired or cancelled.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_FINDING_AND_BINDING_INITIATOR_FINISHED = 0x0d,
/**
* Overview:
* - Indicates that the Touchlink target is preparing to commission with the initiator.
*
* When generated:
* - When the Touchlink procedure starts on the target device.
*
* Status code:
* - ESP_OK: Waiting for the commissioning procedure to proceed.
* - ESP_FAIL: Touchlink procedure failed or was canceled.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_TOUCHLINK_TARGET = 0x0e,
/**
* Overview:
* - Indicates that the Touchlink target network has started.
*
* When generated:
* - When the Touchlink target starts the network upon receiving a start_network, join_router, or join_ed request.
*
* Status code:
* - ESP_OK: Network started successfully.
* - ESP_FAIL: Network start failed or was canceled.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_TOUCHLINK_NWK = 0x0f,
/**
* Overview:
* - Indicates that the Touchlink target commissioning procedure has finished.
*
* When generated:
* - When the Touchlink target times out or completes the commissioning procedure.
*
* Status code:
* - ESP_OK: Commissioning procedure completed successfully.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_TOUCHLINK_TARGET_FINISHED = 0x10,
/* Reserve: 0x11 */
/**
* Overview:
* - Indicates that a new device has initiated an association procedure.
*
* When generated:
* - When a new device is associated.
*
* Status code:
* - ESP_OK: The new device was successfully associated.
*
* Payload:
* - Refer to esp_zb_nwk_signal_device_associated_params_t
*/
ESP_ZB_NWK_SIGNAL_DEVICE_ASSOCIATED = 0x12,
/**
* Overview:
* - Indicates that a child device has left the network.
*
* When generated:
* - When the leave command is received from the child device.
*
* Status code:
* - ESP_OK: The child device left the network successfully.
*
* Payload:
* - Refer to esp_zb_zdo_signal_leave_indication_params_t
*/
ESP_ZB_ZDO_SIGNAL_LEAVE_INDICATION = 0x13,
/* Reserve: 0x14 */
/**
* Overview:
* - Indicates the GPCB (Green Power Combo Basic) commissioning signal.
*
* When generated:
* - When a device is commissioned or decommissioned by the GPCB.
*
* Status code:
* - ESP_OK: Commissioning or decommissioning completed successfully.
*
* Payload:
* - Refer to esp_zb_zgp_signal_commissioning_params_t
*/
ESP_ZB_ZGP_SIGNAL_COMMISSIONING = 0x15,
/**
* Overview:
* - Indicates the device can enter sleep mode.
*
* When generated:
* - When the stack determines that the device is eligible to enter sleep mode.
*
* Status code:
* - ESP_OK: The device can enter sleep mode.
*
* Payload:
* - Refer to esp_zb_zdo_signal_can_sleep_params_t
*/
ESP_ZB_COMMON_SIGNAL_CAN_SLEEP = 0x16,
/**
* Overview:
* - Indicates whether a specific part of the production configuration was found.
*
* When generated:
* - After restoring the production configuration.
*
* Status code:
* - ESP_OK: Production configuration successfully loaded from storage.
* - ESP_FAIL: No production configuration found in storage.
*
* Payload:
* - None
*/
ESP_ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY = 0x17,
/**
* Overview:
* - Indicates that the Neighbor Table has expired, and no active route links remain.
*
* When generated:
* - When all routes have expired.
*
* Status code:
* - ESP_OK: All routers have expired.
*
* Payload:
* - None
*/
ESP_ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT = 0x18,
/* Reserve: 0x19 - 0x2e */
/**
* Overview:
* - Indicates that a new device has been authorized by the Trust Center in the network.
*
* When generated:
* - Upon successful authorization.
* - Upon authorization failure.
* - Upon authorization timeout.
*
* Status code:
* - ESP_OK: New device is authorized.
*
* Payload:
* - Refer to esp_zb_zdo_signal_device_authorized_params_t
*/
ESP_ZB_ZDO_SIGNAL_DEVICE_AUTHORIZED = 0x2f,
/**
* Overview:
* - Indicates that a device has joined, rejoined, or left the network from the Trust Center or its parents.
*
* When generated:
* - Standard device secured rejoin.
* - Standard device unsecured join.
* - Device left.
* - Standard device trust center rejoin.
*
* Status code:
* - ESP_OK: New device information updated.
*
* Payload:
* - Refer to esp_zb_zdo_signal_device_update_params_t
*/
ESP_ZB_ZDO_SIGNAL_DEVICE_UPDATE = 0x30,
/**
* Overview:
* - Detects a PAN ID conflict and inquires for a resolution.
*
* When generated:
* - Upon detecting a PAN ID conflict.
*
* Status code:
* - ESP_OK: On success.
*
* Payload:
* - None
*/
ESP_ZB_NWK_SIGNAL_PANID_CONFLICT_DETECTED = 0x31,
/**
* Overview:
* - Indicates that a network failure has been detected.
*
* When generated:
* - Triggered when the network encounters a failure and the application can implement
* error handling based on the reported status.
*
* Status code:
* - ESP_OK: On success.
*
* Payload:
* - Refer to esp_zb_zdo_signal_nwk_status_indication_params_t
*/
ESP_ZB_NLME_STATUS_INDICATION = 0x32,
/* Reserve: 0x33 - 0x34 */
/**
* Overview:
* - Indicates that the Trust Center rejoin procedure has been completed.
*
* When generated:
* - Upon successful completion of the TC rejoin procedure by the device.
*
* Status code:
* - ESP_OK: TC rejoin completed successfully.
* - ESP_FAIL: Rejoin failed.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_TC_REJOIN_DONE = 0x35,
/**
* Overview:
* - Indicates the status of the network (open or closed).
*
* When generated:
* - When the network is opened.
* - When the network is closed.
*
* Status code:
* - ESP_OK: On successful operation.
*
* Payload:
* - Pointer to uint8_t, indicating the network status (open or closed).
*/
ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS = 0x36,
/**
* Overview:
* - Indicates the result of cancelling BDB steering.
*
* When generated:
* - When `esp_zb_bdb_cancel_steering()` is processed.
*
* Status code:
* - ESP_OK: Steering is cancelled successfully.
* - ESP_ERR_INVALID_STATE: Steering is not in progress.
* - ESP_FAIL: Failed to cancel steering.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_STEERING_CANCELLED = 0x37,
/**
* Overview:
* - Notifies the result of cancelling BDB formation.
*
* When generated:
* - When `esp_zb_bdb_cancel_formation()` is processed.
*
* Status code:
* - ESP_OK: Formation is cancelled successfully.
* - ESP_ERR_INVALID_STATE: Formation is not in progress.
* - ESP_FAIL: Failed to cancel formation.
*
* Payload:
* - None
*/
ESP_ZB_BDB_SIGNAL_FORMATION_CANCELLED = 0x38,
/* Reserve: 0x39 - 0x3a */
/**
* Overview:
* - Indicates a ZGP mode change.
*
* When generated:
* - When a GPCB Sink changes mode between operational mode and commissioning mode.
*
* Status code:
* - ESP_OK: On success.
*
* Payload:
* - None
*/
ESP_ZB_ZGP_SIGNAL_MODE_CHANGE = 0x3b,
/**
* Overview:
* - Notify that the destination device is unavailable.
*
* When generated:
* - When the stack could not send a packet over NWK or APS, for example:
* - No ACK on the MAC layer;
* - No response to a network address request;
* - No APS-ACK to an APS packet.
*
* Status code:
* - ESP_OK: On success.
*
* Payload:
* - Refer to esp_zb_zdo_device_unavailable_params_t
*/
ESP_ZB_ZDO_DEVICE_UNAVAILABLE = 0x3c,
/**
* Overview:
* - ZGP Approve Commissioning.
*
* When generated:
* - When the ZGP subsystem is ready to create a new pairing, but the APP should check
* if the GPD application functionality matches to continue the pairing.
*
* Status code:
* - ESP_OK: On success.
*
* Payload:
* - Refer to esp_zb_zgp_signal_approve_comm_params_t
*/
ESP_ZB_ZGP_SIGNAL_APPROVE_COMMISSIONING = 0x3d,
ESP_ZB_SIGNAL_END = 0x3e,
} esp_zb_app_signal_type_t;
/**
* @brief The struct of esp zboss app signal message table
* @anchor esp_zb_app_signal_msg_t
*/
typedef struct {
esp_zb_app_signal_type_t signal; /*!< The signal type of Zigbee */
const char *msg; /*!< The string of Zigbee signal */
} esp_zb_app_signal_msg_t;
/**
* @brief The enum of bind request destination address mode
* @anchor esp_zb_zdo_bind_dst_addr_mode_t
*/
typedef enum {
ESP_ZB_ZDO_BIND_DST_ADDR_MODE_16_BIT_GROUP = 0x01U,
ESP_ZB_ZDO_BIND_DST_ADDR_MODE_64_BIT_EXTENDED = 0x03U,
} esp_zb_zdo_bind_dst_addr_mode_t;
/* zdo param define */
/**
* @name Leave types
* @anchor nwk_leave_type
*/
typedef enum {
ESP_ZB_NWK_LEAVE_TYPE_RESET = 0x00, /*!< Leave without rejoin */
ESP_ZB_NWK_LEAVE_TYPE_REJOIN = 0x01 /*!< Leave with rejoin */
} esp_zb_nwk_leave_type_t;
/**
* @brief TC action on incoming update device
*/
typedef enum {
ESP_ZB_ZDO_TC_ACTION_AUTHORIZE = 0x00U, /*!< Authorize device */
ESP_ZB_ZDO_TC_ACTION_DENY = 0x01U, /*!< deny authorization, remove it */
ESP_ZB_ZDO_TC_ACTION_IGNORE = 0x02U /*!< ignore Update Device */
} esp_zb_zdo_update_dev_tc_action_t;
/**
* @brief ZDO update device status
*/
typedef enum {
ESP_ZB_ZDO_STANDARD_DEV_SECURED_REJOIN = 0x00U, /*!< Standard device secured rejoin */
ESP_ZB_ZDO_STANDARD_DEV_UNSECURED_JOIN = 0x01U, /*!< Standard device unsecured join */
ESP_ZB_ZDO_STANDARD_DEV_LEFT = 0x02U, /*!< Standard device left */
ESP_ZB_ZDO_STANDARD_DEV_TC_REJOIN = 0x03U, /*!< Standard device trust center rejoin */
/* 0x04 0x07 = Reserved */
} esp_zb_zdo_update_dev_status_t;
/**
* @brief The payload of ESP_ZB_ZDO_SIGNAL_LEAVE signal
*
*/
typedef struct esp_zb_zdo_signal_leave_params_s {
uint8_t leave_type; /*!< Leave type, refer to esp_zb_nwk_leave_type_t */
} esp_zb_zdo_signal_leave_params_t;
/**
* @brief The payload of ESP_ZB_ZDO_SIGNAL_LEAVE_INDICATION signal
*
*/
typedef struct esp_zb_zdo_signal_leave_indication_params_s {
uint16_t short_addr; /*!< Short address of device requested to leave or leaving device*/
esp_zb_ieee_addr_t device_addr; /*!< Long address of device requested to leave or leaving device*/
uint8_t rejoin; /*!< 1 if this was leave with rejoin; 0 - otherwise */
} esp_zb_zdo_signal_leave_indication_params_t;
/**
* @brief The payload of ESP_ZB_COMMON_SIGNAL_CAN_SLEEP signal
*
*/
typedef struct esp_zb_zdo_signal_can_sleep_params_s {
uint32_t sleep_duration; /*!< sleep duration in milliseconds */
} esp_zb_zdo_signal_can_sleep_params_t;
/**
* @brief The payload of ESP_ZB_ZDO_SIGNAL_DEVICE_ANNCE signal
*
* @note Stack passes this parameter to application when some device joins/rejoins to network.
*/
typedef struct esp_zb_zdo_signal_device_annce_params_s {
uint16_t device_short_addr; /*!< address of device that recently joined to network */
esp_zb_ieee_addr_t ieee_addr; /*!< The 64-bit (IEEE) address assigned to the device. */
uint8_t capability; /*!< The capability of the device. */
} esp_zb_zdo_signal_device_annce_params_t;
/**
* @@brief The payload of ESP_ZB_ZDO_SIGNAL_DEVICE_UPDATE signal
*/
typedef struct esp_zb_zdo_signal_device_update_params_s {
esp_zb_ieee_addr_t long_addr; /*!< Long Address of the updated device */
uint16_t short_addr; /*!< Short Address of the updated device */
uint8_t status; /*!< Indicates the updated status of the device, refer to esp_zb_zdo_update_dev_status_t */
uint8_t tc_action; /*!< Trust center action, refer to esp_zb_zdo_update_dev_tc_action_t */
uint16_t parent_short; /*!< The short address of device's parent */
} esp_zb_zdo_signal_device_update_params_t;
/**
* @brief The payload of ESP_ZB_ZDO_SIGNAL_DEVICE_AUTHORIZED signal
* @note The authorization_type as following:
* 0x00 = Authorization type for legacy devices ( < r21)
* Status:
* 0x00: Authorization success
* 0x01: Authorization failed
* 0x01 = Authorization type for r21 device through TCLK
* Status:
* 0x00: Authorization success
* 0x01: Authorization timeout
* 0x02: Authorization failed
* 0x02 = Authorization type for SE through CBKE
* Status:
* 0x00: Authorization success
*/
typedef struct esp_zb_zdo_signal_device_authorized_params_s {
esp_zb_ieee_addr_t long_addr; /*!< Long Address of the updated device */
uint16_t short_addr; /*!< Short Address of the updated device */
uint8_t authorization_type; /*!< Type of the authorization procedure */
uint8_t authorization_status; /*!< Status of the authorization procedure which depends on authorization_type */
} esp_zb_zdo_signal_device_authorized_params_t;
/**
* @brief The payload of ESP_ZB_ZDO_DEVICE_UNAVAILABLE signal
*
*/
typedef struct esp_zb_zdo_device_unavailable_params_s {
esp_zb_ieee_addr_t long_addr; /*!< Long address of the unavailable device */
uint16_t short_addr; /*!< Short address of unavailable device */
} esp_zb_zdo_device_unavailable_params_t;
#ifdef CONFIG_ZB_GP_ENABLED
/**
* @brief ZGP approve commissioning parameters
*
*/
typedef struct esp_zgp_approve_comm_params_s {
esp_zb_zgpd_id_t zgpd_id; /*!< ZGPD ID */
uint8_t device_id; /*!< ZGPD device ID */
uint16_t manuf_id; /*!< Manufacturer ID (meaningful if device_id = 0xFE or 0xFF) */
uint16_t manuf_model_id; /*!< Manufacturer model ID (meaningful if device_id = 0xFE or 0xFF) */
esp_zb_ieee_addr_t ieee_addr; /*!< ZGPD long IEEE address if available, otherwise filled with zeroes */
uint8_t pairing_endpoint; /*!< Device endpoint, on which commissioning is currently active */
esp_zb_zgp_gpd_cmds_list_t gpd_cmds_list; /*!< ZGPD Command list */
esp_zb_zgp_cluster_list_t cluster_list; /*!< ZGPD Cluster list */
uint8_t num_of_reports; /*!< total number of different report descriptors that GPD sent during the commissioning process */
esp_zb_zgp_raw_report_desc_t reports[ZB_ZGP_APP_DESCR_REPORTS_NUM]; /*!< array of reports*/
bool pairing_configuration; /*!< It is ZB_TRUE in case this approve signal was triggered by GP Pairing Configuration command */
uint8_t actions; /*!< Pairing configuration actions */
uint8_t num_of_endpoints; /*!< Pairing configuration number of paired endpoints field
- 0x00 and 0xfd: there are no paired endpoints
- 0xff: all matching endpoints are to be paired
- 0xfe: paired endpoints are to be derived by the sink itself
- other values: paired_endpoints field is present and contains the list of local endpoints paired to this GPD
**/
uint8_t paired_endpoints[ZB_ZGP_MAX_PAIRED_ENDPOINTS]; /*!< Paired endpoint numbers */
} esp_zgp_approve_comm_params_t;
/**
* @brief The payload of ESP_ZB_ZGP_SIGNAL_APPROVE_COMMISSIONING signal
*
*/
typedef struct esp_zb_zgp_signal_approve_comm_params_s {
esp_zgp_approve_comm_params_t *param; /*!< Parameter for approving commissioning */
} esp_zb_zgp_signal_approve_comm_params_t;
/**
* @brief The payload of ESP_ZB_ZGP_SIGNAL_MODE_CHANGE signal
*
* Stack passes this parameter to application to notify about GP mode change.
*/
typedef struct esp_zb_zgp_signal_mode_change_params_s {
esp_zb_zgp_mode_change_reason_t reason; /*!< Reason for mode change, refer to esp_zb_zgp_mode_change_reason_t */
esp_zb_zgp_mode_t new_mode; /*!< New mode */
} esp_zb_zgp_signal_mode_change_params_t;
/**
* @brief The payload of ESP_ZB_ZGP_SIGNAL_COMMISSIONING signal
*
*/
typedef struct esp_zb_zgp_signal_commissioning_params_s {
esp_zb_zgpd_id_t zgpd_id; /*!< Pointer to GPD ID */
esp_zb_zgp_comm_status_t result; /*!< commissioning result, refer to esp_zb_zgp_comm_status_t */
} esp_zb_zgp_signal_commissioning_params_t;
#endif /* CONFIG_ZB_GP_ENABLED */
/**
* @brief The payload of ESP_ZB_BDB_SIGNAL_TOUCHLINK_NWK_STARTED signal
*
*/
typedef struct esp_zb_bdb_signal_touchlink_nwk_started_params_s {
esp_zb_ieee_addr_t device_ieee_addr; /*!< The ieee address of touchlink target */
uint8_t endpoint; /*!< The endpoint id on the touchlink target */
uint16_t profile_id; /*!< The profile id of touchlink profile */
} esp_zb_bdb_signal_touchlink_nwk_started_params_t;
/**
* @brief The payload of ESP_ZB_BDB_SIGNAL_TOUCHLINK_NWK_JOINED_ROUTER signal
*
*/
typedef esp_zb_bdb_signal_touchlink_nwk_started_params_t esp_zb_bdb_signal_touchlink_nwk_joined_router_t;
/**
* @brief The payload of ESP_ZB_BDB_SIGNAL_TOUCHLINK_NWK_JOINED_ED signal
*
*/
typedef esp_zb_bdb_signal_touchlink_nwk_started_params_t esp_zb_bdb_signal_touchlink_nwk_joined_ed_t;
/**
* @brief The payload of ESP_ZB_NLME_STATUS_INDICATION signal
*
*/
typedef struct esp_zb_zdo_signal_nwk_status_indication_params_s {
uint8_t status; /*!< Error code associated with the failure, refer to esp_zb_nwk_command_status_t */
uint16_t network_addr; /*!< Network device address associated with the status information */
uint8_t unknown_command_id; /*!< Unknown command ID */
} ESP_ZB_PACKED_STRUCT esp_zb_zdo_signal_nwk_status_indication_params_t;
/**
* @brief The payload of ESP_ZB_NWK_SIGNAL_DEVICE_ASSOCIATED signal
*
*/
typedef struct esp_zb_nwk_signal_device_associated_params_s {
esp_zb_ieee_addr_t device_addr; /*!< address of associated device */
} esp_zb_nwk_signal_device_associated_params_t;
#ifdef __cplusplus
}
#endif