From 89b73368766fa937ce56f17cf18e63cf64d77900 Mon Sep 17 00:00:00 2001 From: Nick Ward Date: Fri, 11 Oct 2024 11:07:39 +1100 Subject: [PATCH] net: openthread: make receive sensitivity configurable OpenThread route cost calculations are dependent on this being accurate for the hardware design. Signed-off-by: Nick Ward --- modules/openthread/Kconfig.thread | 7 +++++++ modules/openthread/platform/radio.c | 4 +--- tests/subsys/openthread/radio_stub.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/openthread/Kconfig.thread b/modules/openthread/Kconfig.thread index 22f11d5c606..8578ae72729 100644 --- a/modules/openthread/Kconfig.thread +++ b/modules/openthread/Kconfig.thread @@ -175,6 +175,13 @@ config OPENTHREAD_MAC_STAY_AWAKE_BETWEEN_FRAGMENTS help This optimization is done at the expense of power consumption on SED/SSED devices. +config OPENTHREAD_DEFAULT_RX_SENSITIVITY + int "OpenThread default RX sensitivity in dBm" + range $(INT8_MIN) $(INT8_MAX) + default -100 + help + Set the default receive sensitivity [dBm] in radio driver. + config OPENTHREAD_DEFAULT_TX_POWER int "OpenThread default tx power in dBm" range -40 20 if NRF_802154_RADIO_DRIVER diff --git a/modules/openthread/platform/radio.c b/modules/openthread/platform/radio.c index 7e2943e734f..3dc6a4bcc8f 100644 --- a/modules/openthread/platform/radio.c +++ b/modules/openthread/platform/radio.c @@ -69,8 +69,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_L2_LOG_LEVEL); */ #define PHR_DURATION_US 32U -#define DEFAULT_SENSITIVITY -100 - enum pending_events { PENDING_EVENT_FRAME_TO_SEND, /* There is a tx frame to send */ PENDING_EVENT_FRAME_RECEIVED, /* Radio has received new frame */ @@ -1173,7 +1171,7 @@ int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { ARG_UNUSED(aInstance); - return DEFAULT_SENSITIVITY; + return CONFIG_OPENTHREAD_DEFAULT_RX_SENSITIVITY; } otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) diff --git a/tests/subsys/openthread/radio_stub.c b/tests/subsys/openthread/radio_stub.c index 79d61d5dbd0..eca072730cb 100644 --- a/tests/subsys/openthread/radio_stub.c +++ b/tests/subsys/openthread/radio_stub.c @@ -20,6 +20,7 @@ #define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_THREAD_PRIORITY) #define CONFIG_NET_L2_OPENTHREAD 1 #define CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE 512 +#define CONFIG_OPENTHREAD_DEFAULT_RX_SENSITIVITY -100 #define CONFIG_OPENTHREAD_DEFAULT_TX_POWER 0 /* file itself */