From b982374fa7cca7e268b520cd688885757fcc3689 Mon Sep 17 00:00:00 2001 From: Xu Si Yu Date: Tue, 14 Jan 2025 12:08:14 +0800 Subject: [PATCH] fix(openthread): use the correct macros to control code compilation --- components/ieee802154/driver/esp_ieee802154_dev.c | 2 +- .../private_include/esp_openthread_radio.h | 6 +++--- .../openthread-core-esp32x-ftd-config.h | 8 ++++---- .../openthread/src/ncp/esp_openthread_ncp.cpp | 8 ++++---- .../openthread/src/port/esp_openthread_radio.c | 6 +++--- .../src/port/esp_openthread_radio_spinel.cpp | 8 ++++---- .../openthread/src/port/esp_openthread_state.c | 13 ++++++------- examples/openthread/ot_br/sdkconfig.ci.spinel_trel | 1 + .../ot_br/sdkconfig.ci.spinel_trel_ext_coex | 2 ++ 9 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 examples/openthread/ot_br/sdkconfig.ci.spinel_trel create mode 100644 examples/openthread/ot_br/sdkconfig.ci.spinel_trel_ext_coex diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index d7a1b4f269..f0380a1af2 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -602,7 +602,7 @@ static IRAM_ATTR void isr_handle_tx_abort(ieee802154_ll_tx_abort_reason_t tx_abo NEEDS_NEXT_OPT(true); break; case IEEE802154_TX_ABORT_BY_TX_COEX_BREAK: -#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) esp_coex_ieee802154_coex_break_notify(); #endif IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX || s_ieee802154_state == IEEE802154_STATE_TX_CCA); diff --git a/components/openthread/private_include/esp_openthread_radio.h b/components/openthread/private_include/esp_openthread_radio.h index f39dcb07c6..20e4556681 100644 --- a/components/openthread/private_include/esp_openthread_radio.h +++ b/components/openthread/private_include/esp_openthread_radio.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,7 +12,7 @@ #include "esp_openthread_types.h" #include "openthread/instance.h" -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) #include "esp_coex_i154.h" #endif @@ -58,7 +58,7 @@ void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop); esp_err_t esp_openthread_radio_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop); -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) /** * @brief Set the coexist config. 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 8be3cf6b80..1386dff4a3 100644 --- a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -461,7 +461,7 @@ #define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1 #endif -#if !CONFIG_OPENTHREAD_RADIO_NATIVE +#if (CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI) /** * @def OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE * @@ -494,7 +494,7 @@ #define OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL (60 * 1000 * 1000) #endif -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if CONFIG_EXTERNAL_COEX_ENABLE /** * @def OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE * @@ -504,7 +504,7 @@ #define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1 #endif #endif -#endif // !CONFIG_OPENTHREAD_RADIO_NATIVE +#endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI #if CONFIG_OPENTHREAD_LINK_METRICS /** diff --git a/components/openthread/src/ncp/esp_openthread_ncp.cpp b/components/openthread/src/ncp/esp_openthread_ncp.cpp index 4c80ef34f8..c9ddd03e3e 100644 --- a/components/openthread/src/ncp/esp_openthread_ncp.cpp +++ b/components/openthread/src/ncp/esp_openthread_ncp.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,7 +9,7 @@ #include "esp_openthread_ncp.h" #include "ncp_base.hpp" -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) #include "esp_coex_i154.h" #endif @@ -70,7 +70,7 @@ otError NcpBase::VendorGetPropertyHandler(spinel_prop_key_t aPropKey) switch (aPropKey) { case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: { -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) esp_ieee802154_coex_config_t config = esp_ieee802154_get_coex_config(); const uint8_t *args = reinterpret_cast(&config); error = mEncoder.WriteDataWithLen(args, sizeof(esp_ieee802154_coex_config_t)); @@ -110,7 +110,7 @@ otError NcpBase::VendorSetPropertyHandler(spinel_prop_key_t aPropKey) break; } case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: { -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) const uint8_t *args = nullptr; uint16_t len = 0; mDecoder.ReadDataWithLen(args, len); diff --git a/components/openthread/src/port/esp_openthread_radio.c b/components/openthread/src/port/esp_openthread_radio.c index 7afe4172a0..09de3a2452 100644 --- a/components/openthread/src/port/esp_openthread_radio.c +++ b/components/openthread/src/port/esp_openthread_radio.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,7 +32,7 @@ #include "utils/link_metrics.h" #include "utils/mac_frame.h" -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) #include "esp_coex_i154.h" #endif @@ -815,7 +815,7 @@ uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance) return CONFIG_OPENTHREAD_SUPPORTED_CHANNEL_MASK; } -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config) { esp_ieee802154_set_coex_config(config); diff --git a/components/openthread/src/port/esp_openthread_radio_spinel.cpp b/components/openthread/src/port/esp_openthread_radio_spinel.cpp index 059e2bc02b..172aaf0698 100644 --- a/components/openthread/src/port/esp_openthread_radio_spinel.cpp +++ b/components/openthread/src/port/esp_openthread_radio_spinel.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -56,7 +56,7 @@ static const esp_openthread_radio_config_t *s_esp_openthread_radio_config = NULL static esp_openthread_compatibility_error_callback s_compatibility_error_callback = NULL; -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if CONFIG_EXTERNAL_COEX_ENABLE #define SPINEL_PROP_VENDOR_ESP_COEX_EVENT (SPINEL_PROP_VENDOR_ESP__BEGIN + 3) @@ -138,7 +138,7 @@ esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *conf s_spinel_driver.Init(s_spinel_interface.GetSpinelInterface(), true, iidList, ot::Spinel::kSpinelHeaderMaxNumIid); s_radio.SetCompatibilityErrorCallback(ot_spinel_compatibility_error_callback, esp_openthread_get_instance()); s_radio.Init(/*skip_rcp_compatibility_check=*/false, /*reset_radio=*/true, &s_spinel_driver, s_radio_caps, /*RCP_time_sync=*/true); -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if CONFIG_EXTERNAL_COEX_ENABLE ESP_RETURN_ON_ERROR(esp_openthread_radio_spinel_coex_config_init(), OT_PLAT_LOG_TAG, "Coex config init failed"); #endif #if CONFIG_OPENTHREAD_RADIO_SPINEL_SPI // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI @@ -516,7 +516,7 @@ uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance) return s_radio.GetRadioChannelMask(false); } -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if CONFIG_EXTERNAL_COEX_ENABLE void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config) { diff --git a/components/openthread/src/port/esp_openthread_state.c b/components/openthread/src/port/esp_openthread_state.c index 98806154af..7f89304060 100644 --- a/components/openthread/src/port/esp_openthread_state.c +++ b/components/openthread/src/port/esp_openthread_state.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -63,7 +63,7 @@ static void handle_ot_netdata_change(void) static void handle_ot_role_change(otInstance* instance) { -#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE) +#if ((CONFIG_ESP_COEX_SW_COEXIST_ENABLE && OPENTHREAD_RADIO_NATIVE) || CONFIG_EXTERNAL_COEX_ENABLE) otLinkModeConfig linkmode = otThreadGetLinkMode(instance); esp_ieee802154_coex_config_t config = esp_openthread_get_coex_config(); config.txrx = (linkmode.mRxOnWhenIdle) ? IEEE802154_LOW : IEEE802154_MIDDLE; @@ -83,14 +83,13 @@ static void handle_ot_role_change(otInstance* instance) otOperationalDataset dataset; ESP_GOTO_ON_FALSE(otDatasetGetActive(instance, &dataset) == OT_ERROR_NONE, ESP_FAIL, exit, TAG, "Failed to get the active dataset"); - ESP_GOTO_ON_ERROR(esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_ATTACHED, &dataset, sizeof(dataset), 0), - exit, TAG, "Failed to post OPENTHREAD_EVENT_ATTACHED. Err: %s", esp_err_to_name(ret)); + ret = esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_ATTACHED, &dataset, sizeof(dataset), 0); + ESP_GOTO_ON_ERROR(ret, exit, TAG, "Failed to post OPENTHREAD_EVENT_ATTACHED. Err: %s", esp_err_to_name(ret)); } } else if (role == OT_DEVICE_ROLE_DETACHED) { if (s_previous_role != OT_DEVICE_ROLE_DISABLED) { - ESP_GOTO_ON_ERROR( - esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_DETACHED, &s_previous_role, sizeof(s_previous_role), 0), - exit, TAG, "Failed to post OPENTHREAD_EVENT_DETACHED. Err: %s", esp_err_to_name(ret)); + ret = esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_DETACHED, &s_previous_role, sizeof(s_previous_role), 0); + ESP_GOTO_ON_ERROR(ret, exit, TAG, "Failed to post OPENTHREAD_EVENT_DETACHED. Err: %s", esp_err_to_name(ret)); } } exit: diff --git a/examples/openthread/ot_br/sdkconfig.ci.spinel_trel b/examples/openthread/ot_br/sdkconfig.ci.spinel_trel new file mode 100644 index 0000000000..58ad47256f --- /dev/null +++ b/examples/openthread/ot_br/sdkconfig.ci.spinel_trel @@ -0,0 +1 @@ +CONFIG_OPENTHREAD_RADIO_TREL=y diff --git a/examples/openthread/ot_br/sdkconfig.ci.spinel_trel_ext_coex b/examples/openthread/ot_br/sdkconfig.ci.spinel_trel_ext_coex new file mode 100644 index 0000000000..571881d7f6 --- /dev/null +++ b/examples/openthread/ot_br/sdkconfig.ci.spinel_trel_ext_coex @@ -0,0 +1,2 @@ +CONFIG_OPENTHREAD_RADIO_TREL=y +CONFIG_EXTERNAL_COEX_ENABLE=y