Merge branch 'feat/154_enable_receive_done' into 'master'

feat(ieee802154): make the receive done handler feature mandatory

See merge request espressif/esp-idf!28573
This commit is contained in:
Shu Chen 2024-01-26 11:54:44 +08:00
commit b056ac760b
29 changed files with 87 additions and 131 deletions

View File

@ -127,7 +127,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
View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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);

@ -1 +0,0 @@
Subproject commit 102b03c8095de8a337c293f79dce189be63186f3

View File

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

View File

@ -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--;

View File

@ -71,6 +71,9 @@ WIFI_DOCS = ['api-guides/wifi.rst',
'api-reference/provisioning/wifi_provisioning.rst',
'migration-guides/release-5.x/5.2/wifi.rst']
IEEE802154_DOCS = ['migration-guides/release-5.x/5.1/ieee802154.rst',
'migration-guides/release-5.x/5.2/ieee802154.rst']
NAN_DOCS = ['api-reference/network/esp_nan.rst']
WIFI_MESH_DOCS = ['api-guides/esp-wifi-mesh.rst',
@ -194,6 +197,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_PSRAM_DMA_CAPABLE':MM_SYNC_DOCS,
'SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE':MM_SYNC_DOCS,

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

View File

@ -7,6 +7,7 @@ Migration from 5.0 to 5.1
:maxdepth: 1
gcc
:SOC_IEEE802154_SUPPORTED: ieee802154
peripherals
storage
networking

View File

@ -0,0 +1,9 @@
IEEE 802.15.4
=============
:link_to_translation:`zh_CN:[中文]`
Receive Handle Done
-------------------
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.

View File

@ -8,6 +8,7 @@ Migration from 5.1 to 5.2
bluetooth-classic
gcc
:SOC_IEEE802154_SUPPORTED: ieee802154
peripherals
protocols
storage

View 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 驱动层,否则这个数据空间将不会被释放。

View File

@ -7,6 +7,7 @@
:maxdepth: 1
gcc
:SOC_IEEE802154_SUPPORTED: ieee802154
peripherals
storage
networking

View File

@ -0,0 +1,9 @@
IEEE 802.15.4
=============
:link_to_translation:`en:[English]`
Receive Handle Done
-------------------
当收到的数据帧被处理后, 用户需要调用函数 :cpp:func:`esp_ieee802154_receive_handle_done` 通知 802.15.4 驱动层,否则这个数据空间将不会被释放。

View File

@ -8,6 +8,7 @@
bluetooth-classic
gcc
:SOC_IEEE802154_SUPPORTED: ieee802154
peripherals
protocols
storage

View File

@ -822,6 +822,7 @@ void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_
if (ack != NULL) {
ESP_EARLY_LOGI(TAG, "Rx ack %d bytes", ack[0]);
esp_ieee802154_frame_print(ack);
esp_ieee802154_receive_handle_done(ack);
}
}
@ -829,6 +830,7 @@ void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *fr
{
ESP_EARLY_LOGI(TAG, "Rx Done %d bytes", frame[0]);
esp_ieee802154_frame_print(frame);
esp_ieee802154_receive_handle_done(frame);
}
void esp_ieee802154_energy_detect_done(int8_t power)

View File

@ -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

View File

@ -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
#

View File

@ -25,9 +25,8 @@
#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"
#include "driver/uart_vfs.h"
#include "driver/usb_serial_jtag_vfs.h"
#if (!defined ZB_MACSPLIT_HOST && defined ZB_MACSPLIT_DEVICE)
#error Only Zigbee gateway host device should be defined
@ -44,9 +43,9 @@ esp_err_t esp_zb_gateway_console_init(void)
setvbuf(stdin, NULL, _IONBF, 0);
/* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
esp_vfs_dev_usb_serial_jtag_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
usb_serial_jtag_vfs_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
/* Move the caret to the beginning of the next line on '\n' */
esp_vfs_dev_usb_serial_jtag_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
usb_serial_jtag_vfs_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
/* Enable non-blocking mode on stdin and stdout */
fcntl(fileno(stdout), F_SETFL, O_NONBLOCK);
@ -54,8 +53,8 @@ esp_err_t esp_zb_gateway_console_init(void)
usb_serial_jtag_driver_config_t usb_serial_jtag_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT();
ret = usb_serial_jtag_driver_install(&usb_serial_jtag_config);
esp_vfs_usb_serial_jtag_use_driver();
esp_vfs_dev_uart_register();
usb_serial_jtag_vfs_use_driver();
uart_vfs_dev_register();
return ret;
}
#endif

View File

@ -31,9 +31,3 @@ CONFIG_ZB_ENABLED=y
CONFIG_ZB_ZCZR=y
# end of Zboss
# end of Component config
#
# IEEE802154
#
CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y
# end of IEEE802154

View File

@ -1,7 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp-zboss-lib: "~1.0.9"
espressif/esp-zigbee-lib: "~1.0.9"
espressif/esp-zboss-lib: "1.0.9"
espressif/esp-zigbee-lib: "1.0.9"
## Required IDF version
idf:
version: ">=5.0.0"

View File

@ -14,10 +14,4 @@ CONFIG_PARTITION_TABLE_MD5=y
CONFIG_ZB_ENABLED=y
CONFIG_ZB_RCP=y
# end of ZBOSS Source
#
# IEEE802154
#
CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y
# end of IEEE802154
# end of Component config

View File

@ -28,10 +28,4 @@ CONFIG_MBEDTLS_ECJPAKE_C=y
CONFIG_ZB_ENABLED=y
CONFIG_ZB_ZED=y
# end of Zboss
#
# IEEE802154
#
CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y
# end of IEEE802154
# end of Component config

View File

@ -27,6 +27,5 @@ CONFIG_MBEDTLS_ECJPAKE_C=y
#
CONFIG_ZB_ENABLED=y
CONFIG_ZB_ZCZR=y
CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y
# end of Zboss
# end of Component config

View File

@ -20,7 +20,6 @@ submodules:
- "/components/esp_phy/lib/"
- "/components/esp_wifi/lib/"
- "/components/heap/tlsf/"
- "/components/ieee802154/lib/"
- "/components/json/cJSON/"
- "/components/lwip/lwip/"
- "/components/mbedtls/mbedtls/"

View File

@ -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"