feat(openthread): support multipan feature for RCP

This commit is contained in:
Xu Si Yu
2026-08-14 15:07:15 +08:00
parent de8d87d8de
commit 3079c4b9e3
17 changed files with 755 additions and 220 deletions
@@ -42,3 +42,9 @@
#else
#define ESP_OPENTHREAD_ASSERT(a) assert(a)
#endif
#if CONFIG_OPENTHREAD_MULTIPAN_RCP_ENABLE
#define OT_INSTANCE_COUNT CONFIG_OPENTHREAD_MULTIPLE_INTERFACES_COUNT
#else
#define OT_INSTANCE_COUNT 1
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,8 +10,21 @@
extern "C" {
#endif
/**
* @brief This function initializes the NCP for a single instance
*
* @param[in] aInstance The OpenThread instance.
*/
void otAppNcpInit(otInstance *aInstance);
/**
* @brief This function initializes the NCP for multiple instances
*
* @param[in] aInstances The array of OpenThread instances.
* @param[in] aCount The number of instances.
*/
void otAppNcpInitMulti(otInstance **aInstances, uint8_t aCount);
#if CONFIG_OPENTHREAD_RCP_SPINEL_CONSOLE
esp_err_t esp_console_redirect_to_otlog(void);
#endif // CONFIG_OPENTHREAD_RCP_SPINEL_CONSOLE
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -155,6 +155,37 @@ void esp_openthread_set_storage_name(const char *name);
*/
uint32_t esp_openthread_get_alloc_caps(void);
/**
* @brief This function gets the index of the instance
*
* @param[in] instance The OpenThread instance.
*
* @note Invalid input is logged and asserted.
*
* @return
* - The index of the instance
*/
int8_t esp_openthread_get_idx_from_instance(otInstance *instance);
/**
* @brief This function gets the instance from the index
*
* @param[in] idx The index of the instance.
*
* @note Invalid index is logged and asserted. A valid index always has an instance.
*
* @return
* - The instance
*/
otInstance *esp_openthread_get_instance_from_idx(int8_t idx);
/**
* @brief This function sets the active instance
*
* @param[in] instance The OpenThread instance.
*/
void esp_openthread_set_active_instance(otInstance *instance);
#ifdef __cplusplus
} // end of extern "C"
#endif
@@ -165,6 +165,62 @@
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
*
* Define to 1 to enable multiple instance support.
*/
#ifdef OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#error `OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE` is redefined.
#endif
#if CONFIG_OPENTHREAD_MULTIPAN_RCP_ENABLE
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 1
#else
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
*
* Define to 1 to enable multipan RCP support.
*/
#ifdef OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
#error `OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE` is redefined.
#endif
#if CONFIG_OPENTHREAD_MULTIPAN_RCP_ENABLE
#define OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 1
#else
#define OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
*
* Define to 1 to enable multiple static instance support.
*/
#ifdef OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
#error `OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE` is redefined.
#endif
#if CONFIG_OPENTHREAD_MULTIPAN_RCP_ENABLE
#define OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE 1
#else
#define OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE 0
#endif
/**
* @def OPENTHREAD_SPINEL_CONFIG_BROADCAST_IID
*
* Define broadcast IID for spinel frames dedicated to all hosts in multipan configuration.
* Host interfaces use IID 0 .. COUNT-1; broadcast takes the next slot.
*
*/
#ifdef OPENTHREAD_SPINEL_CONFIG_BROADCAST_IID
#error `OPENTHREAD_SPINEL_CONFIG_BROADCAST_IID` is redefined.
#endif
#if CONFIG_OPENTHREAD_MULTIPAN_RCP_ENABLE
#define OPENTHREAD_SPINEL_CONFIG_BROADCAST_IID SPINEL_HEADER_IID(CONFIG_OPENTHREAD_MULTIPLE_INTERFACES_COUNT)
#endif
/*----The following options set fixed default values but can be overridden by the user header file.----*/
#if CONFIG_OPENTHREAD_LINK_METRICS