mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(ieee802154): make the receive done handler feature mandatory
This commit is contained in:
parent
86cf144aa7
commit
aab24b0dd7
@ -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);
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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--;
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user