diff --git a/modules/openthread/CMakeLists.txt b/modules/openthread/CMakeLists.txt index 02af3687cf5..e6d4af11560 100644 --- a/modules/openthread/CMakeLists.txt +++ b/modules/openthread/CMakeLists.txt @@ -11,6 +11,10 @@ macro(kconfig_to_ot_option kconfig_option ot_config description) endif() endmacro() +macro(kconfig_to_ot_option_value kconfig_option ot_config description) + set(${ot_config} ${${kconfig_option}} CACHE STRING "${description}" FORCE) +endmacro() + # OpenThread options set(OT_BUILD_EXECUTABLES OFF CACHE BOOL "Disable OpenThread samples") set(OT_BUILTIN_MBEDTLS_MANAGEMENT OFF CACHE BOOL "Use Zephyr's mbedTLS heap") @@ -130,6 +134,7 @@ kconfig_to_ot_option(CONFIG_OPENTHREAD_UPTIME OT_UPTIME "Enable support for trac kconfig_to_ot_option(CONFIG_OPENTHREAD_VERHOEFF_CHECKSUM OT_VERHOEFF_CHECKSUM "Verhoeff checksum") kconfig_to_ot_option(CONFIG_OPENTHREAD_WAKEUP_COORDINATOR OT_WAKEUP_COORDINATOR "Enable Wake-up Coordinator role") kconfig_to_ot_option(CONFIG_OPENTHREAD_WAKEUP_END_DEVICE OT_WAKEUP_END_DEVICE "Enable Wake-up End Device role") +kconfig_to_ot_option_value(CONFIG_OPENTHREAD_RCP_RESTORATION_MAX_COUNT OT_RCP_RESTORATION_MAX_COUNT "Set the maximum number of RCP restoration attempts") if(CONFIG_OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE) set(OT_NCP_VENDOR_HOOK_SOURCE ${CONFIG_OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE} CACHE STRING "NCP vendor hook source file name" FORCE) diff --git a/modules/openthread/Kconfig.thread b/modules/openthread/Kconfig.thread index 2bababd4fee..0633d8bc62d 100644 --- a/modules/openthread/Kconfig.thread +++ b/modules/openthread/Kconfig.thread @@ -250,3 +250,18 @@ config OPENTHREAD_MLE_CHILD_TIMEOUT default 240 help The value of MLE child timeout in seconds. + +config OPENTHREAD_RCP_RESTORATION_MAX_COUNT + int "Openthread RCP restoration maximum count" + default 2 + help + The maximum number of attempts to restore the RCP connection. + +config OPENTHREAD_ROUTER_SELECTION_JITTER_OVERRIDE + bool "Override default router selection jitter" + depends on OPENTHREAD_FTD + +config OPENTHREAD_ROUTER_SELECTION_JITTER + int "OpenThread router selection jitter in seconds" + depends on OPENTHREAD_ROUTER_SELECTION_JITTER_OVERRIDE + default 120 diff --git a/modules/openthread/openthread.c b/modules/openthread/openthread.c index 5bd7f27e8c8..e4124cda7f9 100644 --- a/modules/openthread/openthread.c +++ b/modules/openthread/openthread.c @@ -33,6 +33,7 @@ LOG_MODULE_REGISTER(net_openthread_platform, CONFIG_OPENTHREAD_PLATFORM_LOG_LEVE #include #include #include +#include #include #include #include @@ -98,6 +99,12 @@ LOG_MODULE_REGISTER(net_openthread_platform, CONFIG_OPENTHREAD_PLATFORM_LOG_LEVE #define OT_POLL_PERIOD 0 #endif +#if defined(CONFIG_OPENTHREAD_ROUTER_SELECTION_JITTER) +#define OT_ROUTER_SELECTION_JITTER CONFIG_OPENTHREAD_ROUTER_SELECTION_JITTER +#else +#define OT_ROUTER_SELECTION_JITTER 0 +#endif + #define ZEPHYR_PACKAGE_NAME "Zephyr" #define PACKAGE_VERSION KERNEL_VERSION_STRING @@ -340,6 +347,10 @@ int openthread_init(void) } } + if (IS_ENABLED(CONFIG_OPENTHREAD_ROUTER_SELECTION_JITTER_OVERRIDE)) { + otThreadSetRouterSelectionJitter(openthread_instance, OT_ROUTER_SELECTION_JITTER); + } + openthread_mutex_unlock(); /* Start work queue for the OpenThread module */