From ca34d4ddda017ca4d2cd825468332cc422a31d4e Mon Sep 17 00:00:00 2001 From: Xu Si Yu Date: Thu, 16 Apr 2026 17:21:44 +0800 Subject: [PATCH] feat(openthread): optimized the autostart macro --- examples/openthread/ot_br/main/esp_ot_br.c | 11 ++++------- examples/openthread/ot_br/sdkconfig.ci.br_autostart | 2 ++ examples/openthread/ot_br/sdkconfig.defaults.esp32p4 | 1 - .../ot_examples_br/CMakeLists.txt | 2 +- .../ot_examples_br/Kconfig.projbuild | 12 ------------ 5 files changed, 7 insertions(+), 21 deletions(-) create mode 100644 examples/openthread/ot_br/sdkconfig.ci.br_autostart delete mode 100644 examples/openthread/ot_common_components/ot_examples_br/Kconfig.projbuild diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index a7efd060bc3..89449a25ecf 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -125,16 +125,13 @@ void app_main(void) #if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION esp_cli_custom_command_init(); #endif -#if CONFIG_OPENTHREAD_BORDER_ROUTER_AUTO_START +#if CONFIG_OPENTHREAD_STATE_INDICATOR_ENABLE + ESP_ERROR_CHECK(esp_openthread_state_indicator_init(esp_openthread_get_instance())); +#endif +#if CONFIG_OPENTHREAD_BORDER_ROUTER && CONFIG_OPENTHREAD_NETWORK_AUTO_START ESP_ERROR_CHECK(esp_openthread_border_router_start()); #if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_SOC_IEEE802154_SUPPORTED ESP_ERROR_CHECK(esp_coex_wifi_i154_enable()); #endif #endif -#if CONFIG_OPENTHREAD_STATE_INDICATOR_ENABLE - ESP_ERROR_CHECK(esp_openthread_state_indicator_init(esp_openthread_get_instance())); -#endif -#if CONFIG_OPENTHREAD_NETWORK_AUTO_START - ot_network_auto_start(); -#endif } diff --git a/examples/openthread/ot_br/sdkconfig.ci.br_autostart b/examples/openthread/ot_br/sdkconfig.ci.br_autostart new file mode 100644 index 00000000000..a68665a5b5f --- /dev/null +++ b/examples/openthread/ot_br/sdkconfig.ci.br_autostart @@ -0,0 +1,2 @@ +CONFIG_OPENTHREAD_NETWORK_AUTO_START=y +CONFIG_OPENTHREAD_CLI_WIFI=n diff --git a/examples/openthread/ot_br/sdkconfig.defaults.esp32p4 b/examples/openthread/ot_br/sdkconfig.defaults.esp32p4 index 8277f12de55..662064db7b1 100644 --- a/examples/openthread/ot_br/sdkconfig.defaults.esp32p4 +++ b/examples/openthread/ot_br/sdkconfig.defaults.esp32p4 @@ -1,6 +1,5 @@ # Enable BR auto start for Ethernet builds CONFIG_OPENTHREAD_NETWORK_AUTO_START=y -CONFIG_OPENTHREAD_BORDER_ROUTER_AUTO_START=y # Enable PPP support as a workaround to ensure LWIP thread-lib compatibility for Ethernet builds CONFIG_LWIP_PPP_SUPPORT=y diff --git a/examples/openthread/ot_common_components/ot_examples_br/CMakeLists.txt b/examples/openthread/ot_common_components/ot_examples_br/CMakeLists.txt index fbda672d96d..73821c5d635 100644 --- a/examples/openthread/ot_common_components/ot_examples_br/CMakeLists.txt +++ b/examples/openthread/ot_common_components/ot_examples_br/CMakeLists.txt @@ -1,6 +1,6 @@ set(srcs "") -if(CONFIG_OPENTHREAD_BORDER_ROUTER_AUTO_START) +if(CONFIG_OPENTHREAD_BORDER_ROUTER AND CONFIG_OPENTHREAD_NETWORK_AUTO_START) list(APPEND srcs "ot_examples_br.c") endif() diff --git a/examples/openthread/ot_common_components/ot_examples_br/Kconfig.projbuild b/examples/openthread/ot_common_components/ot_examples_br/Kconfig.projbuild deleted file mode 100644 index 2835110a1f5..00000000000 --- a/examples/openthread/ot_common_components/ot_examples_br/Kconfig.projbuild +++ /dev/null @@ -1,12 +0,0 @@ -menu "OpenThread Border Router Config" - depends on OPENTHREAD_BORDER_ROUTER - - config OPENTHREAD_BORDER_ROUTER_AUTO_START - depends on OPENTHREAD_BORDER_ROUTER - bool 'Enable the border router auto start' - default n - help - If enabled, the program will automatically connect to the backbone network and - initialize the border router at startup. - -endmenu