Skip to content

Commit b056ac7

Browse files
committed
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
2 parents 6aa6403 + 6bc6660 commit b056ac7

File tree

29 files changed

+87
-131
lines changed

29 files changed

+87
-131
lines changed

.gitlab/ci/rules.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
- "components/esp_phy/lib"
128128
- "components/esp_wifi/lib"
129129
- "components/esp_coex/lib"
130-
- "components/ieee802154/lib"
131130
- "components/json/cJSON"
132131
- "components/lwip/lwip"
133132
- "components/mbedtls/mbedtls"

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@
120120
path = components/openthread/lib
121121
url = ../../espressif/esp-thread-lib.git
122122

123-
[submodule "components/ieee802154/lib"]
124-
path = components/ieee802154/lib
125-
url = ../../espressif/esp-ieee802154-lib.git
126-
127123
[submodule "components/bt/controller/lib_esp32h2/esp32h2-bt-lib"]
128124
path = components/bt/controller/lib_esp32h2/esp32h2-bt-lib
129125
url = ../../espressif/esp32h2-bt-lib.git

components/ieee802154/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ menu "IEEE 802.15.4"
4141
configure the CCA mode to Carrier sense AND energy above threshold
4242
endchoice
4343

44-
config IEEE802154_RECEIVE_DONE_HANDLER
45-
bool "Enable the receive done handler feature"
46-
default n
47-
help
48-
configure the receive done handler feature, when enabled, the user must call the
49-
function `esp_ieee802154_receive_handle_done` to inform the 802.15.4 driver that
50-
the received frame has been processed, so the frame space could be freed.
51-
5244
config IEEE802154_CCA_MODE
5345
depends on IEEE802154_ENABLED
5446
int

components/ieee802154/driver/esp_ieee802154_dev.c

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ IEEE802154_STATIC volatile ieee802154_state_t s_ieee802154_state;
4747
static uint8_t *s_tx_frame = NULL;
4848
#define IEEE802154_RX_FRAME_SIZE (127 + 1 + 1) // +1: len, +1: for dma test
4949

50-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
5150
// +1: for the stub buffer when the valid buffers are full.
5251
//
5352
// |--------------------VB[0]--------------------|
@@ -62,10 +61,6 @@ static uint8_t *s_tx_frame = NULL;
6261
// STUB : Stub buffer, used when all valid buffers are under processing, the received frame will be dropped.
6362
static uint8_t s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE + 1][IEEE802154_RX_FRAME_SIZE];
6463
static esp_ieee802154_frame_info_t s_rx_frame_info[CONFIG_IEEE802154_RX_BUFFER_SIZE + 1];
65-
#else
66-
static uint8_t s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE][IEEE802154_RX_FRAME_SIZE];
67-
static esp_ieee802154_frame_info_t s_rx_frame_info[CONFIG_IEEE802154_RX_BUFFER_SIZE];
68-
#endif
6964

7065
static uint8_t s_rx_index = 0;
7166
static uint8_t s_enh_ack_frame[128];
@@ -85,7 +80,6 @@ typedef struct {
8580
static pending_tx_t s_pending_tx = { 0 };
8681
#endif
8782

88-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
8983
static void ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_info_t *frame_info)
9084
{
9185
// 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
113107
}
114108
}
115109

116-
esp_err_t ieee802154_receive_handle_done(uint8_t *data)
110+
esp_err_t ieee802154_receive_handle_done(const uint8_t *data)
117111
{
118112
uint16_t size = data - &s_rx_frame[0][0];
119113
if ((size % IEEE802154_RX_FRAME_SIZE) != 0
@@ -123,18 +117,6 @@ esp_err_t ieee802154_receive_handle_done(uint8_t *data)
123117
s_rx_frame_info[size / IEEE802154_RX_FRAME_SIZE].process = false;
124118
return ESP_OK;
125119
}
126-
#else
127-
static void ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_info_t *frame_info)
128-
{
129-
esp_ieee802154_receive_done(data, frame_info);
130-
}
131-
132-
static void ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info)
133-
{
134-
esp_ieee802154_transmit_done(frame, ack, ack_frame_info);
135-
}
136-
137-
#endif
138120

139121
static IRAM_ATTR void event_end_process(void)
140122
{
@@ -179,8 +161,8 @@ uint8_t ieee802154_get_recent_lqi(void)
179161
IEEE802154_STATIC void set_next_rx_buffer(void)
180162
{
181163
uint8_t* next_rx_buffer = NULL;
182-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
183164
uint8_t index = 0;
165+
184166
if (s_rx_index != CONFIG_IEEE802154_RX_BUFFER_SIZE && s_rx_frame_info[s_rx_index].process == false) {
185167
// If buffer is not full, and current index is empty, set it to hardware.
186168
next_rx_buffer = s_rx_frame[s_rx_index];
@@ -204,16 +186,7 @@ IEEE802154_STATIC void set_next_rx_buffer(void)
204186
s_rx_index = CONFIG_IEEE802154_RX_BUFFER_SIZE;
205187
next_rx_buffer = s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE];
206188
}
207-
#else
208-
if (s_rx_frame[s_rx_index][0] != 0) {
209-
s_rx_index++;
210-
if (s_rx_index == CONFIG_IEEE802154_RX_BUFFER_SIZE) {
211-
s_rx_index = 0;
212-
memset(s_rx_frame[s_rx_index], 0, sizeof(s_rx_frame[s_rx_index]));
213-
}
214-
}
215-
next_rx_buffer = (uint8_t *)&s_rx_frame[s_rx_index];
216-
#endif
189+
217190
ieee802154_ll_set_rx_addr(next_rx_buffer);
218191
}
219192

components/ieee802154/esp_ieee802154.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,10 @@ uint8_t esp_ieee802154_get_recent_lqi(void)
338338
return ieee802154_get_recent_lqi();
339339
}
340340

341-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
342-
esp_err_t esp_ieee802154_receive_handle_done(uint8_t *frame)
341+
esp_err_t esp_ieee802154_receive_handle_done(const uint8_t *frame)
343342
{
344343
return ieee802154_receive_handle_done(frame);
345344
}
346-
#endif
347345

348346
__attribute__((weak)) void esp_ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_info_t *frame_info)
349347
{

components/ieee802154/include/esp_ieee802154.h

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,20 @@ esp_err_t esp_ieee802154_sleep(void);
115115
/**
116116
* @brief Set the IEEE 802.15.4 Radio to receive state.
117117
*
118+
* @note Radio will continue receiving until it receives a valid frame.
119+
* Refer to `esp_ieee802154_receive_done()`.
120+
*
118121
* @return
119122
* - ESP_OK on success
120123
* - ESP_FAIL on failure due to invalid state.
121124
*
122-
* Note: Radio will continue receiving until it receives a valid frame.
123-
* Ref to esp_ieee802154_receive_done().
124-
*
125125
*/
126126
esp_err_t esp_ieee802154_receive(void);
127127

128128
/**
129129
* @brief Transmit the given frame.
130+
* The transmit result will be reported via `esp_ieee802154_transmit_done()`
131+
* or `esp_ieee802154_transmit_failed()`.
130132
*
131133
* @param[in] frame The pointer to the frame, the frame format:
132134
* |-----------------------------------------------------------------------|
@@ -138,9 +140,6 @@ esp_err_t esp_ieee802154_receive(void);
138140
* - ESP_OK on success.
139141
* - ESP_FAIL on failure due to invalid state.
140142
*
141-
* Note: The transmit result will be reported via esp_ieee802154_transmit_done()
142-
* or esp_ieee802154_transmit_failed().
143-
*
144143
*/
145144
esp_err_t esp_ieee802154_transmit(const uint8_t *frame, bool cca);
146145

@@ -453,35 +452,31 @@ bool esp_ieee802154_get_rx_when_idle(void);
453452
*/
454453
esp_err_t esp_ieee802154_energy_detect(uint32_t duration);
455454

456-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
457455
/**
458456
* @brief Notify the IEEE 802.15.4 Radio that the frame is handled done by upper layer.
459457
*
460-
* @param[in] frame The pointer to the frame which was passed from the function esp_ieee802154_receive_done.
461-
* or ack frame from esp_ieee802154_transmit_done.
458+
* @param[in] frame The pointer to the frame which was passed from the function `esp_ieee802154_receive_done()`
459+
* or ack frame from `esp_ieee802154_transmit_done()`.
462460
*
463461
* @return
464462
* - ESP_OK on success
465463
* - ESP_FAIL if frame is invalid.
466464
*
467465
*/
468-
esp_err_t esp_ieee802154_receive_handle_done(uint8_t *frame);
469-
#endif
466+
esp_err_t esp_ieee802154_receive_handle_done(const uint8_t *frame);
470467

471468
/** Below are the events generated by IEEE 802.15.4 subsystem, which are in ISR context **/
472469
/**
473470
* @brief A Frame was received.
474471
*
472+
* @note User must call the function `esp_ieee802154_receive_handle_done()` to notify 802.15.4 driver after the received frame is handled.
473+
*
475474
* @param[in] frame The point to the received frame, frame format:
476475
* |-----------------------------------------------------------------------|
477476
* | Len | MHR | MAC Payload (no FCS) |
478477
* |-----------------------------------------------------------------------|
479478
* @param[in] frame_info More information of the received frame, refer to esp_ieee802154_frame_info_t.
480479
*
481-
* Note: If configuration `IEEE802154_RECEIVE_DONE_HANDLER` is enabled, then the user must call the function
482-
* `esp_ieee802154_receive_handle_done()` to inform 802.15.4 driver that the received frame is handled.
483-
* See `esp_ieee802154_receive_handle_done()` for more informations.
484-
*
485480
*/
486481
extern void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info);
487482

@@ -494,27 +489,22 @@ extern void esp_ieee802154_receive_sfd_done(void);
494489
/**
495490
* @brief The Frame Transmission succeeded.
496491
*
492+
* @note If the ack frame is not null, user must call the function `esp_ieee802154_receive_handle_done()` to notify 802.15.4 driver
493+
* after the ack frame is handled.
494+
*
497495
* @param[in] frame The pointer to the transmitted frame.
498496
* @param[in] ack The received ACK frame, it could be NULL if the transmitted frame's AR bit is not set.
499497
* @param[in] ack_frame_info More information of the ACK frame, refer to esp_ieee802154_frame_info_t.
500498
*
501-
* Note: refer to esp_ieee802154_transmit().
502-
*
503-
* If configuration `IEEE802154_RECEIVE_DONE_HANDLER` is enabled and ack frame is not null, then after the upper layer has processed the frame,
504-
* the user must call the function `esp_ieee802154_receive_handle_done()` to inform 802.15.4 driver that the ack frame is handled.
505-
* See `esp_ieee802154_receive_handle_done()` for more informations.
506-
*
507499
*/
508500
extern void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info);
509501

510502
/**
511-
* @brief The Frame Transmission failed.
503+
* @brief The Frame Transmission failed. Refer to `esp_ieee802154_transmit()`.
512504
*
513505
* @param[in] frame The pointer to the frame.
514506
* @param[in] error The transmission failure reason, refer to esp_ieee802154_tx_error_t.
515507
*
516-
* Note: refer to esp_ieee802154_transmit().
517-
*
518508
*/
519509
extern void esp_ieee802154_transmit_failed(const uint8_t *frame, esp_ieee802154_tx_error_t error);
520510

@@ -525,32 +515,31 @@ extern void esp_ieee802154_transmit_failed(const uint8_t *frame, esp_ieee802154_
525515
extern void esp_ieee802154_transmit_sfd_done(uint8_t *frame);
526516

527517
/**
528-
* @brief The energy detection done.
518+
* @brief The energy detection done. Refer to `esp_ieee802154_energy_detect()`.
529519
*
530520
* @param[in] power The detected power level, in dBm.
531521
*
532-
* Note: refer to esp_ieee802154_energy_detect().
533-
*
534522
*/
535523
extern void esp_ieee802154_energy_detect_done(int8_t power);
536524

537525
/**
538526
* @brief Set the IEEE 802.15.4 Radio to receive state at a specific time.
539527
*
528+
* @note Radio will start receiving after the timestamp, and continue receiving until it receives a valid frame.
529+
* Refer to `esp_ieee802154_receive_done()`.
540530
*
541531
* @param[in] time A specific timestamp for starting receiving.
542532
* @return
543533
* - ESP_OK on success
544534
* - ESP_FAIL on failure due to invalid state.
545535
*
546-
* Note: Radio will start receiving after the timestamp, and continue receiving until it receives a valid frame.
547-
* Ref to esp_ieee802154_receive_done().
548-
*
549536
*/
550537
esp_err_t esp_ieee802154_receive_at(uint32_t time);
551538

552539
/**
553540
* @brief Transmit the given frame at a specific time.
541+
* The transmit result will be reported via `esp_ieee802154_transmit_done()`
542+
* or `esp_ieee802154_transmit_failed()`.
554543
*
555544
* @param[in] frame The pointer to the frame. Refer to `esp_ieee802154_transmit()`.
556545
* @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);
560549
* - ESP_OK on success.
561550
* - ESP_FAIL on failure due to invalid state.
562551
*
563-
* Note: The transmit result will be reported via esp_ieee802154_transmit_done()
564-
* or esp_ieee802154_transmit_failed().
565-
*
566552
*/
567553
esp_err_t esp_ieee802154_transmit_at(const uint8_t *frame, bool cca, uint32_t time);
568554

components/ieee802154/lib

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/ieee802154/private_include/esp_ieee802154_dev.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca);
110110
*/
111111
esp_err_t ieee802154_receive(void);
112112

113-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
114113
/**
115114
* @brief Notify the IEEE 802.15.4 Radio that the frame is handled done by upper layer.
116115
*
@@ -122,8 +121,7 @@ esp_err_t ieee802154_receive(void);
122121
* - ESP_FAIL if frame is invalid.
123122
*
124123
*/
125-
esp_err_t ieee802154_receive_handle_done(uint8_t* frame);
126-
#endif
124+
esp_err_t ieee802154_receive_handle_done(const uint8_t* frame);
127125

128126
/**
129127
* @brief Transmit the given frame at a specific time.

components/openthread/src/port/esp_openthread_radio.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
174174
otPlatRadioTxDone(aInstance, &s_transmit_frame, NULL, OT_ERROR_NONE);
175175
} else {
176176
otPlatRadioTxDone(aInstance, &s_transmit_frame, &s_ack_frame, OT_ERROR_NONE);
177-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
178-
esp_ieee802154_receive_handle_done(s_ack_frame.mPsdu - 1);
179-
#endif
177+
esp_ieee802154_receive_handle_done(s_ack_frame.mPsdu - 1);
180178
s_ack_frame.mPsdu = NULL;
181179
}
182180
}
@@ -228,9 +226,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
228226
{
229227
otPlatRadioReceiveDone(aInstance, &s_receive_frame[s_recv_queue.head], OT_ERROR_NONE);
230228
}
231-
#if CONFIG_IEEE802154_RECEIVE_DONE_HANDLER
232229
esp_ieee802154_receive_handle_done(s_receive_frame[s_recv_queue.head].mPsdu - 1);
233-
#endif
234230
s_receive_frame[s_recv_queue.head].mPsdu = NULL;
235231
s_recv_queue.head = (s_recv_queue.head + 1) % CONFIG_IEEE802154_RX_BUFFER_SIZE;
236232
s_recv_queue.used--;

docs/conf_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
'api-reference/provisioning/wifi_provisioning.rst',
7272
'migration-guides/release-5.x/5.2/wifi.rst']
7373

74+
IEEE802154_DOCS = ['migration-guides/release-5.x/5.1/ieee802154.rst',
75+
'migration-guides/release-5.x/5.2/ieee802154.rst']
76+
7477
NAN_DOCS = ['api-reference/network/esp_nan.rst']
7578

7679
WIFI_MESH_DOCS = ['api-guides/esp-wifi-mesh.rst',
@@ -194,6 +197,7 @@
194197
'SOC_BLUFI_SUPPORTED':BLUFI_DOCS,
195198
'SOC_WIFI_SUPPORTED':WIFI_DOCS,
196199
'SOC_BT_CLASSIC_SUPPORTED':CLASSIC_BT_DOCS,
200+
'SOC_IEEE802154_SUPPORTED':IEEE802154_DOCS,
197201
'SOC_SUPPORT_COEXISTENCE':COEXISTENCE_DOCS,
198202
'SOC_PSRAM_DMA_CAPABLE':MM_SYNC_DOCS,
199203
'SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE':MM_SYNC_DOCS,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
IEEE 802.15.4
2+
=============
3+
4+
:link_to_translation:`zh_CN:[中文]`
5+
6+
Receive Handle Done
7+
-------------------
8+
9+
.. note::
10+
11+
It is required since IDF v5.1.3 release.
12+
13+
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.

docs/en/migration-guides/release-5.x/5.1/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Migration from 5.0 to 5.1
77
:maxdepth: 1
88

99
gcc
10+
:SOC_IEEE802154_SUPPORTED: ieee802154
1011
peripherals
1112
storage
1213
networking
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
IEEE 802.15.4
2+
=============
3+
4+
:link_to_translation:`zh_CN:[中文]`
5+
6+
Receive Handle Done
7+
-------------------
8+
9+
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.

docs/en/migration-guides/release-5.x/5.2/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Migration from 5.1 to 5.2
88

99
bluetooth-classic
1010
gcc
11+
:SOC_IEEE802154_SUPPORTED: ieee802154
1112
peripherals
1213
protocols
1314
storage
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
IEEE 802.15.4
2+
=============
3+
4+
:link_to_translation:`en:[English]`
5+
6+
Receive Handle Done
7+
-------------------
8+
9+
.. note::
10+
11+
这个功能仅包括在 IDF v5.1.3 以及之后的发布中。
12+
13+
当收到的数据帧被处理后, 用户需要调用函数 :cpp:func:`esp_ieee802154_receive_handle_done` 通知 802.15.4 驱动层,否则这个数据空间将不会被释放。

0 commit comments

Comments
 (0)