diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index f496141e47..d2c9255163 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -66,6 +66,7 @@ static uint8_t s_rx_frame[CONFIG_IEEE802154_RX_BUFFER_SIZE + 1][IEEE802154_RX_FR static esp_ieee802154_frame_info_t s_rx_frame_info[CONFIG_IEEE802154_RX_BUFFER_SIZE + 1]; static bool s_needs_next_operation = false; +static volatile bool s_pending_rx_stop = false; static uint8_t s_rx_index = 0; static uint8_t s_enh_ack_frame[128]; @@ -457,6 +458,13 @@ static void enable_rx(void) static IRAM_ATTR void next_operation(void) { + if (s_pending_rx_stop) { + ieee802154_ll_disable_rx_abort_events(IEEE802154_RX_ABORT_ALL); + ieee802154_ll_enable_rx_abort_events(BIT(IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT - 1) | BIT(IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK - 1)); + esp_ieee802154_receive_at_done(); + s_pending_rx_stop = false; + } + if (ieee802154_pib_get_rx_when_idle()) { enable_rx(); } else { @@ -1044,8 +1052,15 @@ esp_err_t ieee802154_receive(void) IEEE802154_NOINLINE static void ieee802154_finish_receive_at(void* ctx) { (void)ctx; - stop_current_operation(); - esp_ieee802154_receive_at_done(); + if (s_ieee802154_state == IEEE802154_STATE_RX && ieee802154_ll_is_current_rx_frame()) { + // if we successfully receive SFD, then continue receiving + ieee802154_ll_enable_rx_abort_events(IEEE802154_RX_ABORT_ALL); + s_pending_rx_stop = true; + } else { + // or else we go back to sleep + stop_current_operation(); + esp_ieee802154_receive_at_done(); + } } IEEE802154_NOINLINE static void ieee802154_start_receive_at(void* ctx) diff --git a/components/openthread/Kconfig b/components/openthread/Kconfig index c6bf703d8c..012a749bec 100644 --- a/components/openthread/Kconfig +++ b/components/openthread/Kconfig @@ -357,7 +357,7 @@ menu "OpenThread" config OPENTHREAD_CSL_UNCERTAIN int "The CSL Uncertainty in units of 10 us." - default 0 + default 50 help The fixed uncertainty of the Device for scheduling CSL Transmissions in units of 10 microseconds. diff --git a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h index e7ee13dc46..fdefb6eb5f 100644 --- a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h @@ -878,6 +878,16 @@ #define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD (OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + 320) #endif +/** + * @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER + * + * Additional time for CSL receiver to remain in rx active after SFD has been received, in units of microseconds. + * + */ +#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER +#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER 0 +#endif + /** * @def OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT * diff --git a/components/openthread/private_include/openthread-core-esp32x-mtd-config.h b/components/openthread/private_include/openthread-core-esp32x-mtd-config.h index 045faff323..25d67cc84b 100644 --- a/components/openthread/private_include/openthread-core-esp32x-mtd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-mtd-config.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -450,6 +450,16 @@ #define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD (OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + 320) #endif +/** + * @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER + * + * Additional time for CSL receiver to remain in rx active after SFD has been received, in units of microseconds. + * + */ +#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER +#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER 0 +#endif + /** * @def OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE * diff --git a/examples/openthread/ot_sleepy_device/light_sleep/sdkconfig.ci.ssed b/examples/openthread/ot_sleepy_device/light_sleep/sdkconfig.ci.ssed index 3b8fa8eee5..d9fa16e4eb 100644 --- a/examples/openthread/ot_sleepy_device/light_sleep/sdkconfig.ci.ssed +++ b/examples/openthread/ot_sleepy_device/light_sleep/sdkconfig.ci.ssed @@ -5,5 +5,5 @@ CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y CONFIG_OPENTHREAD_CSL_ENABLE=y CONFIG_OPENTHREAD_CSL_ACCURACY=50 -CONFIG_OPENTHREAD_CSL_UNCERTAIN=0 +CONFIG_OPENTHREAD_CSL_UNCERTAIN=50 CONFIG_RTC_CLK_SRC_EXT_CRYS=y