mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'backport/openthread_related_bacport_to_5_2' into 'release/v5.2'
Backport some openthread related features (Backport v5.2) See merge request espressif/esp-idf!32250
This commit is contained in:
commit
f7dd52f281
@ -237,9 +237,9 @@ execute_process(
|
|||||||
|
|
||||||
string(TIMESTAMP OT_BUILD_TIMESTAMP " %Y-%m-%d %H:%M:%S UTC" UTC)
|
string(TIMESTAMP OT_BUILD_TIMESTAMP " %Y-%m-%d %H:%M:%S UTC" UTC)
|
||||||
string(CONCAT OT_FULL_VERSION_STRING
|
string(CONCAT OT_FULL_VERSION_STRING
|
||||||
"openthread-esp32/"
|
"${CONFIG_OPENTHREAD_PACKAGE_NAME}/"
|
||||||
"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\; "
|
"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\; "
|
||||||
"${CONFIG_IDF_TARGET}\; ${OT_BUILD_TIMESTAMP}")
|
"${CONFIG_OPENTHREAD_PLATFORM_INFO}\; ${OT_BUILD_TIMESTAMP}")
|
||||||
|
|
||||||
idf_component_register(SRC_DIRS "${src_dirs}"
|
idf_component_register(SRC_DIRS "${src_dirs}"
|
||||||
EXCLUDE_SRCS "${exclude_srcs}"
|
EXCLUDE_SRCS "${exclude_srcs}"
|
||||||
@ -266,6 +266,8 @@ if(CONFIG_OPENTHREAD_ENABLED OR CONFIG_OPENTHREAD_SPINEL_ONLY)
|
|||||||
PUBLIC
|
PUBLIC
|
||||||
"OPENTHREAD_CONFIG_FILE=\"openthread-core-esp32x-${CONFIG_FILE_TYPE}-config.h\""
|
"OPENTHREAD_CONFIG_FILE=\"openthread-core-esp32x-${CONFIG_FILE_TYPE}-config.h\""
|
||||||
"${device_type}"
|
"${device_type}"
|
||||||
|
"OPENTHREAD_PROJECT_LIB_CONFIG_FILE=\"openthread-core-esp32x-${CONFIG_FILE_TYPE}-config.h\""
|
||||||
|
"${device_type}"
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"PACKAGE_VERSION=\"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\""
|
"PACKAGE_VERSION=\"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\""
|
||||||
"OPENTHREAD_BUILD_DATETIME=\"${OT_BUILD_TIMESTAMP}\""
|
"OPENTHREAD_BUILD_DATETIME=\"${OT_BUILD_TIMESTAMP}\""
|
||||||
|
@ -170,10 +170,26 @@ menu "OpenThread"
|
|||||||
Select this to enable SPI connection to host.
|
Select this to enable SPI connection to host.
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
menu "OpenThread version message"
|
||||||
|
depends on OPENTHREAD_ENABLED
|
||||||
|
|
||||||
|
config OPENTHREAD_PACKAGE_NAME
|
||||||
|
string "OpenThread package name"
|
||||||
|
default "openthread-esp32"
|
||||||
|
help
|
||||||
|
The OpenThread package name.
|
||||||
|
|
||||||
|
config OPENTHREAD_PLATFORM_INFO
|
||||||
|
string "platform information"
|
||||||
|
default IDF_TARGET
|
||||||
|
help
|
||||||
|
The OpenThread platform information.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config OPENTHREAD_NCP_VENDOR_HOOK
|
config OPENTHREAD_NCP_VENDOR_HOOK
|
||||||
bool "Enable vendor command for RCP"
|
bool "Enable vendor command for RCP"
|
||||||
depends on OPENTHREAD_RADIO
|
depends on OPENTHREAD_RADIO
|
||||||
default n
|
default y
|
||||||
help
|
help
|
||||||
Select this to enable OpenThread NCP vendor commands.
|
Select this to enable OpenThread NCP vendor commands.
|
||||||
|
|
||||||
@ -259,7 +275,8 @@ menu "OpenThread"
|
|||||||
config OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
config OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
int "The size of openthread spinel rx frame buffer"
|
int "The size of openthread spinel rx frame buffer"
|
||||||
depends on OPENTHREAD_ENABLED || OPENTHREAD_SPINEL_ONLY
|
depends on OPENTHREAD_ENABLED || OPENTHREAD_SPINEL_ONLY
|
||||||
default 2048
|
default 1024 if OPENTHREAD_MTD || OPENTHREAD_RADIO
|
||||||
|
default 2048 if OPENTHREAD_FTD || OPENTHREAD_SPINEL_ONLY
|
||||||
|
|
||||||
config OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
|
config OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
|
||||||
int "Maximum backoffs times before declaring a channel access failure."
|
int "Maximum backoffs times before declaring a channel access failure."
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit be7d36e4ff9cf7df6dfce54e58a31163c87b93f7
|
Subproject commit f32c18bc0840f400182456e58ae3900fc2fb4af7
|
@ -14,7 +14,7 @@
|
|||||||
* The platform-specific string to insert into the OpenThread version string.
|
* The platform-specific string to insert into the OpenThread version string.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_IDF_TARGET
|
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_OPENTHREAD_PLATFORM_INFO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||||
@ -317,7 +317,7 @@
|
|||||||
* Define to the full name of this package.
|
* Define to the full name of this package.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define PACKAGE_NAME "openthread-esp32"
|
#define PACKAGE_NAME CONFIG_OPENTHREAD_PACKAGE_NAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def PACKAGE_STRING
|
* @def PACKAGE_STRING
|
||||||
@ -355,13 +355,13 @@
|
|||||||
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE
|
* @def OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
*
|
*
|
||||||
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
||||||
* `RadioSpinel` platform is used.
|
* `RadioSpinel` platform is used.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
#define OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* The platform-specific string to insert into the OpenThread version string.
|
* The platform-specific string to insert into the OpenThread version string.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_IDF_TARGET
|
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_OPENTHREAD_PLATFORM_INFO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||||
@ -131,7 +131,7 @@
|
|||||||
* Define to the full name of this package.
|
* Define to the full name of this package.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define PACKAGE_NAME "openthread-esp32"
|
#define PACKAGE_NAME CONFIG_OPENTHREAD_PACKAGE_NAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def PACKAGE_STRING
|
* @def PACKAGE_STRING
|
||||||
@ -169,13 +169,13 @@
|
|||||||
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE
|
* @def OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
*
|
*
|
||||||
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
||||||
* `RadioSpinel` platform is used.
|
* `RadioSpinel` platform is used.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE 1024
|
#define OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* The platform-specific string to insert into the OpenThread version string.
|
* The platform-specific string to insert into the OpenThread version string.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_IDF_TARGET
|
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_OPENTHREAD_PLATFORM_INFO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||||
@ -112,7 +112,7 @@
|
|||||||
* Define to the full name of this package.
|
* Define to the full name of this package.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define PACKAGE_NAME "openthread-esp32"
|
#define PACKAGE_NAME CONFIG_OPENTHREAD_PACKAGE_NAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def PACKAGE_STRING
|
* @def PACKAGE_STRING
|
||||||
@ -142,13 +142,13 @@
|
|||||||
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE
|
* @def OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
*
|
*
|
||||||
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
||||||
* `RadioSpinel` platform is used.
|
* `RadioSpinel` platform is used.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE 1024
|
#define OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
||||||
|
@ -6,6 +6,23 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
/**
|
||||||
|
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
|
||||||
|
*
|
||||||
|
* The platform-specific string to insert into the OpenThread version string.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define OPENTHREAD_CONFIG_PLATFORM_INFO CONFIG_OPENTHREAD_PLATFORM_INFO
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def PACKAGE_NAME
|
||||||
|
*
|
||||||
|
* Define to the full name of this package.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define PACKAGE_NAME CONFIG_OPENTHREAD_PACKAGE_NAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE
|
* @def OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE
|
||||||
*
|
*
|
||||||
@ -25,9 +42,11 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT
|
#ifndef OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT
|
||||||
// TZ-567: Set OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT to 3 after adding rcp failure notification mechanism
|
// TZ-567: Set OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT to 3 after adding rcp failure notification mechanism
|
||||||
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 0
|
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_SPINEL_CONFIG_RCP_CUSTOM_RESTORATION
|
* @def OPENTHREAD_SPINEL_CONFIG_RCP_CUSTOM_RESTORATION
|
||||||
*
|
*
|
||||||
@ -39,13 +58,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE
|
* @def OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
*
|
*
|
||||||
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
||||||
* `RadioSpinel` platform is used.
|
* `RadioSpinel` platform is used.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
#define OPENTHREAD_LIB_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
|
* @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
|
||||||
|
@ -5,4 +5,4 @@ supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
|
|||||||
originator: 'Organization: Google LLC'
|
originator: 'Organization: Google LLC'
|
||||||
description: OpenThread released by Google is an open-source implementation of the Thread networking
|
description: OpenThread released by Google is an open-source implementation of the Thread networking
|
||||||
url: https://github.com/espressif/openthread
|
url: https://github.com/espressif/openthread
|
||||||
hash: be7d36e4ff9cf7df6dfce54e58a31163c87b93f7
|
hash: f32c18bc0840f400182456e58ae3900fc2fb4af7
|
||||||
|
@ -320,7 +320,7 @@ void *esp_openthread_netif_glue_init(const esp_openthread_platform_config_t *con
|
|||||||
otIp6SetAddressCallback(instance, process_thread_address, instance);
|
otIp6SetAddressCallback(instance, process_thread_address, instance);
|
||||||
otIp6SetReceiveCallback(instance, process_thread_receive, instance);
|
otIp6SetReceiveCallback(instance, process_thread_receive, instance);
|
||||||
otIp6SetReceiveFilterEnabled(instance, true);
|
otIp6SetReceiveFilterEnabled(instance, true);
|
||||||
otIcmp6SetEchoMode(instance, OT_ICMP6_ECHO_HANDLER_DISABLED);
|
otIcmp6SetEchoMode(instance, OT_ICMP6_ECHO_HANDLER_RLOC_ALOC_ONLY);
|
||||||
|
|
||||||
s_openthread_netif_glue.event_fd = eventfd(0, 0);
|
s_openthread_netif_glue.event_fd = eventfd(0, 0);
|
||||||
if (s_openthread_netif_glue.event_fd < 0) {
|
if (s_openthread_netif_glue.event_fd < 0) {
|
||||||
|
@ -64,10 +64,13 @@ static otRadioFrame s_ack_frame;
|
|||||||
static int s_ed_power;
|
static int s_ed_power;
|
||||||
static esp_ieee802154_tx_error_t s_tx_error;
|
static esp_ieee802154_tx_error_t s_tx_error;
|
||||||
static int s_radio_event_fd = -1;
|
static int s_radio_event_fd = -1;
|
||||||
static bool s_diag_mode = false;
|
|
||||||
static const char *s_radio_workflow = "radio";
|
static const char *s_radio_workflow = "radio";
|
||||||
static uint8_t s_txrx_events;
|
static uint8_t s_txrx_events;
|
||||||
|
|
||||||
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
|
static bool s_diag_mode = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||||
static otRadioIeInfo s_transmit_ie_info;
|
static otRadioIeInfo s_transmit_ie_info;
|
||||||
#endif // OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
#endif // OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||||
@ -113,7 +116,7 @@ static inline bool get_event(uint8_t event)
|
|||||||
esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *config)
|
esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *config)
|
||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(s_radio_event_fd == -1, ESP_ERR_INVALID_STATE, OT_PLAT_LOG_TAG,
|
ESP_RETURN_ON_FALSE(s_radio_event_fd == -1, ESP_ERR_INVALID_STATE, OT_PLAT_LOG_TAG,
|
||||||
"Radio was initalized already!");
|
"Radio was initialized already!");
|
||||||
|
|
||||||
s_radio_event_fd = eventfd(0, EFD_SUPPORT_ISR);
|
s_radio_event_fd = eventfd(0, EFD_SUPPORT_ISR);
|
||||||
|
|
||||||
@ -165,7 +168,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
|
|||||||
|
|
||||||
if (get_event(EVENT_TX_DONE)) {
|
if (get_event(EVENT_TX_DONE)) {
|
||||||
clr_event(EVENT_TX_DONE);
|
clr_event(EVENT_TX_DONE);
|
||||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
if (otPlatDiagModeGet()) {
|
if (otPlatDiagModeGet()) {
|
||||||
otPlatDiagRadioTransmitDone(aInstance, &s_transmit_frame, OT_ERROR_NONE);
|
otPlatDiagRadioTransmitDone(aInstance, &s_transmit_frame, OT_ERROR_NONE);
|
||||||
} else
|
} else
|
||||||
@ -183,7 +186,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
|
|||||||
|
|
||||||
if (get_event(EVENT_TX_FAILED)) {
|
if (get_event(EVENT_TX_FAILED)) {
|
||||||
clr_event(EVENT_TX_FAILED);
|
clr_event(EVENT_TX_FAILED);
|
||||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
if (otPlatDiagModeGet()) {
|
if (otPlatDiagModeGet()) {
|
||||||
otPlatDiagRadioTransmitDone(aInstance, &s_transmit_frame, OT_ERROR_CHANNEL_ACCESS_FAILURE);
|
otPlatDiagRadioTransmitDone(aInstance, &s_transmit_frame, OT_ERROR_CHANNEL_ACCESS_FAILURE);
|
||||||
} else
|
} else
|
||||||
@ -219,7 +222,7 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
|
|||||||
|
|
||||||
while (atomic_load(&s_recv_queue.used)) {
|
while (atomic_load(&s_recv_queue.used)) {
|
||||||
if (s_receive_frame[s_recv_queue.head].mPsdu != NULL) {
|
if (s_receive_frame[s_recv_queue.head].mPsdu != NULL) {
|
||||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
if (otPlatDiagModeGet()) {
|
if (otPlatDiagModeGet()) {
|
||||||
otPlatDiagRadioReceiveDone(aInstance, &s_receive_frame[s_recv_queue.head], OT_ERROR_NONE);
|
otPlatDiagRadioReceiveDone(aInstance, &s_receive_frame[s_recv_queue.head], OT_ERROR_NONE);
|
||||||
} else
|
} else
|
||||||
@ -302,7 +305,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
{
|
{
|
||||||
esp_ieee802154_set_channel(aFrame->mChannel);
|
esp_ieee802154_set_channel(aFrame->mChannel);
|
||||||
|
|
||||||
aFrame->mPsdu[-1] = aFrame->mLength; // lenth locates one byte before the psdu (esp_openthread_radio_tx_psdu);
|
aFrame->mPsdu[-1] = aFrame->mLength; // length locates one byte before the psdu (esp_openthread_radio_tx_psdu);
|
||||||
|
|
||||||
if (otMacFrameIsSecurityEnabled(aFrame) && !aFrame->mInfo.mTxInfo.mIsSecurityProcessed) {
|
if (otMacFrameIsSecurityEnabled(aFrame) && !aFrame->mInfo.mTxInfo.mIsSecurityProcessed) {
|
||||||
if (!s_transmit_frame.mInfo.mTxInfo.mIsARetx) {
|
if (!s_transmit_frame.mInfo.mTxInfo.mIsARetx) {
|
||||||
@ -447,6 +450,15 @@ int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
|
|||||||
return ESP_RECEIVE_SENSITIVITY;
|
return ESP_RECEIVE_SENSITIVITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
|
|
||||||
|
void otPlatDiagSetOutputCallback(otInstance *aInstance, otPlatDiagOutputCallback aCallback, void *aContext)
|
||||||
|
{
|
||||||
|
OT_UNUSED_VARIABLE(aInstance);
|
||||||
|
OT_UNUSED_VARIABLE(aCallback);
|
||||||
|
OT_UNUSED_VARIABLE(aContext);
|
||||||
|
}
|
||||||
|
|
||||||
void otPlatDiagModeSet(bool mode)
|
void otPlatDiagModeSet(bool mode)
|
||||||
{
|
{
|
||||||
s_diag_mode = mode;
|
s_diag_mode = mode;
|
||||||
@ -479,6 +491,8 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
|
|||||||
OT_UNUSED_VARIABLE(aInstance);
|
OT_UNUSED_VARIABLE(aInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // CONFIG_OPENTHREAD_DIAG
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
||||||
void otPlatRadioSetMacKey(otInstance *aInstance, uint8_t aKeyIdMode, uint8_t aKeyId, const otMacKeyMaterial *aPrevKey,
|
void otPlatRadioSetMacKey(otInstance *aInstance, uint8_t aKeyIdMode, uint8_t aKeyId, const otMacKeyMaterial *aPrevKey,
|
||||||
const otMacKeyMaterial *aCurrKey, const otMacKeyMaterial *aNextKey, otRadioKeyType aKeyType)
|
const otMacKeyMaterial *aCurrKey, const otMacKeyMaterial *aNextKey, otRadioKeyType aKeyType)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "esp_openthread_radio.h"
|
#include "esp_openthread_radio.h"
|
||||||
|
|
||||||
|
#include "link_raw.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
@ -23,9 +24,11 @@
|
|||||||
#include "openthread/platform/diag.h"
|
#include "openthread/platform/diag.h"
|
||||||
#include "openthread/platform/radio.h"
|
#include "openthread/platform/radio.h"
|
||||||
#include "platform/exit_code.h"
|
#include "platform/exit_code.h"
|
||||||
|
#include "spinel_driver.hpp"
|
||||||
|
|
||||||
using ot::Spinel::RadioSpinel;
|
using ot::Spinel::RadioSpinel;
|
||||||
using esp::openthread::SpinelInterfaceAdapter;
|
using esp::openthread::SpinelInterfaceAdapter;
|
||||||
|
using ot::Spinel::SpinelDriver;
|
||||||
|
|
||||||
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART // CONFIG_OPENTHREAD_RADIO_SPINEL_UART
|
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART // CONFIG_OPENTHREAD_RADIO_SPINEL_UART
|
||||||
using esp::openthread::UartSpinelInterface;
|
using esp::openthread::UartSpinelInterface;
|
||||||
@ -35,7 +38,17 @@ using esp::openthread::SpiSpinelInterface;
|
|||||||
static SpinelInterfaceAdapter<SpiSpinelInterface> s_spinel_interface;
|
static SpinelInterfaceAdapter<SpiSpinelInterface> s_spinel_interface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static SpinelDriver s_spinel_driver;
|
||||||
static RadioSpinel s_radio;
|
static RadioSpinel s_radio;
|
||||||
|
static otRadioCaps s_radio_caps = (OT_RADIO_CAPS_ENERGY_SCAN |
|
||||||
|
#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
|
||||||
|
OT_RADIO_CAPS_RX_ON_WHEN_IDLE |
|
||||||
|
#endif
|
||||||
|
OT_RADIO_CAPS_TRANSMIT_SEC |
|
||||||
|
OT_RADIO_CAPS_RECEIVE_TIMING |
|
||||||
|
OT_RADIO_CAPS_TRANSMIT_TIMING |
|
||||||
|
OT_RADIO_CAPS_ACK_TIMEOUT |
|
||||||
|
OT_RADIO_CAPS_SLEEP_TO_TX);
|
||||||
|
|
||||||
static const char *radiospinel_workflow = "radio_spinel";
|
static const char *radiospinel_workflow = "radio_spinel";
|
||||||
|
|
||||||
@ -60,7 +73,7 @@ esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *conf
|
|||||||
#if CONFIG_OPENTHREAD_DIAG
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
callbacks.mDiagReceiveDone = otPlatDiagRadioReceiveDone;
|
callbacks.mDiagReceiveDone = otPlatDiagRadioReceiveDone;
|
||||||
callbacks.mDiagTransmitDone = otPlatDiagRadioTransmitDone;
|
callbacks.mDiagTransmitDone = otPlatDiagRadioTransmitDone;
|
||||||
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
|
#endif // CONFIG_OPENTHREAD_DIAG
|
||||||
callbacks.mEnergyScanDone = otPlatRadioEnergyScanDone;
|
callbacks.mEnergyScanDone = otPlatRadioEnergyScanDone;
|
||||||
callbacks.mReceiveDone = otPlatRadioReceiveDone;
|
callbacks.mReceiveDone = otPlatRadioReceiveDone;
|
||||||
callbacks.mTransmitDone = otPlatRadioTxDone;
|
callbacks.mTransmitDone = otPlatRadioTxDone;
|
||||||
@ -70,14 +83,15 @@ esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *conf
|
|||||||
esp_openthread_radio_config_set(&config->radio_config);
|
esp_openthread_radio_config_set(&config->radio_config);
|
||||||
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART // CONFIG_OPENTHREAD_RADIO_SPINEL_UART
|
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART // CONFIG_OPENTHREAD_RADIO_SPINEL_UART
|
||||||
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(config->radio_config.radio_uart_config), OT_PLAT_LOG_TAG,
|
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(config->radio_config.radio_uart_config), OT_PLAT_LOG_TAG,
|
||||||
"Spinel interface init falied");
|
"Spinel interface init failed");
|
||||||
#else // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
|
#else // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
|
||||||
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(config->radio_config.radio_spi_config), OT_PLAT_LOG_TAG,
|
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(config->radio_config.radio_spi_config), OT_PLAT_LOG_TAG,
|
||||||
"Spinel interface init failed");
|
"Spinel interface init failed");
|
||||||
#endif
|
#endif
|
||||||
s_radio.Init(s_spinel_interface.GetSpinelInterface(), /*reset_radio=*/true, /*skip_rcp_compatibility_check=*/false, iidList, ot::Spinel::kSpinelHeaderMaxNumIid);
|
s_spinel_driver.Init(s_spinel_interface.GetSpinelInterface(), true, iidList, ot::Spinel::kSpinelHeaderMaxNumIid);
|
||||||
|
s_radio.Init(/*skip_rcp_compatibility_check=*/false, /*reset_radio=*/true, &s_spinel_driver, s_radio_caps);
|
||||||
#if CONFIG_OPENTHREAD_RADIO_SPINEL_SPI // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
|
#if CONFIG_OPENTHREAD_RADIO_SPINEL_SPI // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
|
||||||
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().AfterRadioInit(), OT_PLAT_LOG_TAG, "Spinel interface init falied");
|
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().AfterRadioInit(), OT_PLAT_LOG_TAG, "Spinel interface init failed");
|
||||||
#endif
|
#endif
|
||||||
return esp_openthread_platform_workflow_register(&esp_openthread_radio_update, &esp_openthread_radio_process,
|
return esp_openthread_platform_workflow_register(&esp_openthread_radio_update, &esp_openthread_radio_process,
|
||||||
radiospinel_workflow);
|
radiospinel_workflow);
|
||||||
@ -106,7 +120,7 @@ esp_err_t esp_openthread_rcp_init(void)
|
|||||||
const esp_openthread_radio_config_t *radio_config = esp_openthread_radio_config_get();
|
const esp_openthread_radio_config_t *radio_config = esp_openthread_radio_config_get();
|
||||||
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART
|
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART
|
||||||
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(radio_config->radio_uart_config), OT_PLAT_LOG_TAG,
|
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(radio_config->radio_uart_config), OT_PLAT_LOG_TAG,
|
||||||
"Spinel interface init falied");
|
"Spinel interface init failed");
|
||||||
#else // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
|
#else // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
|
||||||
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(radio_config->radio_spi_config), OT_PLAT_LOG_TAG,
|
ESP_RETURN_ON_ERROR(s_spinel_interface.GetSpinelInterface().Enable(radio_config->radio_spi_config), OT_PLAT_LOG_TAG,
|
||||||
"Spinel interface init failed");
|
"Spinel interface init failed");
|
||||||
@ -128,6 +142,7 @@ void esp_openthread_radio_deinit(void)
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
s_spinel_driver.Process((void *)mainloop);
|
||||||
s_radio.Process((void *)mainloop);
|
s_radio.Process((void *)mainloop);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@ -211,7 +226,8 @@ int8_t otPlatRadioGetRssi(otInstance *instance)
|
|||||||
|
|
||||||
otRadioCaps otPlatRadioGetCaps(otInstance *instance)
|
otRadioCaps otPlatRadioGetCaps(otInstance *instance)
|
||||||
{
|
{
|
||||||
return s_radio.GetRadioCaps();
|
s_radio_caps = s_radio.GetRadioCaps();
|
||||||
|
return s_radio_caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool otPlatRadioGetPromiscuous(otInstance *instance)
|
bool otPlatRadioGetPromiscuous(otInstance *instance)
|
||||||
@ -319,7 +335,7 @@ void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCoun
|
|||||||
SuccessOrDie(s_radio.SetMacFrameCounter(aMacFrameCounter, true));
|
SuccessOrDie(s_radio.SetMacFrameCounter(aMacFrameCounter, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
#if CONFIG_OPENTHREAD_DIAG
|
||||||
otError otPlatDiagProcess(otInstance *instance, int argc, char *argv[], char *output, size_t output_max_len)
|
otError otPlatDiagProcess(otInstance *instance, int argc, char *argv[], char *output, size_t output_max_len)
|
||||||
{
|
{
|
||||||
// deliver the platform specific diags commands to radio only ncp.
|
// deliver the platform specific diags commands to radio only ncp.
|
||||||
@ -331,12 +347,19 @@ otError otPlatDiagProcess(otInstance *instance, int argc, char *argv[], char *ou
|
|||||||
cur += snprintf(cur, static_cast<size_t>(end - cur), "%s ", argv[index]);
|
cur += snprintf(cur, static_cast<size_t>(end - cur), "%s ", argv[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_radio.PlatDiagProcess(cmd, output, output_max_len);
|
return s_radio.PlatDiagProcess(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void otPlatDiagSetOutputCallback(otInstance *aInstance, otPlatDiagOutputCallback aCallback, void *aContext)
|
||||||
|
{
|
||||||
|
OT_UNUSED_VARIABLE(aInstance);
|
||||||
|
OT_UNUSED_VARIABLE(aCallback);
|
||||||
|
OT_UNUSED_VARIABLE(aContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void otPlatDiagModeSet(bool aMode)
|
void otPlatDiagModeSet(bool aMode)
|
||||||
{
|
{
|
||||||
SuccessOrExit(s_radio.PlatDiagProcess(aMode ? "start" : "stop", NULL, 0));
|
SuccessOrExit(s_radio.PlatDiagProcess(aMode ? "start" : "stop"));
|
||||||
s_radio.SetDiagEnabled(aMode);
|
s_radio.SetDiagEnabled(aMode);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -353,7 +376,7 @@ void otPlatDiagTxPowerSet(int8_t tx_power)
|
|||||||
char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE];
|
char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE];
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "power %d", tx_power);
|
snprintf(cmd, sizeof(cmd), "power %d", tx_power);
|
||||||
SuccessOrExit(s_radio.PlatDiagProcess(cmd, NULL, 0));
|
SuccessOrExit(s_radio.PlatDiagProcess(cmd));
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return;
|
return;
|
||||||
@ -364,7 +387,7 @@ void otPlatDiagChannelSet(uint8_t channel)
|
|||||||
char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE];
|
char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE];
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "channel %d", channel);
|
snprintf(cmd, sizeof(cmd), "channel %d", channel);
|
||||||
SuccessOrExit(s_radio.PlatDiagProcess(cmd, NULL, 0));
|
SuccessOrExit(s_radio.PlatDiagProcess(cmd));
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return;
|
return;
|
||||||
@ -378,13 +401,13 @@ void otPlatDiagAlarmCallback(otInstance *instance)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // CONFIG_OPENTHREAD_DIAG
|
||||||
|
|
||||||
const char *otPlatRadioGetVersionString(otInstance *aInstance)
|
const char *otPlatRadioGetVersionString(otInstance *aInstance)
|
||||||
{
|
{
|
||||||
return s_radio.GetVersion();
|
return s_radio.GetVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
|
|
||||||
|
|
||||||
uint64_t otPlatRadioGetNow(otInstance *aInstance)
|
uint64_t otPlatRadioGetNow(otInstance *aInstance)
|
||||||
{
|
{
|
||||||
OT_UNUSED_VARIABLE(aInstance);
|
OT_UNUSED_VARIABLE(aInstance);
|
||||||
|
@ -12,17 +12,33 @@
|
|||||||
#include "esp_radio_spinel.h"
|
#include "esp_radio_spinel.h"
|
||||||
#include "esp_radio_spinel_adapter.hpp"
|
#include "esp_radio_spinel_adapter.hpp"
|
||||||
#include "esp_radio_spinel_uart_interface.hpp"
|
#include "esp_radio_spinel_uart_interface.hpp"
|
||||||
|
#include "spinel_driver.hpp"
|
||||||
|
|
||||||
|
#define SPINEL_VENDOR_PROPERTY_BIT_PENDINGMODE BIT(0)
|
||||||
|
#define SPINEL_VENDOR_PROPERTY_BIT_COORDINATOR BIT(1)
|
||||||
|
static esp_ieee802154_pending_mode_t s_spinel_vendor_property_pendingmode[ot::Spinel::kSpinelHeaderMaxNumIid] = {ESP_IEEE802154_AUTO_PENDING_DISABLE};
|
||||||
|
static bool s_spinel_vendor_property_coordinator[ot::Spinel::kSpinelHeaderMaxNumIid] = {false};
|
||||||
|
static uint64_t s_spinel_vendor_property_mask[ot::Spinel::kSpinelHeaderMaxNumIid] = {0};
|
||||||
|
|
||||||
using ot::Spinel::RadioSpinel;
|
using ot::Spinel::RadioSpinel;
|
||||||
using ot::Spinel::RadioSpinelCallbacks;
|
using ot::Spinel::RadioSpinelCallbacks;
|
||||||
using esp::radio_spinel::SpinelInterfaceAdapter;
|
using esp::radio_spinel::SpinelInterfaceAdapter;
|
||||||
using esp::radio_spinel::UartSpinelInterface;
|
using esp::radio_spinel::UartSpinelInterface;
|
||||||
|
using ot::Spinel::SpinelDriver;
|
||||||
|
|
||||||
static SpinelInterfaceAdapter<UartSpinelInterface> s_spinel_interface[ot::Spinel::kSpinelHeaderMaxNumIid];
|
static SpinelInterfaceAdapter<UartSpinelInterface> s_spinel_interface[ot::Spinel::kSpinelHeaderMaxNumIid];
|
||||||
static RadioSpinel s_radio[ot::Spinel::kSpinelHeaderMaxNumIid];
|
static RadioSpinel s_radio[ot::Spinel::kSpinelHeaderMaxNumIid];
|
||||||
static esp_radio_spinel_callbacks_t s_esp_radio_spinel_callbacks[ot::Spinel::kSpinelHeaderMaxNumIid];
|
static esp_radio_spinel_callbacks_t s_esp_radio_spinel_callbacks[ot::Spinel::kSpinelHeaderMaxNumIid];
|
||||||
|
static SpinelDriver s_spinel_driver[ot::Spinel::kSpinelHeaderMaxNumIid];
|
||||||
otRadioFrame s_transmit_frame;
|
otRadioFrame s_transmit_frame;
|
||||||
|
|
||||||
|
static otRadioCaps s_radio_caps = (OT_RADIO_CAPS_ENERGY_SCAN |
|
||||||
|
OT_RADIO_CAPS_TRANSMIT_SEC |
|
||||||
|
OT_RADIO_CAPS_RECEIVE_TIMING |
|
||||||
|
OT_RADIO_CAPS_TRANSMIT_TIMING |
|
||||||
|
OT_RADIO_CAPS_ACK_TIMEOUT |
|
||||||
|
OT_RADIO_CAPS_SLEEP_TO_TX);
|
||||||
|
|
||||||
static esp_radio_spinel_idx_t get_index_from_instance(otInstance *instance)
|
static esp_radio_spinel_idx_t get_index_from_instance(otInstance *instance)
|
||||||
{
|
{
|
||||||
// TZ-563: Implement the function to get the esp radio spinel idx from otInstance for multipan rcp
|
// TZ-563: Implement the function to get the esp radio spinel idx from otInstance for multipan rcp
|
||||||
@ -35,6 +51,22 @@ static otInstance* get_instance_from_index(esp_radio_spinel_idx_t idx)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void esp_radio_spinel_restore_vendor_properities(void *context)
|
||||||
|
{
|
||||||
|
esp_radio_spinel_idx_t idx = get_index_from_instance((otInstance*)context);
|
||||||
|
if (s_spinel_vendor_property_mask[idx] & SPINEL_VENDOR_PROPERTY_BIT_PENDINGMODE) {
|
||||||
|
if (esp_radio_spinel_set_pending_mode(s_spinel_vendor_property_pendingmode[idx], idx) != ESP_OK) {
|
||||||
|
ESP_LOGE(ESP_SPINEL_LOG_TAG, "Fail to restore pendingmode: %d", idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_spinel_vendor_property_mask[idx] & SPINEL_VENDOR_PROPERTY_BIT_COORDINATOR) {
|
||||||
|
if (esp_radio_spinel_set_pan_coord(s_spinel_vendor_property_coordinator[idx], idx) != ESP_OK) {
|
||||||
|
ESP_LOGE(ESP_SPINEL_LOG_TAG, "Fail to restore coordinator: %d", idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
void ReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
||||||
{
|
{
|
||||||
esp_radio_spinel_idx_t idx = get_index_from_instance(aInstance);
|
esp_radio_spinel_idx_t idx = get_index_from_instance(aInstance);
|
||||||
@ -213,7 +245,10 @@ void esp_radio_spinel_init(esp_radio_spinel_idx_t idx)
|
|||||||
|
|
||||||
// Multipan is not currently supported
|
// Multipan is not currently supported
|
||||||
iidList[0] = 0;
|
iidList[0] = 0;
|
||||||
s_radio[idx].Init(s_spinel_interface[idx].GetSpinelInterface(), /*reset_radio=*/true, /*skip_rcp_compatibility_check=*/false, iidList, ot::Spinel::kSpinelHeaderMaxNumIid);
|
s_spinel_driver[idx].Init(s_spinel_interface[idx].GetSpinelInterface(), true, iidList, ot::Spinel::kSpinelHeaderMaxNumIid);
|
||||||
|
s_radio[idx].Init(/*skip_rcp_compatibility_check=*/false, /*reset_radio=*/true, &s_spinel_driver[idx], s_radio_caps);
|
||||||
|
otInstance *instance = get_instance_from_index(idx);
|
||||||
|
s_radio[idx].SetVendorRestorePropertiesCallback(esp_radio_spinel_restore_vendor_properities, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_enable(esp_radio_spinel_idx_t idx)
|
esp_err_t esp_radio_spinel_enable(esp_radio_spinel_idx_t idx)
|
||||||
@ -222,11 +257,6 @@ esp_err_t esp_radio_spinel_enable(esp_radio_spinel_idx_t idx)
|
|||||||
return (s_radio[idx].Enable(instance) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].Enable(instance) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_set_pending_mode(esp_ieee802154_pending_mode_t pending_mode, esp_radio_spinel_idx_t idx)
|
|
||||||
{
|
|
||||||
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_PENDINGMODE, SPINEL_DATATYPE_INT32_S, static_cast<int32_t>(pending_mode)) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_get_eui64(uint8_t *eui64, esp_radio_spinel_idx_t idx)
|
esp_err_t esp_radio_spinel_get_eui64(uint8_t *eui64, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
return (s_radio[idx].GetIeeeEui64(eui64) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].GetIeeeEui64(eui64) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
@ -249,11 +279,6 @@ esp_err_t esp_radio_spinel_set_extended_address(uint8_t *ext_address, esp_radio_
|
|||||||
return (s_radio[idx].SetExtendedAddress(aExtAddress) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].SetExtendedAddress(aExtAddress) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_set_pan_coord(bool enable, esp_radio_spinel_idx_t idx)
|
|
||||||
{
|
|
||||||
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_COORDINATOR, SPINEL_DATATYPE_BOOL_S, enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_receive(uint8_t channel, esp_radio_spinel_idx_t idx)
|
esp_err_t esp_radio_spinel_receive(uint8_t channel, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
return (s_radio[idx].Receive(channel) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].Receive(channel) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
@ -302,6 +327,24 @@ esp_err_t esp_radio_spinel_set_promiscuous_mode(bool enable, esp_radio_spinel_id
|
|||||||
return (s_radio[idx].SetPromiscuous(enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].SetPromiscuous(enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------Vendor Property Set-------------------------------------------------------*/
|
||||||
|
esp_err_t esp_radio_spinel_set_pending_mode(esp_ieee802154_pending_mode_t pending_mode, esp_radio_spinel_idx_t idx)
|
||||||
|
{
|
||||||
|
s_spinel_vendor_property_pendingmode[idx] = pending_mode;
|
||||||
|
s_spinel_vendor_property_mask[idx] |= SPINEL_VENDOR_PROPERTY_BIT_PENDINGMODE;
|
||||||
|
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_PENDINGMODE, SPINEL_DATATYPE_INT32_S, static_cast<int32_t>(pending_mode)) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_radio_spinel_set_pan_coord(bool enable, esp_radio_spinel_idx_t idx)
|
||||||
|
{
|
||||||
|
s_spinel_vendor_property_coordinator[idx] = enable;
|
||||||
|
s_spinel_vendor_property_mask[idx] |= SPINEL_VENDOR_PROPERTY_BIT_COORDINATOR;
|
||||||
|
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_COORDINATOR, SPINEL_DATATYPE_BOOL_S, enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
void esp_radio_spinel_radio_update(esp_radio_spinel_mainloop_context_t *mainloop_context, esp_radio_spinel_idx_t idx)
|
void esp_radio_spinel_radio_update(esp_radio_spinel_mainloop_context_t *mainloop_context, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
s_spinel_interface[idx].GetSpinelInterface().UpdateFdSet(static_cast<void *>(mainloop_context));
|
s_spinel_interface[idx].GetSpinelInterface().UpdateFdSet(static_cast<void *>(mainloop_context));
|
||||||
@ -309,6 +352,7 @@ void esp_radio_spinel_radio_update(esp_radio_spinel_mainloop_context_t *mainloop
|
|||||||
|
|
||||||
void esp_radio_spinel_radio_process(esp_radio_spinel_mainloop_context_t *mainloop_context, esp_radio_spinel_idx_t idx)
|
void esp_radio_spinel_radio_process(esp_radio_spinel_mainloop_context_t *mainloop_context, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
|
s_spinel_driver[idx].Process((void *)mainloop_context);
|
||||||
s_radio[idx].Process(static_cast<void *>(mainloop_context));
|
s_radio[idx].Process(static_cast<void *>(mainloop_context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,3 +398,29 @@ esp_err_t esp_radio_spinel_rcp_version_get(char *running_rcp_version, esp_radio_
|
|||||||
strcpy(running_rcp_version, rcp_version);
|
strcpy(running_rcp_version, rcp_version);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_radio_spinel_set_rcp_ready(esp_radio_spinel_idx_t idx)
|
||||||
|
{
|
||||||
|
s_spinel_driver[idx].SetCoprocessorReady();
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ot {
|
||||||
|
namespace Spinel {
|
||||||
|
|
||||||
|
otError RadioSpinel::VendorHandleValueIs(spinel_prop_key_t aPropKey)
|
||||||
|
{
|
||||||
|
otError error = OT_ERROR_NONE;
|
||||||
|
|
||||||
|
switch (aPropKey)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ESP_LOGW(ESP_SPINEL_LOG_TAG, "Not Implemented!");
|
||||||
|
error = OT_ERROR_NOT_FOUND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Spinel
|
||||||
|
} // namespace ot
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "esp_openthread_common_macro.h"
|
#include "esp_openthread_common_macro.h"
|
||||||
#include "openthread/platform/time.h"
|
#include "openthread/platform/time.h"
|
||||||
#include "hdlc.hpp"
|
#include "hdlc.hpp"
|
||||||
|
#include "core/common/code_utils.hpp"
|
||||||
|
|
||||||
namespace esp {
|
namespace esp {
|
||||||
namespace radio_spinel {
|
namespace radio_spinel {
|
||||||
|
@ -31,6 +31,42 @@ extern "C" {
|
|||||||
#define EXAMPLE_NETIF_DESC_ETH "example_netif_eth"
|
#define EXAMPLE_NETIF_DESC_ETH "example_netif_eth"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_CONNECT_PPP
|
||||||
|
#define EXAMPLE_NETIF_DESC_PPP "example_netif_ppp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST
|
||||||
|
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_FAST_SCAN
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL
|
||||||
|
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL
|
||||||
|
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY
|
||||||
|
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_WIFI_AUTH_OPEN
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WEP
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_ENTERPRISE
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */
|
/* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */
|
||||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||||
#define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)
|
#define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -26,38 +26,6 @@ static SemaphoreHandle_t s_semph_get_ip_addrs = NULL;
|
|||||||
static SemaphoreHandle_t s_semph_get_ip6_addrs = NULL;
|
static SemaphoreHandle_t s_semph_get_ip6_addrs = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST
|
|
||||||
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_FAST_SCAN
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL
|
|
||||||
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL
|
|
||||||
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY
|
|
||||||
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_WIFI_AUTH_OPEN
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WEP
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_ENTERPRISE
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int s_retry_num = 0;
|
static int s_retry_num = 0;
|
||||||
|
|
||||||
static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event_base,
|
static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event_base,
|
||||||
@ -75,6 +43,7 @@ static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event
|
|||||||
xSemaphoreGive(s_semph_get_ip6_addrs);
|
xSemaphoreGive(s_semph_get_ip6_addrs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
example_wifi_sta_do_disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Wi-Fi disconnected, trying to reconnect...");
|
ESP_LOGI(TAG, "Wi-Fi disconnected, trying to reconnect...");
|
||||||
|
@ -8,6 +8,11 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
|||||||
CONFIG_PARTITION_TABLE_MD5=y
|
CONFIG_PARTITION_TABLE_MD5=y
|
||||||
# end of Partition Table
|
# end of Partition Table
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wireless Coexistence
|
||||||
|
#
|
||||||
|
CONFIG_ESP_COEX_SW_COEXIST_ENABLE=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# OpenThread
|
# OpenThread
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user