From f81ce9c44ee1604101da9c3e3c99d365cacd03f4 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Wed, 29 Jul 2026 17:23:37 +0800 Subject: [PATCH] feat(openthread): use the actual receive sensitivity for link quality evaluation --- .../esp32c5/include/hal/ieee802154_ll.h | 1 + .../esp32c6/include/hal/ieee802154_ll.h | 1 + .../esp32h2/include/hal/ieee802154_ll.h | 5 +++-- .../esp32h21/include/hal/ieee802154_ll.h | 1 + .../esp32h4/include/hal/ieee802154_ll.h | 1 + .../esp32s31/include/hal/ieee802154_ll.h | 1 + components/ieee802154/driver/esp_ieee802154_ack.c | 1 - components/ieee802154/driver/esp_ieee802154_debug.c | 1 - components/ieee802154/driver/esp_ieee802154_dev.c | 1 - components/ieee802154/driver/esp_ieee802154_pib.c | 1 - components/ieee802154/driver/esp_ieee802154_sec.c | 1 - components/ieee802154/driver/esp_ieee802154_timer.c | 1 - components/ieee802154/driver/esp_ieee802154_util.c | 1 - components/ieee802154/esp_ieee802154.c | 6 +++++- components/ieee802154/include/esp_ieee802154.h | 8 ++++++++ components/openthread/src/port/esp_openthread_radio.c | 4 +--- 16 files changed, 22 insertions(+), 13 deletions(-) diff --git a/components/esp_hal_ieee802154/esp32c5/include/hal/ieee802154_ll.h b/components/esp_hal_ieee802154/esp32c5/include/hal/ieee802154_ll.h index 4f94a5224b2..840b7de86b9 100644 --- a/components/esp_hal_ieee802154/esp32c5/include/hal/ieee802154_ll.h +++ b/components/esp_hal_ieee802154/esp32c5/include/hal/ieee802154_ll.h @@ -9,3 +9,4 @@ #include "hal/ieee802154_common_ll.h" #define IEEE802154_RSSI_COMPENSATION_VALUE 0 +#define IEEE802154_RX_SENSITIVITY -104 diff --git a/components/esp_hal_ieee802154/esp32c6/include/hal/ieee802154_ll.h b/components/esp_hal_ieee802154/esp32c6/include/hal/ieee802154_ll.h index 4f94a5224b2..840b7de86b9 100644 --- a/components/esp_hal_ieee802154/esp32c6/include/hal/ieee802154_ll.h +++ b/components/esp_hal_ieee802154/esp32c6/include/hal/ieee802154_ll.h @@ -9,3 +9,4 @@ #include "hal/ieee802154_common_ll.h" #define IEEE802154_RSSI_COMPENSATION_VALUE 0 +#define IEEE802154_RX_SENSITIVITY -104 diff --git a/components/esp_hal_ieee802154/esp32h2/include/hal/ieee802154_ll.h b/components/esp_hal_ieee802154/esp32h2/include/hal/ieee802154_ll.h index 6fc4a17ef6d..0d77c446e4f 100644 --- a/components/esp_hal_ieee802154/esp32h2/include/hal/ieee802154_ll.h +++ b/components/esp_hal_ieee802154/esp32h2/include/hal/ieee802154_ll.h @@ -12,9 +12,10 @@ extern "C" { #endif -extern uint32_t bt_bb_get_rssi_comp(void); - #define IEEE802154_RSSI_COMPENSATION_VALUE bt_bb_get_rssi_comp() +#define IEEE802154_RX_SENSITIVITY -102 + +extern uint32_t bt_bb_get_rssi_comp(void); #ifdef __cplusplus } diff --git a/components/esp_hal_ieee802154/esp32h21/include/hal/ieee802154_ll.h b/components/esp_hal_ieee802154/esp32h21/include/hal/ieee802154_ll.h index 1f10802bffe..70f93d7adb1 100644 --- a/components/esp_hal_ieee802154/esp32h21/include/hal/ieee802154_ll.h +++ b/components/esp_hal_ieee802154/esp32h21/include/hal/ieee802154_ll.h @@ -14,6 +14,7 @@ extern "C" { #endif #define IEEE802154_RSSI_COMPENSATION_VALUE 0 +#define IEEE802154_RX_SENSITIVITY -102 static inline uint32_t ieee802154_ll_get_rx_filter_not_work_cnt(void) { diff --git a/components/esp_hal_ieee802154/esp32h4/include/hal/ieee802154_ll.h b/components/esp_hal_ieee802154/esp32h4/include/hal/ieee802154_ll.h index ad9913d4b66..8f9fd96a4a8 100644 --- a/components/esp_hal_ieee802154/esp32h4/include/hal/ieee802154_ll.h +++ b/components/esp_hal_ieee802154/esp32h4/include/hal/ieee802154_ll.h @@ -13,6 +13,7 @@ extern "C" { #endif #define IEEE802154_RSSI_COMPENSATION_VALUE 0 +#define IEEE802154_RX_SENSITIVITY -102 static inline uint32_t ieee802154_ll_get_rx_filter_not_work_cnt(void) { diff --git a/components/esp_hal_ieee802154/esp32s31/include/hal/ieee802154_ll.h b/components/esp_hal_ieee802154/esp32s31/include/hal/ieee802154_ll.h index ad9913d4b66..c26944a19cb 100644 --- a/components/esp_hal_ieee802154/esp32s31/include/hal/ieee802154_ll.h +++ b/components/esp_hal_ieee802154/esp32s31/include/hal/ieee802154_ll.h @@ -13,6 +13,7 @@ extern "C" { #endif #define IEEE802154_RSSI_COMPENSATION_VALUE 0 +#define IEEE802154_RX_SENSITIVITY -104 static inline uint32_t ieee802154_ll_get_rx_filter_not_work_cnt(void) { diff --git a/components/ieee802154/driver/esp_ieee802154_ack.c b/components/ieee802154/driver/esp_ieee802154_ack.c index ce15b445974..8e1aa2c8fe1 100644 --- a/components/ieee802154/driver/esp_ieee802154_ack.c +++ b/components/ieee802154/driver/esp_ieee802154_ack.c @@ -5,7 +5,6 @@ */ #include -#include "hal/ieee802154_ll.h" #include "esp_attr.h" #include "esp_err.h" #include "esp_ieee802154_ack.h" diff --git a/components/ieee802154/driver/esp_ieee802154_debug.c b/components/ieee802154/driver/esp_ieee802154_debug.c index 5979c0483fb..baa9dba1317 100644 --- a/components/ieee802154/driver/esp_ieee802154_debug.c +++ b/components/ieee802154/driver/esp_ieee802154_debug.c @@ -6,7 +6,6 @@ #include #include -#include "hal/ieee802154_ll.h" #include "esp_ieee802154_util.h" #include "esp_log.h" diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index b3b796804c9..12c465b4d4f 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -24,7 +24,6 @@ #include "esp_ieee802154_sec.h" #include "esp_ieee802154_util.h" #include "esp_ieee802154_timer.h" -#include "hal/ieee802154_ll.h" #include "esp_attr.h" #include "esp_phy_init.h" diff --git a/components/ieee802154/driver/esp_ieee802154_pib.c b/components/ieee802154/driver/esp_ieee802154_pib.c index b8a95369db4..e4f4d88f607 100644 --- a/components/ieee802154/driver/esp_ieee802154_pib.c +++ b/components/ieee802154/driver/esp_ieee802154_pib.c @@ -7,7 +7,6 @@ #include #include #include "sdkconfig.h" -#include "hal/ieee802154_ll.h" #include "esp_check.h" #include "esp_ieee802154_pib.h" #include "esp_ieee802154_util.h" diff --git a/components/ieee802154/driver/esp_ieee802154_sec.c b/components/ieee802154/driver/esp_ieee802154_sec.c index c628666b0a7..37a06918380 100644 --- a/components/ieee802154/driver/esp_ieee802154_sec.c +++ b/components/ieee802154/driver/esp_ieee802154_sec.c @@ -7,7 +7,6 @@ #include "sdkconfig.h" #include #include "esp_err.h" -#include "hal/ieee802154_ll.h" #include "esp_ieee802154_frame.h" #include "esp_ieee802154_sec.h" #include "esp_ieee802154_util.h" diff --git a/components/ieee802154/driver/esp_ieee802154_timer.c b/components/ieee802154/driver/esp_ieee802154_timer.c index f4c6eb2b79c..8a373f9ef04 100644 --- a/components/ieee802154/driver/esp_ieee802154_timer.c +++ b/components/ieee802154/driver/esp_ieee802154_timer.c @@ -5,7 +5,6 @@ */ #include "soc/soc.h" -#include "hal/ieee802154_ll.h" #include "esp_check.h" #include "esp_ieee802154_timer.h" #include "esp_ieee802154_util.h" diff --git a/components/ieee802154/driver/esp_ieee802154_util.c b/components/ieee802154/driver/esp_ieee802154_util.c index a37cf4b6d85..f77e693a41a 100644 --- a/components/ieee802154/driver/esp_ieee802154_util.c +++ b/components/ieee802154/driver/esp_ieee802154_util.c @@ -7,7 +7,6 @@ #include "esp_private/esp_modem_clock.h" #include "soc/soc.h" #include "soc/periph_defs.h" -#include "hal/ieee802154_ll.h" #include "esp_check.h" #include "esp_coex_i154.h" #include "esp_ieee802154_util.h" diff --git a/components/ieee802154/esp_ieee802154.c b/components/ieee802154/esp_ieee802154.c index 1947c73a524..189bb002b7c 100644 --- a/components/ieee802154/esp_ieee802154.c +++ b/components/ieee802154/esp_ieee802154.c @@ -20,7 +20,6 @@ #include "esp_ieee802154_util.h" #include "esp_log.h" #include "esp_coex_i154.h" -#include "hal/ieee802154_ll.h" #include "hal/ieee802154_common_ll.h" esp_err_t esp_ieee802154_event_callback_list_register(esp_ieee802154_event_cb_list_t cb_list) @@ -49,6 +48,11 @@ esp_err_t esp_ieee802154_disable(void) return ieee802154_mac_deinit(); } +int8_t esp_ieee802154_get_receive_sensitivity(void) +{ + return IEEE802154_RX_SENSITIVITY; +} + uint8_t esp_ieee802154_get_channel(void) { return ieee802154_pib_get_channel(); diff --git a/components/ieee802154/include/esp_ieee802154.h b/components/ieee802154/include/esp_ieee802154.h index 7e7b4d6aa39..b5c037d782d 100644 --- a/components/ieee802154/include/esp_ieee802154.h +++ b/components/ieee802154/include/esp_ieee802154.h @@ -39,6 +39,14 @@ esp_err_t esp_ieee802154_enable(void); */ esp_err_t esp_ieee802154_disable(void); +/** + * @brief Get the receive sensitivity. + * + * @return The receive sensitivity in dBm. + * + */ +int8_t esp_ieee802154_get_receive_sensitivity(void); + /** * @brief Get the operational channel. * diff --git a/components/openthread/src/port/esp_openthread_radio.c b/components/openthread/src/port/esp_openthread_radio.c index 326175ec6db..01ecca05d35 100644 --- a/components/openthread/src/port/esp_openthread_radio.c +++ b/components/openthread/src/port/esp_openthread_radio.c @@ -10,7 +10,6 @@ #include "sdkconfig.h" #include "esp_check.h" #include "esp_ieee802154.h" -#include "esp_ieee802154_types.h" #include "esp_mac.h" #include "esp_openthread_common.h" #include "esp_openthread_common_macro.h" @@ -37,7 +36,6 @@ #include "esp_coex_i154.h" #endif -#define ESP_RECEIVE_SENSITIVITY -120 #define ESP_OPENTHREAD_XTAL_ACCURACY CONFIG_OPENTHREAD_XTAL_ACCURACY #define ESP_OPENTHREAD_CSL_ACCURACY CONFIG_OPENTHREAD_CSL_ACCURACY #define ESP_OPENTHREAD_CSL_UNCERTAIN CONFIG_OPENTHREAD_CSL_UNCERTAIN @@ -461,7 +459,7 @@ otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aTh int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { - return ESP_RECEIVE_SENSITIVITY; + return esp_ieee802154_get_receive_sensitivity(); } #if CONFIG_OPENTHREAD_DIAG