Merge branch 'fix/fix_coex_macro_control' into 'master'

fix(openthread): use the correct macros to control code compilation

See merge request espressif/esp-idf!36362
This commit is contained in:
Jiang Jiang Jian 2025-01-16 20:34:20 +08:00
commit 4f8bf6b98e
9 changed files with 28 additions and 26 deletions

View File

@ -602,7 +602,7 @@ static IRAM_ATTR void isr_handle_tx_abort(ieee802154_ll_tx_abort_reason_t tx_abo
NEEDS_NEXT_OPT(true); NEEDS_NEXT_OPT(true);
break; break;
case IEEE802154_TX_ABORT_BY_TX_COEX_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(); esp_coex_ieee802154_coex_break_notify();
#endif #endif
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX || s_ieee802154_state == IEEE802154_STATE_TX_CCA); IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX || s_ieee802154_state == IEEE802154_STATE_TX_CCA);

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -12,7 +12,7 @@
#include "esp_openthread_types.h" #include "esp_openthread_types.h"
#include "openthread/instance.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" #include "esp_coex_i154.h"
#endif #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); 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. * @brief Set the coexist config.

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -461,7 +461,7 @@
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1 #define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1
#endif #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 * @def OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE
* *
@ -494,7 +494,7 @@
#define OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL (60 * 1000 * 1000) #define OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL (60 * 1000 * 1000)
#endif #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 * @def OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
* *
@ -504,7 +504,7 @@
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1 #define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
#endif #endif
#endif #endif
#endif // !CONFIG_OPENTHREAD_RADIO_NATIVE #endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
#if CONFIG_OPENTHREAD_LINK_METRICS #if CONFIG_OPENTHREAD_LINK_METRICS
/** /**

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -9,7 +9,7 @@
#include "esp_openthread_ncp.h" #include "esp_openthread_ncp.h"
#include "ncp_base.hpp" #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" #include "esp_coex_i154.h"
#endif #endif
@ -70,7 +70,7 @@ otError NcpBase::VendorGetPropertyHandler(spinel_prop_key_t aPropKey)
switch (aPropKey) switch (aPropKey)
{ {
case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: { 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(); esp_ieee802154_coex_config_t config = esp_ieee802154_get_coex_config();
const uint8_t *args = reinterpret_cast<const uint8_t *>(&config); const uint8_t *args = reinterpret_cast<const uint8_t *>(&config);
error = mEncoder.WriteDataWithLen(args, sizeof(esp_ieee802154_coex_config_t)); error = mEncoder.WriteDataWithLen(args, sizeof(esp_ieee802154_coex_config_t));
@ -110,7 +110,7 @@ otError NcpBase::VendorSetPropertyHandler(spinel_prop_key_t aPropKey)
break; break;
} }
case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: { 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; const uint8_t *args = nullptr;
uint16_t len = 0; uint16_t len = 0;
mDecoder.ReadDataWithLen(args, len); mDecoder.ReadDataWithLen(args, len);

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -32,7 +32,7 @@
#include "utils/link_metrics.h" #include "utils/link_metrics.h"
#include "utils/mac_frame.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" #include "esp_coex_i154.h"
#endif #endif
@ -815,7 +815,7 @@ uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance)
return CONFIG_OPENTHREAD_SUPPORTED_CHANNEL_MASK; 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) void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config)
{ {
esp_ieee802154_set_coex_config(config); esp_ieee802154_set_coex_config(config);

View File

@ -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 * 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; 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) #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_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.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); 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"); ESP_RETURN_ON_ERROR(esp_openthread_radio_spinel_coex_config_init(), OT_PLAT_LOG_TAG, "Coex config init failed");
#endif #endif
#if CONFIG_OPENTHREAD_RADIO_SPINEL_SPI // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI #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); 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) void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config)
{ {

View File

@ -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 * 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) 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); otLinkModeConfig linkmode = otThreadGetLinkMode(instance);
esp_ieee802154_coex_config_t config = esp_openthread_get_coex_config(); esp_ieee802154_coex_config_t config = esp_openthread_get_coex_config();
config.txrx = (linkmode.mRxOnWhenIdle) ? IEEE802154_LOW : IEEE802154_MIDDLE; config.txrx = (linkmode.mRxOnWhenIdle) ? IEEE802154_LOW : IEEE802154_MIDDLE;
@ -83,14 +83,13 @@ static void handle_ot_role_change(otInstance* instance)
otOperationalDataset dataset; otOperationalDataset dataset;
ESP_GOTO_ON_FALSE(otDatasetGetActive(instance, &dataset) == OT_ERROR_NONE, ESP_FAIL, exit, TAG, ESP_GOTO_ON_FALSE(otDatasetGetActive(instance, &dataset) == OT_ERROR_NONE, ESP_FAIL, exit, TAG,
"Failed to get the active dataset"); "Failed to get the active dataset");
ESP_GOTO_ON_ERROR(esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_ATTACHED, &dataset, sizeof(dataset), 0), ret = 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)); 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) { } else if (role == OT_DEVICE_ROLE_DETACHED) {
if (s_previous_role != OT_DEVICE_ROLE_DISABLED) { if (s_previous_role != OT_DEVICE_ROLE_DISABLED) {
ESP_GOTO_ON_ERROR( ret = esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_DETACHED, &s_previous_role, sizeof(s_previous_role), 0);
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, TAG, "Failed to post OPENTHREAD_EVENT_DETACHED. Err: %s", esp_err_to_name(ret));
} }
} }
exit: exit:

View File

@ -0,0 +1 @@
CONFIG_OPENTHREAD_RADIO_TREL=y

View File

@ -0,0 +1,2 @@
CONFIG_OPENTHREAD_RADIO_TREL=y
CONFIG_EXTERNAL_COEX_ENABLE=y