mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 02:37:19 +02:00
Merge branch 'backport/154_receive_handle_done_v5.1' into 'release/v5.1'
Backport/154 receive handle done v5.1 See merge request espressif/esp-idf!28718
This commit is contained in:
@ -169,7 +169,6 @@
|
||||
- "components/esp_phy/lib"
|
||||
- "components/esp_wifi/lib"
|
||||
- "components/esp_coex/lib"
|
||||
- "components/ieee802154/lib"
|
||||
- "components/json/cJSON"
|
||||
- "components/lwip/lwip"
|
||||
- "components/mbedtls/mbedtls"
|
||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -120,10 +120,6 @@
|
||||
path = components/openthread/lib
|
||||
url = ../../espressif/esp-thread-lib.git
|
||||
|
||||
[submodule "components/ieee802154/lib"]
|
||||
path = components/ieee802154/lib
|
||||
url = ../../espressif/esp-ieee802154-lib.git
|
||||
|
||||
[submodule "components/bt/controller/lib_esp32h2/esp32h2-bt-lib"]
|
||||
path = components/bt/controller/lib_esp32h2/esp32h2-bt-lib
|
||||
url = ../../espressif/esp32h2-bt-lib.git
|
||||
|
@ -41,14 +41,6 @@ menu "IEEE 802.15.4"
|
||||
configure the CCA mode to Carrier sense AND energy above threshold
|
||||
endchoice
|
||||
|
||||
config IEEE802154_RECEIVE_DONE_HANDLER
|
||||
bool "Enable the receive done handler feature"
|
||||
default n
|
||||
help
|
||||
configure the receive done handler feature, when enabled, the user must call the
|
||||
function `esp_ieee802154_receive_handle_done` to inform the 802.15.4 driver that
|
||||
the received frame has been processed, so the frame space could be freed.
|
||||
|
||||
config IEEE802154_CCA_MODE
|
||||
depends on IEEE802154_ENABLED
|
||||
int
|
||||
|
@ -47,7 +47,6 @@ IEEE802154_STATIC volatile ieee802154_state_t s_ieee802154_state;
|
||||
static uint8_t *s_tx_frame = NULL;
|
||||
#define IEEE802154_RX_FRAME_SIZE (127 + 1 + 1) // +1: len, +1: for dma test
|
||||
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
// +1: for the stub buffer when the valid buffers are full.
|
||||
//
|
||||
// |--------------------VB[0]--------------------|
|
||||
@ -62,10 +61,6 @@ static uint8_t *s_tx_frame = NULL;
|
||||
// STUB : Stub buffer, used when all valid buffers are under processing, the received frame will be dropped.
|
||||
static uint8_t s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE + 1][IEEE802154_RX_FRAME_SIZE];
|
||||
static esp_ieee802154_frame_info_t s_rx_frame_info[CONFIG_IEEE802154_RX_BUFFER_SIZE + 1];
|
||||
#else
|
||||
static uint8_t s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE][IEEE802154_RX_FRAME_SIZE];
|
||||
static esp_ieee802154_frame_info_t s_rx_frame_info[CONFIG_IEEE802154_RX_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
static uint8_t s_rx_index = 0;
|
||||
static uint8_t s_enh_ack_frame[128];
|
||||
@ -85,7 +80,6 @@ typedef struct {
|
||||
static pending_tx_t s_pending_tx = { 0 };
|
||||
#endif
|
||||
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
static void ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_info_t *frame_info)
|
||||
{
|
||||
// If the RX done packet is written in the stub buffer, drop it silently.
|
||||
@ -113,7 +107,7 @@ static void ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, e
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t ieee802154_receive_handle_done(uint8_t *data)
|
||||
esp_err_t ieee802154_receive_handle_done(const uint8_t *data)
|
||||
{
|
||||
uint16_t size = data - &s_rx_frame[0][0];
|
||||
if ((size % IEEE802154_RX_FRAME_SIZE) != 0
|
||||
@ -123,18 +117,6 @@ esp_err_t ieee802154_receive_handle_done(uint8_t *data)
|
||||
s_rx_frame_info[size / IEEE802154_RX_FRAME_SIZE].process = false;
|
||||
return ESP_OK;
|
||||
}
|
||||
#else
|
||||
static void ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_info_t *frame_info)
|
||||
{
|
||||
esp_ieee802154_receive_done(data, frame_info);
|
||||
}
|
||||
|
||||
static void ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info)
|
||||
{
|
||||
esp_ieee802154_transmit_done(frame, ack, ack_frame_info);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static IRAM_ATTR void event_end_process(void)
|
||||
{
|
||||
@ -179,8 +161,8 @@ uint8_t ieee802154_get_recent_lqi(void)
|
||||
IEEE802154_STATIC void set_next_rx_buffer(void)
|
||||
{
|
||||
uint8_t* next_rx_buffer = NULL;
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
uint8_t index = 0;
|
||||
|
||||
if (s_rx_index != CONFIG_IEEE802154_RX_BUFFER_SIZE && s_rx_frame_info[s_rx_index].process == false) {
|
||||
// If buffer is not full, and current index is empty, set it to hardware.
|
||||
next_rx_buffer = s_rx_frame[s_rx_index];
|
||||
@ -204,16 +186,7 @@ IEEE802154_STATIC void set_next_rx_buffer(void)
|
||||
s_rx_index = CONFIG_IEEE802154_RX_BUFFER_SIZE;
|
||||
next_rx_buffer = s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE];
|
||||
}
|
||||
#else
|
||||
if (s_rx_frame[s_rx_index][0] != 0) {
|
||||
s_rx_index++;
|
||||
if (s_rx_index == CONFIG_IEEE802154_RX_BUFFER_SIZE) {
|
||||
s_rx_index = 0;
|
||||
memset(s_rx_frame[s_rx_index], 0, sizeof(s_rx_frame[s_rx_index]));
|
||||
}
|
||||
}
|
||||
next_rx_buffer = (uint8_t *)&s_rx_frame[s_rx_index];
|
||||
#endif
|
||||
|
||||
ieee802154_ll_set_rx_addr(next_rx_buffer);
|
||||
}
|
||||
|
||||
|
@ -338,12 +338,10 @@ uint8_t esp_ieee802154_get_recent_lqi(void)
|
||||
return ieee802154_get_recent_lqi();
|
||||
}
|
||||
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
esp_err_t esp_ieee802154_receive_handle_done(uint8_t *frame)
|
||||
esp_err_t esp_ieee802154_receive_handle_done(const uint8_t *frame)
|
||||
{
|
||||
return ieee802154_receive_handle_done(frame);
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void esp_ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_info_t *frame_info)
|
||||
{
|
||||
|
@ -115,18 +115,20 @@ esp_err_t esp_ieee802154_sleep(void);
|
||||
/**
|
||||
* @brief Set the IEEE 802.15.4 Radio to receive state.
|
||||
*
|
||||
* @note Radio will continue receiving until it receives a valid frame.
|
||||
* Refer to `esp_ieee802154_receive_done()`.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
* Note: Radio will continue receiving until it receives a valid frame.
|
||||
* Ref to esp_ieee802154_receive_done().
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_receive(void);
|
||||
|
||||
/**
|
||||
* @brief Transmit the given frame.
|
||||
* The transmit result will be reported via `esp_ieee802154_transmit_done()`
|
||||
* or `esp_ieee802154_transmit_failed()`.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame, the frame format:
|
||||
* |-----------------------------------------------------------------------|
|
||||
@ -138,9 +140,6 @@ esp_err_t esp_ieee802154_receive(void);
|
||||
* - ESP_OK on success.
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
* Note: The transmit result will be reported via esp_ieee802154_transmit_done()
|
||||
* or esp_ieee802154_transmit_failed().
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_transmit(const uint8_t *frame, bool cca);
|
||||
|
||||
@ -453,35 +452,31 @@ bool esp_ieee802154_get_rx_when_idle(void);
|
||||
*/
|
||||
esp_err_t esp_ieee802154_energy_detect(uint32_t duration);
|
||||
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
/**
|
||||
* @brief Notify the IEEE 802.15.4 Radio that the frame is handled done by upper layer.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame which was passed from the function esp_ieee802154_receive_done.
|
||||
* or ack frame from esp_ieee802154_transmit_done.
|
||||
* @param[in] frame The pointer to the frame which was passed from the function `esp_ieee802154_receive_done()`
|
||||
* or ack frame from `esp_ieee802154_transmit_done()`.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL if frame is invalid.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_receive_handle_done(uint8_t *frame);
|
||||
#endif
|
||||
esp_err_t esp_ieee802154_receive_handle_done(const uint8_t *frame);
|
||||
|
||||
/** Below are the events generated by IEEE 802.15.4 subsystem, which are in ISR context **/
|
||||
/**
|
||||
* @brief A Frame was received.
|
||||
*
|
||||
* @note User must call the function `esp_ieee802154_receive_handle_done()` to notify 802.15.4 driver after the received frame is handled.
|
||||
*
|
||||
* @param[in] frame The point to the received frame, frame format:
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | Len | MHR | MAC Payload (no FCS) |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* @param[in] frame_info More information of the received frame, refer to esp_ieee802154_frame_info_t.
|
||||
*
|
||||
* Note: If configuration `IEEE802154_RECEIVE_DONE_HANDLER` is enabled, then the user must call the function
|
||||
* `esp_ieee802154_receive_handle_done()` to inform 802.15.4 driver that the received frame is handled.
|
||||
* See `esp_ieee802154_receive_handle_done()` for more informations.
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info);
|
||||
|
||||
@ -494,27 +489,22 @@ extern void esp_ieee802154_receive_sfd_done(void);
|
||||
/**
|
||||
* @brief The Frame Transmission succeeded.
|
||||
*
|
||||
* @note If the ack frame is not null, user must call the function `esp_ieee802154_receive_handle_done()` to notify 802.15.4 driver
|
||||
* after the ack frame is handled.
|
||||
*
|
||||
* @param[in] frame The pointer to the transmitted frame.
|
||||
* @param[in] ack The received ACK frame, it could be NULL if the transmitted frame's AR bit is not set.
|
||||
* @param[in] ack_frame_info More information of the ACK frame, refer to esp_ieee802154_frame_info_t.
|
||||
*
|
||||
* Note: refer to esp_ieee802154_transmit().
|
||||
*
|
||||
* If configuration `IEEE802154_RECEIVE_DONE_HANDLER` is enabled and ack frame is not null, then after the upper layer has processed the frame,
|
||||
* the user must call the function `esp_ieee802154_receive_handle_done()` to inform 802.15.4 driver that the ack frame is handled.
|
||||
* See `esp_ieee802154_receive_handle_done()` for more informations.
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info);
|
||||
|
||||
/**
|
||||
* @brief The Frame Transmission failed.
|
||||
* @brief The Frame Transmission failed. Refer to `esp_ieee802154_transmit()`.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame.
|
||||
* @param[in] error The transmission failure reason, refer to esp_ieee802154_tx_error_t.
|
||||
*
|
||||
* Note: refer to esp_ieee802154_transmit().
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_transmit_failed(const uint8_t *frame, esp_ieee802154_tx_error_t error);
|
||||
|
||||
@ -525,32 +515,31 @@ extern void esp_ieee802154_transmit_failed(const uint8_t *frame, esp_ieee802154_
|
||||
extern void esp_ieee802154_transmit_sfd_done(uint8_t *frame);
|
||||
|
||||
/**
|
||||
* @brief The energy detection done.
|
||||
* @brief The energy detection done. Refer to `esp_ieee802154_energy_detect()`.
|
||||
*
|
||||
* @param[in] power The detected power level, in dBm.
|
||||
*
|
||||
* Note: refer to esp_ieee802154_energy_detect().
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_energy_detect_done(int8_t power);
|
||||
|
||||
/**
|
||||
* @brief Set the IEEE 802.15.4 Radio to receive state at a specific time.
|
||||
*
|
||||
* @note Radio will start receiving after the timestamp, and continue receiving until it receives a valid frame.
|
||||
* Refer to `esp_ieee802154_receive_done()`.
|
||||
*
|
||||
* @param[in] time A specific timestamp for starting receiving.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
* Note: Radio will start receiving after the timestamp, and continue receiving until it receives a valid frame.
|
||||
* Ref to esp_ieee802154_receive_done().
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_receive_at(uint32_t time);
|
||||
|
||||
/**
|
||||
* @brief Transmit the given frame at a specific time.
|
||||
* The transmit result will be reported via `esp_ieee802154_transmit_done()`
|
||||
* or `esp_ieee802154_transmit_failed()`.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame. Refer to `esp_ieee802154_transmit()`.
|
||||
* @param[in] cca Perform CCA before transmission if it's true, otherwise transmit the frame directly.
|
||||
@ -560,9 +549,6 @@ esp_err_t esp_ieee802154_receive_at(uint32_t time);
|
||||
* - ESP_OK on success.
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
* Note: The transmit result will be reported via esp_ieee802154_transmit_done()
|
||||
* or esp_ieee802154_transmit_failed().
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_transmit_at(const uint8_t *frame, bool cca, uint32_t time);
|
||||
|
||||
|
Submodule components/ieee802154/lib deleted from 102b03c809
@ -110,7 +110,6 @@ esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca);
|
||||
*/
|
||||
esp_err_t ieee802154_receive(void);
|
||||
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
/**
|
||||
* @brief Notify the IEEE 802.15.4 Radio that the frame is handled done by upper layer.
|
||||
*
|
||||
@ -122,8 +121,7 @@ esp_err_t ieee802154_receive(void);
|
||||
* - ESP_FAIL if frame is invalid.
|
||||
*
|
||||
*/
|
||||
esp_err_t ieee802154_receive_handle_done(uint8_t* frame);
|
||||
#endif
|
||||
esp_err_t ieee802154_receive_handle_done(const uint8_t* frame);
|
||||
|
||||
/**
|
||||
* @brief Transmit the given frame at a specific time.
|
||||
|
@ -875,6 +875,7 @@ void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_
|
||||
ack[idx], ack[idx+1], ack[idx+2], ack[idx+3],
|
||||
ack[idx+4], ack[idx+5], ack[idx+6], ack[idx+7]);
|
||||
}
|
||||
esp_ieee802154_receive_handle_done(ack);
|
||||
}
|
||||
}
|
||||
|
||||
@ -886,6 +887,7 @@ void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *fr
|
||||
frame[idx], frame[idx+1], frame[idx+2], frame[idx+3],
|
||||
frame[idx+4], frame[idx+5], frame[idx+6], frame[idx+7]);
|
||||
}
|
||||
esp_ieee802154_receive_handle_done(frame);
|
||||
}
|
||||
|
||||
void esp_ieee802154_energy_detect_done(int8_t power)
|
||||
|
@ -174,9 +174,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
|
||||
otPlatRadioTxDone(aInstance, &s_transmit_frame, NULL, OT_ERROR_NONE);
|
||||
} else {
|
||||
otPlatRadioTxDone(aInstance, &s_transmit_frame, &s_ack_frame, OT_ERROR_NONE);
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
esp_ieee802154_receive_handle_done(s_ack_frame.mPsdu - 1);
|
||||
#endif
|
||||
esp_ieee802154_receive_handle_done(s_ack_frame.mPsdu - 1);
|
||||
s_ack_frame.mPsdu = NULL;
|
||||
}
|
||||
}
|
||||
@ -228,9 +226,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
|
||||
{
|
||||
otPlatRadioReceiveDone(aInstance, &s_receive_frame[s_recv_queue.head], OT_ERROR_NONE);
|
||||
}
|
||||
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
|
||||
esp_ieee802154_receive_handle_done(s_receive_frame[s_recv_queue.head].mPsdu - 1);
|
||||
#endif
|
||||
s_receive_frame[s_recv_queue.head].mPsdu = NULL;
|
||||
s_recv_queue.head = (s_recv_queue.head + 1) % CONFIG_IEEE802154_RX_BUFFER_SIZE;
|
||||
s_recv_queue.used--;
|
||||
|
@ -66,6 +66,8 @@ WIFI_DOCS = ['api-guides/wifi.rst',
|
||||
'api-reference/network/esp_wifi.rst',
|
||||
'api-reference/network/esp_dpp.rst']
|
||||
|
||||
IEEE802154_DOCS = ['migration-guides/release-5.x/5.1/ieee802154.rst']
|
||||
|
||||
NAN_DOCS = ['api-reference/network/esp_nan.rst']
|
||||
|
||||
WIFI_MESH_DOCS = ['api-guides/esp-wifi-mesh.rst',
|
||||
@ -179,6 +181,7 @@ conditional_include_dict = {'SOC_BT_SUPPORTED':BT_DOCS,
|
||||
'SOC_BLUFI_SUPPORTED':BLUFI_DOCS,
|
||||
'SOC_WIFI_SUPPORTED':WIFI_DOCS,
|
||||
'SOC_BT_CLASSIC_SUPPORTED':CLASSIC_BT_DOCS,
|
||||
'SOC_IEEE802154_SUPPORTED':IEEE802154_DOCS,
|
||||
'SOC_SUPPORT_COEXISTENCE':COEXISTENCE_DOCS,
|
||||
'SOC_SDMMC_HOST_SUPPORTED':SDMMC_DOCS,
|
||||
'SOC_SDIO_SLAVE_SUPPORTED':SDIO_SLAVE_DOCS,
|
||||
|
13
docs/en/migration-guides/release-5.x/5.1/ieee802154.rst
Normal file
13
docs/en/migration-guides/release-5.x/5.1/ieee802154.rst
Normal file
@ -0,0 +1,13 @@
|
||||
IEEE 802.15.4
|
||||
=============
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Receive Handle Done
|
||||
-------------------
|
||||
|
||||
.. note::
|
||||
|
||||
It is required since IDF v5.1.3 release.
|
||||
|
||||
User must call the function :cpp:func:`esp_ieee802154_receive_handle_done` to notify 802.15.4 driver after the received frame is handled. Otherwise the frame buffer will not be freed for future use.
|
@ -7,6 +7,7 @@ Migration from 5.0 to 5.1
|
||||
:maxdepth: 1
|
||||
|
||||
gcc
|
||||
:SOC_IEEE802154_SUPPORTED: ieee802154
|
||||
peripherals
|
||||
storage
|
||||
networking
|
||||
|
13
docs/zh_CN/migration-guides/release-5.x/5.1/ieee802154.rst
Normal file
13
docs/zh_CN/migration-guides/release-5.x/5.1/ieee802154.rst
Normal file
@ -0,0 +1,13 @@
|
||||
IEEE 802.15.4
|
||||
=============
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
Receive Handle Done
|
||||
-------------------
|
||||
|
||||
.. note::
|
||||
|
||||
这个功能仅包括在 IDF v5.1.3 以及之后的发布中。
|
||||
|
||||
当收到的数据帧被处理后, 用户需要调用函数 :cpp:func:`esp_ieee802154_receive_handle_done` 通知 802.15.4 驱动层,否则这个数据空间将不会被释放。
|
@ -7,6 +7,7 @@
|
||||
:maxdepth: 1
|
||||
|
||||
gcc
|
||||
:SOC_IEEE802154_SUPPORTED: ieee802154
|
||||
peripherals
|
||||
storage
|
||||
networking
|
||||
|
@ -33,10 +33,3 @@ CONFIG_LWIP_IPV6_NUM_ADDRESSES=8
|
||||
CONFIG_LWIP_MULTICAST_PING=y
|
||||
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM=y
|
||||
# end of lwIP
|
||||
|
||||
#
|
||||
# IEEE 802.15.4
|
||||
#
|
||||
CONFIG_IEEE802154_ENABLED=y
|
||||
CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y
|
||||
# end of IEEE 802.15.4
|
||||
|
@ -30,12 +30,6 @@ CONFIG_LOG_BOOTLOADER_LEVEL_ERROR=y
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=n
|
||||
# End of deprecated options
|
||||
|
||||
#
|
||||
# IEEE 802.15.4
|
||||
#
|
||||
CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y
|
||||
# end of IEEE 802.15.4
|
||||
|
||||
#
|
||||
# Configurations for optimizing the size of ot_rcp firmware
|
||||
#
|
||||
|
@ -54,7 +54,7 @@ I (660) ESP_ZB_GATEWAY: status: -1
|
||||
I (670) ESP_ZB_GATEWAY: Zigbee stack initialized
|
||||
I (680) ESP_ZB_GATEWAY: Zigbee rcp device booted
|
||||
I (1280) ESP_ZB_GATEWAY: Start network formation
|
||||
I (3060) ESP_ZB_GATEWAY: Formed network successfully (ieee extended address: f9:54:2d:01:a0:03:f7:84, PAN ID: 0x8651)
|
||||
I (3060) ESP_ZB_GATEWAY: Formed network successfully (Extended PAN ID: f9:54:2d:01:a0:03:f7:84, PAN ID: 0x8651, Channel:13, Short Address: 0x0000)
|
||||
I (4060) ESP_ZB_GATEWAY: status: 0
|
||||
I (4400) ESP_ZB_GATEWAY: Network steering started
|
||||
```
|
||||
|
@ -1,38 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee Gateway Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
@ -42,7 +19,6 @@
|
||||
#include "esp_coexist.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_spiffs.h"
|
||||
#include "esp_vfs_eventfd.h"
|
||||
#include "esp_vfs_dev.h"
|
||||
#include "esp_vfs_usb_serial_jtag.h"
|
||||
@ -51,6 +27,10 @@
|
||||
#include "protocol_examples_common.h"
|
||||
#include "esp_zigbee_gateway.h"
|
||||
|
||||
#include "esp_vfs_dev.h"
|
||||
#include "esp_vfs_usb_serial_jtag.h"
|
||||
#include "driver/usb_serial_jtag.h"
|
||||
|
||||
#if (!defined ZB_MACSPLIT_HOST && defined ZB_MACSPLIT_DEVICE)
|
||||
#error Only Zigbee gateway host device should be defined
|
||||
#endif
|
||||
@ -108,8 +88,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
|
||||
case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
|
||||
if (err_status == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Start network formation");
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION);
|
||||
ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non");
|
||||
if (esp_zb_bdb_is_factory_new()) {
|
||||
ESP_LOGI(TAG, "Start network formation");
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Device rebooted");
|
||||
}
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status));
|
||||
}
|
||||
@ -118,10 +103,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
if (err_status == ESP_OK) {
|
||||
esp_zb_ieee_addr_t ieee_address;
|
||||
esp_zb_get_long_address(ieee_address);
|
||||
ESP_LOGI(TAG, "Formed network successfully (ieee_address: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d)",
|
||||
ESP_LOGI(TAG, "Formed network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 0x%04hx)",
|
||||
ieee_address[7], ieee_address[6], ieee_address[5], ieee_address[4],
|
||||
ieee_address[3], ieee_address[2], ieee_address[1], ieee_address[0],
|
||||
esp_zb_get_pan_id(), esp_zb_get_current_channel());
|
||||
esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address());
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Restart network formation (status: %s)", esp_err_to_name(err_status));
|
||||
@ -137,6 +122,15 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
dev_annce_params = (esp_zb_zdo_signal_device_annce_params_t *)esp_zb_app_signal_get_params(p_sg_p);
|
||||
ESP_LOGI(TAG, "New device commissioned or rejoined (short: 0x%04hx)", dev_annce_params->device_short_addr);
|
||||
break;
|
||||
case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS:
|
||||
if (err_status == ESP_OK) {
|
||||
if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) {
|
||||
ESP_LOGI(TAG, "Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p));
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGI(TAG, "ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type,
|
||||
esp_err_to_name(err_status));
|
||||
@ -146,10 +140,9 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
|
||||
static void esp_zb_task(void *pvParameters)
|
||||
{
|
||||
/* initialize Zigbee stack with Zigbee coordinator config */
|
||||
/* initialize Zigbee stack */
|
||||
esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZC_CONFIG();
|
||||
esp_zb_init(&zb_nwk_cfg);
|
||||
/* initiate Zigbee Stack start without zb_send_no_autostart_signal auto-start */
|
||||
esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
|
||||
ESP_ERROR_CHECK(esp_zb_start(false));
|
||||
esp_zb_main_loop_iteration();
|
||||
@ -161,7 +154,7 @@ void app_main(void)
|
||||
.radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
|
||||
};
|
||||
/* load Zigbee gateway platform config to initialization */
|
||||
|
||||
ESP_ERROR_CHECK(esp_zb_platform_config(&config));
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
@ -1,38 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee Gateway Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "esp_err.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp-zboss-lib: "~0.7.0"
|
||||
espressif/esp-zigbee-lib: "~0.9.0"
|
||||
espressif/esp-zboss-lib: "1.0.9"
|
||||
espressif/esp-zigbee-lib: "1.0.9"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=5.0.0"
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 1150K,
|
||||
zb_storage, data, fat, , 16K,
|
||||
zb_fct, data, fat, , 1K,
|
||||
factory, app, factory, 0x10000, 1400K,
|
||||
zb_storage, data, fat, 0x16e000,16K,
|
||||
zb_fct, data, fat, 0x172000,1K,
|
||||
rcp_fw, data, spiffs, 0x173000,500k,
|
||||
|
|
@ -22,8 +22,7 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
CONFIG_MBEDTLS_ECJPAKE_C=y
|
||||
# end of mbedTLS
|
||||
|
||||
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
|
||||
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n
|
||||
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=4096
|
||||
|
||||
#
|
||||
# Zboss
|
||||
|
@ -1,38 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee RCP Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
@ -1,38 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee RCP Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include "esp_zigbee_core.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp-zboss-lib: "~0.7.0"
|
||||
espressif/esp-zigbee-lib: "~0.9.0"
|
||||
espressif/esp-zboss-lib: "1.0.9"
|
||||
espressif/esp-zigbee-lib: "1.0.9"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=5.0.0"
|
||||
|
@ -2,5 +2,5 @@
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 550K,
|
||||
factory, app, factory, 0x10000, 548K,
|
||||
zb_storage, data, fat, 0x9a000, 16K,
|
||||
|
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Partition Table
|
||||
#
|
||||
CONFIG_PARTITION_TABLE_SINGLE_APP=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
|
@ -11,7 +11,7 @@ The ESP Zigbee SDK provides more examples and tools for productization:
|
||||
|
||||
## Hardware Required
|
||||
|
||||
* One development board with ESP32-H2 SoC acting as Zigbee end device (loaded with HA_on_off_light example)
|
||||
* One development board with ESP32-H2 SoC acting as Zigbee end-device (loaded with HA_on_off_light example)
|
||||
* A USB cable for power supply and programming
|
||||
* Choose another ESP32-H2 as Zigbee coordinator (see [HA_on_off_switch example](../HA_on_off_switch))
|
||||
|
||||
@ -33,18 +33,25 @@ Build the project, flash it to the board, and start the monitor tool to view the
|
||||
|
||||
As you run the example, you will see the following log:
|
||||
|
||||
light bulb:
|
||||
```
|
||||
I (918) ESP_ZB_LIGHT: status: 255
|
||||
I (901) ESP_ZB_LIGHT: Zigbee stack initialized
|
||||
I (901) ESP_ZB_LIGHT: Start network steering
|
||||
I (2611) ESP_ZB_LIGHT: Joined network successfully (Extended PAN ID: aa:98:48:01:a0:03:f7:84, PAN ID: 0x0e8b)
|
||||
I (5651) ESP_ZB_LIGHT: on/off light set to 1
|
||||
I (6631) ESP_ZB_LIGHT: on/off light set to 0
|
||||
I (7331) ESP_ZB_LIGHT: on/off light set to 1
|
||||
I (8251) ESP_ZB_LIGHT: on/off light set to 0
|
||||
I (9111) ESP_ZB_LIGHT: on/off light set to 1
|
||||
I (9671) ESP_ZB_LIGHT: on/off light set to 0
|
||||
I (394) main_task: Calling app_main()
|
||||
I (404) gpio: GPIO[8]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
|
||||
I (404) phy_init: phy_version 220,2dbbbe7,Sep 25 2023,20:39:25
|
||||
I (464) phy: libbtbb version: 90c587c, Sep 25 2023, 20:39:57
|
||||
I (474) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL
|
||||
I (474) ESP_ZB_COLOR_DIMM_LIGHT: Zigbee stack initialized
|
||||
I (484) ESP_ZB_COLOR_DIMM_LIGHT: Start network steering
|
||||
I (484) main_task: Returned from app_main()
|
||||
I (9614) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
|
||||
I (9834) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
|
||||
I (9834) ESP_ZB_COLOR_DIMM_LIGHT: Joined network successfully (Extended PAN ID: 60:55:f9:00:00:f6:07:b4, PAN ID: 0x2a74, Channel:13)
|
||||
I (32944) ESP_ZB_COLOR_DIMM_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
|
||||
I (32944) ESP_ZB_COLOR_DIMM_LIGHT: Light sets to On
|
||||
I (33984) ESP_ZB_COLOR_DIMM_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
|
||||
I (33984) ESP_ZB_COLOR_DIMM_LIGHT: Light sets to Off
|
||||
I (35304) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NLME Status Indication (0x32), status: ESP_OK
|
||||
I (35534) ESP_ZB_COLOR_DIMM_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
|
||||
I (35534) ESP_ZB_COLOR_DIMM_LIGHT: Light sets to On
|
||||
```
|
||||
|
||||
## Light Control Functions
|
||||
|
@ -1,38 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee HA_on_off_light Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@ -67,8 +44,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
|
||||
case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
|
||||
if (err_status == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Start network steering");
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
|
||||
ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non");
|
||||
if (esp_zb_bdb_is_factory_new()) {
|
||||
ESP_LOGI(TAG, "Start network steering");
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Device rebooted");
|
||||
}
|
||||
} else {
|
||||
/* commissioning failed */
|
||||
ESP_LOGW(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status));
|
||||
@ -78,10 +60,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
if (err_status == ESP_OK) {
|
||||
esp_zb_ieee_addr_t extended_pan_id;
|
||||
esp_zb_get_extended_pan_id(extended_pan_id);
|
||||
ESP_LOGI(TAG, "Joined network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d)",
|
||||
ESP_LOGI(TAG, "Joined network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 0x%04hx)",
|
||||
extended_pan_id[7], extended_pan_id[6], extended_pan_id[5], extended_pan_id[4],
|
||||
extended_pan_id[3], extended_pan_id[2], extended_pan_id[1], extended_pan_id[0],
|
||||
esp_zb_get_pan_id(), esp_zb_get_current_channel());
|
||||
esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address());
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Network steering was not successful (status: %s)", esp_err_to_name(err_status));
|
||||
esp_zb_scheduler_alarm((esp_zb_callback_t)bdb_start_top_level_commissioning_cb, ESP_ZB_BDB_MODE_NETWORK_STEERING, 1000);
|
||||
@ -100,14 +82,13 @@ static esp_err_t zb_attribute_handler(const esp_zb_zcl_set_attr_value_message_t
|
||||
bool light_state = 0;
|
||||
|
||||
ESP_RETURN_ON_FALSE(message, ESP_FAIL, TAG, "Empty message");
|
||||
ESP_RETURN_ON_FALSE(message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS, ESP_ERR_INVALID_ARG, TAG,
|
||||
"Received message: error status(%d)", message->info.status);
|
||||
ESP_LOGI(TAG, "Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)",
|
||||
message->info.dst_endpoint, message->info.cluster, message->attribute.id, message->attribute.data.size);
|
||||
ESP_RETURN_ON_FALSE(message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS, ESP_ERR_INVALID_ARG, TAG, "Received message: error status(%d)",
|
||||
message->info.status);
|
||||
ESP_LOGI(TAG, "Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)", message->info.dst_endpoint, message->info.cluster,
|
||||
message->attribute.id, message->attribute.data.size);
|
||||
if (message->info.dst_endpoint == HA_ESP_LIGHT_ENDPOINT) {
|
||||
if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_ON_OFF) {
|
||||
if (message->attribute.id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID &&
|
||||
message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_BOOL) {
|
||||
if (message->attribute.id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_BOOL) {
|
||||
light_state = message->attribute.data.value ? *(bool *)message->attribute.data.value : light_state;
|
||||
ESP_LOGI(TAG, "Light sets to %s", light_state ? "On" : "Off");
|
||||
light_driver_set_power(light_state);
|
||||
|
@ -1,49 +1,27 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee HA_on_off_light Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "esp_zigbee_core.h"
|
||||
#include "light_driver.h"
|
||||
|
||||
/* Zigbee configuration */
|
||||
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
|
||||
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
|
||||
#define ED_AGING_TIMEOUT ESP_ZB_ED_AGING_TIMEOUT_64MIN
|
||||
#define ED_KEEP_ALIVE 3000 /* 3000 millisecond */
|
||||
#define HA_ESP_LIGHT_ENDPOINT 10 /* esp light bulb device endpoint, used to process light controlling commands */
|
||||
#define HA_ESP_LIGHT_ENDPOINT 10 /* esp light bulb device endpoint, used to process light controlling commands */
|
||||
#define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */
|
||||
|
||||
#define ESP_ZB_ZED_CONFIG() \
|
||||
{ \
|
||||
.esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \
|
||||
|
@ -1,7 +1,7 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp-zigbee-lib: "~0.9.0"
|
||||
espressif/esp-zboss-lib: "~0.7.0"
|
||||
espressif/esp-zboss-lib: "1.0.9"
|
||||
espressif/esp-zigbee-lib: "1.0.9"
|
||||
espressif/led_strip: "~2.0.0"
|
||||
## Required IDF version
|
||||
idf:
|
||||
|
@ -2,6 +2,6 @@
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 650K,
|
||||
zb_storage, data, fat, 0xb3000, 16K,
|
||||
zb_fct, data, fat, 0xb7000, 1K,
|
||||
factory, app, factory, 0x10000, 900K,
|
||||
zb_storage, data, fat, 0xf1000, 16K,
|
||||
zb_fct, data, fat, 0xf5000, 1K,
|
||||
|
|
@ -22,8 +22,6 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
CONFIG_MBEDTLS_ECJPAKE_C=y
|
||||
# end of mbedTLS
|
||||
|
||||
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
|
||||
|
||||
#
|
||||
# Zboss
|
||||
#
|
||||
|
@ -33,30 +33,32 @@ Build the project, flash it to the board, and start the monitor tool to view the
|
||||
|
||||
As you run the example, you will see the following log:
|
||||
|
||||
light switch:
|
||||
```
|
||||
I (318) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
|
||||
I (328) system_api: Base MAC address is not set
|
||||
I (328) system_api: read default base MAC address from EFUSE
|
||||
I (408) phy: libbtbb version: 6c47ec3, Mar 16 2022, 18:54:24
|
||||
I (408) phy: phy_version: 101, bb2a234, Mar 16 2022, 18:54:11
|
||||
I (818) ESP_ZB_ON_OFF_SWITCH: status: 255
|
||||
I (818) ESP_ZB_ON_OFF_SWITCH: Zigbee stack initialized
|
||||
I (818) ESP_ZB_ON_OFF_SWITCH: Start network formation
|
||||
I (1318) ESP_ZB_ON_OFF_SWITCH: Formed network successfully (Extended PAN ID: ff:fc:7c:c0:f0:bd:97:10, PAN ID: 0x88e7)
|
||||
I (1778) ESP_ZB_ON_OFF_SWITCH: status: 0
|
||||
I (5528) ESP_ZB_ON_OFF_SWITCH: status: 0
|
||||
I (6038) ESP_ZB_ON_OFF_SWITCH: status: 0
|
||||
I (6068) ESP_ZB_ON_OFF_SWITCH: New device commissioned or rejoined (short: 0x2878)
|
||||
I (6098) ESP_ZB_ON_OFF_SWITCH: User find cb: address:0x2878, endpoint:10
|
||||
I (6638) ESP_ZB_ON_OFF_SWITCH: status: 0
|
||||
I (6678) ESP_ZB_ON_OFF_SWITCH: status: 0
|
||||
I (8168) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
|
||||
I (8898) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
|
||||
I (9458) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
|
||||
I (10088) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
|
||||
I (10588) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
|
||||
I (11098) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
|
||||
I (388) main_task: Calling app_main()
|
||||
I (398) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
|
||||
I (398) phy_init: phy_version 220,2dbbbe7,Sep 25 2023,20:39:25
|
||||
I (478) phy: libbtbb version: 90c587c, Sep 25 2023, 20:39:57
|
||||
I (488) ESP_ZB_ON_OFF_SWITCH: ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL
|
||||
I (488) ESP_ZB_ON_OFF_SWITCH: Zigbee stack initialized
|
||||
I (488) ESP_ZB_ON_OFF_SWITCH: Start network formation
|
||||
I (498) main_task: Returned from app_main()
|
||||
I (998) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
|
||||
I (998) ESP_ZB_ON_OFF_SWITCH: Formed network successfully (Extended PAN ID: 60:55:f9:00:00:f6:07:b4, PAN ID: 0x2a74, Channel:13)
|
||||
I (1468) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
|
||||
I (1468) ESP_ZB_ON_OFF_SWITCH: Network steering started
|
||||
I (14228) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Device Associated (0x12), status: ESP_OK
|
||||
I (14728) ESP_ZB_ON_OFF_SWITCH: ZDO signal: ZDO Device Update (0x30), status: ESP_OK
|
||||
I (14788) ESP_ZB_ON_OFF_SWITCH: New device commissioned or rejoined (short: 0xe399)
|
||||
I (14858) ESP_ZB_ON_OFF_SWITCH: Found light
|
||||
I (14858) ESP_ZB_ON_OFF_SWITCH: Try to bind On/Off
|
||||
I (14858) ESP_ZB_ON_OFF_SWITCH: Bound successfully!
|
||||
I (14858) ESP_ZB_ON_OFF_SWITCH: The light originating from address(0xe399) on endpoint(10)
|
||||
I (15338) ESP_ZB_ON_OFF_SWITCH: ZDO signal: ZDO Device Authorized (0x2f), status: ESP_OK
|
||||
I (15408) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Permit Join (0x36), status: ESP_OK
|
||||
I (35838) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NLME Status Indication (0x32), status: ESP_OK
|
||||
I (38548) ESP_ZB_ON_OFF_SWITCH: Send 'on_off toggle' command
|
||||
I (39598) ESP_ZB_ON_OFF_SWITCH: Send 'on_off toggle' command
|
||||
I (41148) ESP_ZB_ON_OFF_SWITCH: Send 'on_off toggle' command
|
||||
```
|
||||
|
||||
## Light Control Functions
|
||||
|
@ -1,38 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee HA_on_off_switch Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "string.h"
|
||||
@ -82,8 +59,7 @@ static void bind_cb(esp_zb_zdp_status_t zdo_status, void *user_ctx)
|
||||
ESP_LOGI(TAG, "Bound successfully!");
|
||||
if (user_ctx) {
|
||||
light_bulb_device_params_t *light = (light_bulb_device_params_t *)user_ctx;
|
||||
ESP_LOGI(TAG, "The light originating from address(0x%x) on endpoint(%d)", light->short_addr,
|
||||
light->endpoint);
|
||||
ESP_LOGI(TAG, "The light originating from address(0x%x) on endpoint(%d)", light->short_addr, light->endpoint);
|
||||
free(light);
|
||||
}
|
||||
}
|
||||
@ -124,8 +100,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
|
||||
case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
|
||||
if (err_status == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Start network formation");
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION);
|
||||
ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non");
|
||||
if (esp_zb_bdb_is_factory_new()) {
|
||||
ESP_LOGI(TAG, "Start network formation");
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Device rebooted");
|
||||
}
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status));
|
||||
}
|
||||
@ -134,10 +115,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
if (err_status == ESP_OK) {
|
||||
esp_zb_ieee_addr_t extended_pan_id;
|
||||
esp_zb_get_extended_pan_id(extended_pan_id);
|
||||
ESP_LOGI(TAG, "Formed network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d)",
|
||||
ESP_LOGI(TAG, "Formed network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 0x%04hx)",
|
||||
extended_pan_id[7], extended_pan_id[6], extended_pan_id[5], extended_pan_id[4],
|
||||
extended_pan_id[3], extended_pan_id[2], extended_pan_id[1], extended_pan_id[0],
|
||||
esp_zb_get_pan_id(), esp_zb_get_current_channel());
|
||||
esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address());
|
||||
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Restart network formation (status: %s)", esp_err_to_name(err_status));
|
||||
@ -157,6 +138,15 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
|
||||
cmd_req.addr_of_interest = dev_annce_params->device_short_addr;
|
||||
esp_zb_zdo_find_on_off_light(&cmd_req, user_find_cb, NULL);
|
||||
break;
|
||||
case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS:
|
||||
if (err_status == ESP_OK) {
|
||||
if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) {
|
||||
ESP_LOGI(TAG, "Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p));
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGI(TAG, "ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type,
|
||||
esp_err_to_name(err_status));
|
||||
|
@ -1,47 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Included
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* Zigbee HA_on_off_switch Example
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, this
|
||||
* software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include "esp_zigbee_core.h"
|
||||
#include "switch_driver.h"
|
||||
|
||||
/* Zigbee configuration */
|
||||
#define MAX_CHILDREN 10 /* the max amount of connected devices */
|
||||
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
|
||||
#define HA_ONOFF_SWITCH_ENDPOINT 1 /* esp light switch device endpoint */
|
||||
#define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */
|
||||
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
|
||||
#define HA_ONOFF_SWITCH_ENDPOINT 1 /* esp light switch device endpoint */
|
||||
#define ESP_ZB_PRIMARY_CHANNEL_MASK (1l << 13) /* Zigbee primary channel mask use in the example */
|
||||
|
||||
#define ESP_ZB_ZC_CONFIG() \
|
||||
{ \
|
||||
|
@ -1,7 +1,7 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp-zigbee-lib: "~0.9.0"
|
||||
espressif/esp-zboss-lib: "~0.7.0"
|
||||
espressif/esp-zboss-lib: "1.0.9"
|
||||
espressif/esp-zigbee-lib: "1.0.9"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=5.0.0"
|
||||
|
@ -2,6 +2,6 @@
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 650K,
|
||||
zb_storage, data, fat, 0xb3000, 16K,
|
||||
zb_fct, data, fat, 0xb7000, 1K,
|
||||
factory, app, factory, 0x10000, 900K,
|
||||
zb_storage, data, fat, 0xf1000, 16K,
|
||||
zb_fct, data, fat, 0xf5000, 1K,
|
||||
|
|
@ -22,8 +22,6 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
CONFIG_MBEDTLS_ECJPAKE_C=y
|
||||
# end of mbedTLS
|
||||
|
||||
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
|
||||
|
||||
#
|
||||
# Zboss
|
||||
#
|
||||
|
@ -18,7 +18,6 @@ skip:
|
||||
- "components/esp_phy/lib"
|
||||
- "components/esp_wifi/lib"
|
||||
- "components/esp_wifi/lib_esp32"
|
||||
- "components/ieee802154/lib"
|
||||
- "components/json/cJSON"
|
||||
- "components/lwip/lwip"
|
||||
- "components/mbedtls/mbedtls"
|
||||
|
Reference in New Issue
Block a user