mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'festure/add_ot_rcp_base_master' into 'master'
add ot-rcp See merge request espressif/esp-idf!14609
This commit is contained in:
commit
ab0d0b7dd2
@ -1 +1 @@
|
||||
Subproject commit 8b1137c35cc3d2b1085e7f857c2530efb115d3a3
|
||||
Subproject commit 1174878441c77b467503b1b7a1b24e00bea2839e
|
@ -41,6 +41,8 @@ typedef enum {
|
||||
ESP_IEEE802154_TX_ERR_NO_ACK, /*!< No Ack frame received until timeout */
|
||||
ESP_IEEE802154_TX_ERR_INVALID_ACK, /*!< Invalid Ack frame */
|
||||
ESP_IEEE802154_TX_ERR_COEXIST, /*!< Rejected by coexist system */
|
||||
ESP_IEEE802154_TX_ERR_COEXIST_REJ, /*!< Rejected by coexist system before transmitting frame */
|
||||
ESP_IEEE802154_TX_ERR_COEXIST_ACK, /*!< Rejected by coexist system when receiving ack */
|
||||
} esp_ieee802154_tx_error_t;
|
||||
|
||||
/**
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit efbc05d641040253567e825dae53731da595c7b5
|
||||
Subproject commit dd7afcc9f6d4bbd923f601e0d59b0e59b0170a91
|
@ -1,51 +1,10 @@
|
||||
if(CONFIG_OPENTHREAD_ENABLED)
|
||||
set(public_include_dirs
|
||||
"include"
|
||||
"openthread/include")
|
||||
|
||||
set(private_include_dirs
|
||||
"openthread/src"
|
||||
"openthread/src/core"
|
||||
"openthread/src/lib/hdlc"
|
||||
"openthread/src/lib/spinel"
|
||||
"openthread/src/ncp"
|
||||
"openthread/examples/platforms/")
|
||||
|
||||
set(src_dirs
|
||||
"openthread/examples/apps/cli"
|
||||
"openthread/examples/platforms/utils"
|
||||
"openthread/src/cli"
|
||||
"openthread/src/core/api"
|
||||
"openthread/src/core/backbone_router"
|
||||
"openthread/src/core/coap"
|
||||
"openthread/src/core/common"
|
||||
"openthread/src/core/crypto"
|
||||
"openthread/src/core/diags"
|
||||
"openthread/src/core/mac"
|
||||
"openthread/src/core/meshcop"
|
||||
"openthread/src/core/net"
|
||||
"openthread/src/core/radio"
|
||||
"openthread/src/core/thread"
|
||||
"openthread/src/core/utils"
|
||||
"openthread/src/lib/platform"
|
||||
"openthread/src/lib/hdlc"
|
||||
"openthread/src/lib/spinel")
|
||||
|
||||
if(CONFIG_OPENTHREAD_BORDER_ROUTER)
|
||||
list(APPEND src_dirs
|
||||
"openthread/src/core/border_router")
|
||||
if(CONFIG_OPENTHREAD_FTD)
|
||||
include(ftd.cmake)
|
||||
else()
|
||||
include(radio.cmake)
|
||||
endif()
|
||||
|
||||
set(exclude_srcs
|
||||
"openthread/examples/apps/cli/main.c"
|
||||
"openthread/examples/platforms/utils/logging_rtt.c"
|
||||
"openthread/examples/platforms/utils/soft_source_match_table.c"
|
||||
"openthread/src/core/common/extension_example.cpp")
|
||||
|
||||
set_source_files_properties("openthread/src/core/net/srp_server.cpp"
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-maybe-uninitialized)
|
||||
|
||||
if(CONFIG_OPENTHREAD_FTD)
|
||||
set(device_type "OPENTHREAD_FTD=1")
|
||||
elseif(CONFIG_OPENTHREAD_MTD)
|
||||
@ -75,13 +34,19 @@ idf_component_register(SRC_DIRS "${src_dirs}"
|
||||
REQUIRES mbedtls ieee802154)
|
||||
|
||||
if(CONFIG_OPENTHREAD_ENABLED)
|
||||
if(CONFIG_OPENTHREAD_RADIO)
|
||||
set(CONFIG_FILE_TYPE "radio")
|
||||
else()
|
||||
set(CONFIG_FILE_TYPE "ftd")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
${COMPONENT_LIB}
|
||||
PUBLIC
|
||||
"OPENTHREAD_CONFIG_FILE=\"openthread-core-esp32x-config.h\""
|
||||
"OPENTHREAD_CONFIG_FILE=\"openthread-core-esp32x-${CONFIG_FILE_TYPE}-config.h\""
|
||||
"${device_type}"
|
||||
PRIVATE
|
||||
"PACKAGE_VERSION=\"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\"")
|
||||
"PACKAGE_VERSION=\"${IDF_VERSION_FOR_OPENTHREAD_PACKAGE}-${OPENTHREAD_VERSION}\"")
|
||||
|
||||
if(CONFIG_OPENTHREAD_ESP_LIB_FROM_INTERNAL_SRC)
|
||||
idf_component_get_property(openthread_port_lib openthread_port COMPONENT_LIB)
|
||||
|
@ -57,7 +57,7 @@ OPENTHREAD_VERSION := $(shell git -C $(COMPONENT_PATH)/openthread rev-parse --sh
|
||||
OPENTHREAD_PACKAGE_VERSION := $(IDF_VERSION_FOR_OPENTHREAD_PACKAGE)-$(OPENTHREAD_VERSION)
|
||||
|
||||
COMMON_FLAGS := \
|
||||
-DOPENTHREAD_CONFIG_FILE=\<openthread-core-esp32x-config.h\> \
|
||||
-DOPENTHREAD_CONFIG_FILE=\<openthread-core-esp32x-ftd-config.h\> \
|
||||
-DPACKAGE_VERSION=\"OPENTHREAD_PACKAGE_VERSION\" \
|
||||
-Wno-maybe-uninitialized
|
||||
|
||||
|
53
components/openthread/ftd.cmake
Normal file
53
components/openthread/ftd.cmake
Normal file
@ -0,0 +1,53 @@
|
||||
set(public_include_dirs
|
||||
"include"
|
||||
"openthread/include")
|
||||
|
||||
set(private_include_dirs
|
||||
"openthread/examples/platforms"
|
||||
"openthread/include/openthread"
|
||||
"openthread/src"
|
||||
"openthread/src/core"
|
||||
"openthread/src/lib/hdlc"
|
||||
"openthread/src/lib/spinel"
|
||||
"openthread/src/ncp"
|
||||
"private_include"
|
||||
)
|
||||
|
||||
set(src_dirs
|
||||
"openthread/examples/apps/cli"
|
||||
"openthread/examples/platforms/utils"
|
||||
"openthread/src/core/api"
|
||||
"openthread/src/core/backbone_router"
|
||||
"openthread/src/core/coap"
|
||||
"openthread/src/core/common"
|
||||
"openthread/src/core/crypto"
|
||||
"openthread/src/core/diags"
|
||||
"openthread/src/core/mac"
|
||||
"openthread/src/core/meshcop"
|
||||
"openthread/src/core/net"
|
||||
"openthread/src/core/radio"
|
||||
"openthread/src/core/thread"
|
||||
"openthread/src/core/utils"
|
||||
"openthread/src/cli"
|
||||
"openthread/src/lib/hdlc"
|
||||
"openthread/src/lib/spinel"
|
||||
"openthread/src/lib/platform")
|
||||
|
||||
set(exclude_srcs
|
||||
"openthread/examples/apps/cli/main.c"
|
||||
"openthread/examples/platforms/utils/logging_rtt.c"
|
||||
"openthread/examples/platforms/utils/soft_source_match_table.c"
|
||||
"openthread/src/core/common/extension_example.cpp")
|
||||
|
||||
if(CONFIG_OPENTHREAD_BORDER_ROUTER)
|
||||
list(APPEND src_dirs
|
||||
"openthread/src/core/border_router")
|
||||
endif()
|
||||
|
||||
set_source_files_properties("openthread/src/core/net/srp_server.cpp"
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-maybe-uninitialized)
|
||||
|
||||
if(CONFIG_OPENTHREAD_FTD)
|
||||
set(device_type "OPENTHREAD_FTD=1")
|
||||
endif()
|
@ -82,8 +82,9 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
HOST_CONNECTION_MODE_NONE = 0x0, /*!< Disable host connection*/
|
||||
HOST_CONNECTION_MODE_UART = 0x1, /*!< UART connection to the host*/
|
||||
HOST_CONNECTION_MODE_NONE = 0x0, /*!< Disable host connection*/
|
||||
HOST_CONNECTION_MODE_CLI_UART = 0x1, /*!< CLI UART connection to the host*/
|
||||
HOST_CONNECTION_MODE_RCP_UART = 0x2, /*!< RCP UART connection to the host*/
|
||||
} esp_openthread_host_connection_mode_t;
|
||||
|
||||
/**
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 105f3610d2258d7a7dd1c72f5f1adea89077c6cc
|
||||
Subproject commit 5e09d71ee4a6a8165ae4cdbabc46b79a88a95c11
|
@ -0,0 +1,318 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) CO LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License
|
||||
|
||||
#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_IDF_TARGET
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||
*
|
||||
* The assert is managed by platform defined logic when this flag is set.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
|
||||
*
|
||||
* Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
|
||||
*
|
||||
* When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_OUTPUT
|
||||
*
|
||||
* The ESP-IDF platform provides an otPlatLog() function.
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_LEVEL
|
||||
*
|
||||
* The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most
|
||||
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_LOG_LEVEL
|
||||
#if CONFIG_LOG_DEFAULT_LEVEL_NONE
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_NONE
|
||||
#elif CONFIG_LOG_DEFAULT_LEVEL_ERROR
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_CRIT
|
||||
#elif CONFIG_LOG_DEFAULT_LEVEL_WARN
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_WARN
|
||||
#elif CONFIG_LOG_DEFAULT_LEVEL_INFO
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_INFO
|
||||
#elif CONFIG_LOG_DEFAULT_LEVEL_DEBUG
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
|
||||
#elif CONFIG_LOG_DEFAULT_LEVEL_VERBOSE
|
||||
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define OPENTHREAD_CONFIG_LOG_API 1
|
||||
#define OPENTHREAD_CONFIG_LOG_ARP 1
|
||||
#define OPENTHREAD_CONFIG_LOG_BBR 1
|
||||
#define OPENTHREAD_CONFIG_LOG_CLI 1
|
||||
#define OPENTHREAD_CONFIG_LOG_COAP 1
|
||||
#define OPENTHREAD_CONFIG_LOG_DUA 1
|
||||
#define OPENTHREAD_CONFIG_LOG_ICMP 1
|
||||
#define OPENTHREAD_CONFIG_LOG_IP6 1
|
||||
#define OPENTHREAD_CONFIG_LOG_MAC 1
|
||||
#define OPENTHREAD_CONFIG_LOG_MEM 1
|
||||
#define OPENTHREAD_CONFIG_LOG_MESHCOP 1
|
||||
#define OPENTHREAD_CONFIG_LOG_MLE 1
|
||||
#define OPENTHREAD_CONFIG_LOG_MLR 1
|
||||
#define OPENTHREAD_CONFIG_LOG_NETDATA 1
|
||||
#define OPENTHREAD_CONFIG_LOG_NETDIAG 1
|
||||
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
|
||||
#define OPENTHREAD_CONFIG_LOG_PLATFORM 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
|
||||
*
|
||||
* The number of message buffers in buffer pool
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 50
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_COAP_API_ENABLE
|
||||
*
|
||||
* Define to 1 to enable the CoAP API.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE
|
||||
*
|
||||
* Define to 1 to enable Border Router support.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE
|
||||
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
*
|
||||
* Define to 1 to enable Thread Test Harness reference device support.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
*
|
||||
* Define to 1 to enable Child Supervision support.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
#define OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE
|
||||
*
|
||||
* Define to 1 to enable DHCPv6 Client support.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE
|
||||
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
|
||||
*
|
||||
* Define to 1 to enable DHCPv6 Server support.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
|
||||
#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
*
|
||||
* Define to 1 to enable DNS Client support.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_NCP_SPI_ENABLE
|
||||
*
|
||||
* Define to 1 to enable NCP SPI support.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_NCP_SPI_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
*
|
||||
* Define to 1 to enable NCP Spinel Encrypter.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_NCP_HDLC_ENABLE
|
||||
*
|
||||
* Define to 1 to enable NCP HDLC support.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE
|
||||
*
|
||||
* Define 1 to enable feeding an OpenThread message to encoder/decoder.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
|
||||
*
|
||||
* Define to 1 to support injecting Service entries into the Thread Network Data.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def PACKAGE_NAME
|
||||
*
|
||||
* Define to the full name of this package.
|
||||
*
|
||||
*/
|
||||
#define PACKAGE_NAME "openthread-esp32"
|
||||
|
||||
/**
|
||||
* @def PACKAGE_STRING
|
||||
*
|
||||
* Define to the full name and version of this package.
|
||||
*
|
||||
*/
|
||||
#define PACKAGE_STRING (PACKAGE_NAME " - " PACKAGE_VERSION)
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS
|
||||
*
|
||||
* Define as 1 to enable bultin-mbedtls.
|
||||
*
|
||||
* Note that the OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS determines whether to use bultin-mbedtls as well as
|
||||
* whether to manage mbedTLS internally, such as memory allocation and debug.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
|
||||
*
|
||||
* Define as 1 to enable support for adding of auto-configured SLAAC addresses by OpenThread.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS
|
||||
*
|
||||
* The maximum number of state-changed callback handlers (set using `otSetStateChangedCallback()`).
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 3
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE
|
||||
*
|
||||
* Specifies the rx frame buffer size used by `SpinelInterface` in RCP host code. This is applicable/used when
|
||||
* `RadioSpinel` platform is used.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE 1024
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
|
||||
*
|
||||
* Define as 1 to enable microsecond timer.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
|
||||
*
|
||||
* Define to 1 to enable software CSMA-CA backoff logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
|
||||
*
|
||||
* Define to 1 to enable software retransmission logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
|
||||
*
|
||||
* Define to 1 to enable software transmission security logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE
|
||||
*
|
||||
* Define to 1 to enable software transmission target time logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE 1
|
||||
|
||||
/**
|
||||
* The configurable definitions via Kconfig
|
||||
*/
|
||||
#if CONFIG_OPENTHREAD_COMMISSIONER
|
||||
#error "Commissioner shouldn't be enabled for RCP"
|
||||
#endif
|
||||
|
||||
#if CONFIG_OPENTHREAD_JOINER
|
||||
#error "Joiner shouldn't be enabled for RCP"
|
||||
#endif
|
||||
|
||||
#if CONFIG_OPENTHREAD_DIAG
|
||||
#define OPENTHREAD_CONFIG_DIAG_ENABLE 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_OPENTHREAD_FTD
|
||||
#error "Only OPENTHREAD_RADIO is used for RCP"
|
||||
#elif CONFIG_OPENTHREAD_MTD
|
||||
#error "Only OPENTHREAD_RADIO is used for RCP"
|
||||
#elif CONFIG_OPENTHREAD_RADIO
|
||||
#define OPENTHREAD_RADIO 1
|
||||
#endif
|
78
components/openthread/radio.cmake
Normal file
78
components/openthread/radio.cmake
Normal file
@ -0,0 +1,78 @@
|
||||
set(public_include_dirs
|
||||
"include"
|
||||
"openthread/include")
|
||||
|
||||
set(private_include_dirs
|
||||
"openthread/examples/platforms"
|
||||
"openthread/include/openthread"
|
||||
"openthread/src"
|
||||
"openthread/src/core"
|
||||
"openthread/src/lib/hdlc"
|
||||
"openthread/src/lib/spinel"
|
||||
"openthread/src/ncp"
|
||||
"private_include"
|
||||
)
|
||||
|
||||
set(src_dirs
|
||||
"openthread/examples/platforms/utils"
|
||||
"openthread/src/core/api"
|
||||
"openthread/src/core/common"
|
||||
"openthread/src/core/crypto"
|
||||
"openthread/src/core/diags"
|
||||
"openthread/src/core/mac"
|
||||
"openthread/src/core/radio"
|
||||
"openthread/src/core/thread"
|
||||
"openthread/src/core/utils"
|
||||
"openthread/src/lib/hdlc"
|
||||
"openthread/src/lib/spinel"
|
||||
"openthread/src/ncp"
|
||||
"openthread/examples/apps/ncp")
|
||||
|
||||
set(exclude_srcs
|
||||
"openthread/examples/platforms/utils/logging_rtt.c"
|
||||
"openthread/examples/platforms/utils/soft_source_match_table.c"
|
||||
"openthread/examples/apps/ncp/main.c"
|
||||
"openthread/src/core/api/backbone_router_api.cpp"
|
||||
"openthread/src/core/api/entropy_api.cpp"
|
||||
"openthread/src/core/api/netdata_api.cpp"
|
||||
"openthread/src/core/api/link_api.cpp"
|
||||
"openthread/src/core/api/icmp6_api.cpp"
|
||||
"openthread/src/core/api/ip6_api.cpp"
|
||||
"openthread/src/core/api/udp_api.cpp"
|
||||
"openthread/src/core/common/settings.cpp"
|
||||
"openthread/src/core/api/dataset_api.cpp"
|
||||
"openthread/src/core/api/random_crypto_api.cpp"
|
||||
"openthread/src/core/common/extension_example.cpp"
|
||||
"openthread/src/core/common/heap_string.cpp"
|
||||
"openthread/src/core/common/time_ticker.cpp"
|
||||
"openthread/src/core/common/notifier.cpp"
|
||||
"openthread/src/core/api/message_api.cpp"
|
||||
"openthread/src/core/thread/energy_scan_server.cpp"
|
||||
"openthread/src/core/thread/mesh_forwarder.cpp"
|
||||
"openthread/src/core/thread/mle.cpp"
|
||||
"openthread/src/core/thread/neighbor_table.cpp"
|
||||
"openthread/src/core/thread/tmf.cpp"
|
||||
"openthread/src/core/thread/network_data_leader_ftd.cpp"
|
||||
"openthread/src/core/thread/discover_scanner.cpp"
|
||||
"openthread/src/core/thread/lowpan.cpp"
|
||||
"openthread/src/core/thread/network_data_leader.cpp"
|
||||
"openthread/src/core/thread/mesh_forwarder_mtd.cpp"
|
||||
"openthread/src/core/thread/key_manager.cpp"
|
||||
"openthread/src/core/thread/network_data_types.cpp"
|
||||
"openthread/src/core/thread/mesh_forwarder_ftd.cpp"
|
||||
"openthread/src/core/thread/network_data.cpp"
|
||||
"openthread/src/core/thread/network_data_service.cpp"
|
||||
"openthread/src/core/thread/announce_begin_server.cpp"
|
||||
"openthread/src/core/thread/announce_sender.cpp"
|
||||
"openthread/src/core/thread/thread_netif.cpp"
|
||||
"openthread/src/core/thread/topology.cpp"
|
||||
"openthread/src/core/thread/panid_query_server.cpp"
|
||||
"openthread/src/core/mac/channel_mask.cpp"
|
||||
"openthread/src/core/mac/data_poll_handler.cpp"
|
||||
"openthread/src/core/mac/data_poll_sender.cpp"
|
||||
"openthread/src/core/mac/mac.cpp"
|
||||
"openthread/src/core/mac/mac_filter.cpp"
|
||||
"openthread/src/core/mac/mac_links.cpp"
|
||||
"openthread/src/core/utils/child_supervision.cpp")
|
||||
|
||||
set(device_type "OPENTHREAD_RADIO=1")
|
@ -158,7 +158,6 @@ INPUT = \
|
||||
$(PROJECT_PATH)/components/openthread/include/esp_openthread_lock.h \
|
||||
$(PROJECT_PATH)/components/openthread/include/esp_openthread_netif_glue.h \
|
||||
$(PROJECT_PATH)/components/openthread/include/esp_openthread_types.h \
|
||||
$(PROJECT_PATH)/components/openthread/include/openthread-core-esp32x-config.h \
|
||||
$(PROJECT_PATH)/components/vfs/include/esp_vfs.h \
|
||||
$(PROJECT_PATH)/components/vfs/include/esp_vfs_dev.h \
|
||||
$(PROJECT_PATH)/components/vfs/include/esp_vfs_eventfd.h \
|
||||
|
@ -12,7 +12,8 @@ Application Examples
|
||||
The :example:`openthread` directory of ESP-IDF examples contains the following applications:
|
||||
|
||||
- The OpenThread interactive shell :example:`openthread/ot_cli`.
|
||||
- The Thread border router :example:`openthread/ot_cli`.
|
||||
- The Thread border router :example:`openthread/ot_br`.
|
||||
- The Thread radio co-processor :example:`openthread/ot_rcp`.
|
||||
|
||||
|
||||
API Reference
|
||||
@ -28,5 +29,3 @@ ESP-IDF provides extra apis for launching and managing the OpenThread stack, bin
|
||||
.. include-build-file:: inc/esp_openthread_lock.inc
|
||||
.. include-build-file:: inc/esp_openthread_netif_glue.inc
|
||||
.. include-build-file:: inc/esp_openthread_border_router.inc
|
||||
|
||||
|
||||
|
@ -36,24 +36,24 @@
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_UART, \
|
||||
.host_uart_config = { \
|
||||
.port = 0, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = UART_PIN_NO_CHANGE, \
|
||||
.tx_pin = UART_PIN_NO_CHANGE, \
|
||||
}, \
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_CLI_UART, \
|
||||
.host_uart_config = { \
|
||||
.port = 0, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = UART_PIN_NO_CHANGE, \
|
||||
.tx_pin = UART_PIN_NO_CHANGE, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
|
||||
|
@ -44,24 +44,24 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_UART, \
|
||||
.host_uart_config = { \
|
||||
.port = 0, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = UART_PIN_NO_CHANGE, \
|
||||
.tx_pin = UART_PIN_NO_CHANGE, \
|
||||
}, \
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_CLI_UART, \
|
||||
.host_uart_config = { \
|
||||
.port = 0, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = UART_PIN_NO_CHANGE, \
|
||||
.tx_pin = UART_PIN_NO_CHANGE, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
|
||||
|
6
examples/openthread/ot_rcp/CMakeLists.txt
Normal file
6
examples/openthread/ot_rcp/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(esp_ot_rcp)
|
8
examples/openthread/ot_rcp/Makefile
Normal file
8
examples/openthread/ot_rcp/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
|
||||
# project subdirectory.
|
||||
#
|
||||
|
||||
PROJECT_NAME := ot_esp_rcp
|
||||
|
||||
include $(IDF_PATH)/make/project.mk
|
38
examples/openthread/ot_rcp/README.md
Normal file
38
examples/openthread/ot_rcp/README.md
Normal file
@ -0,0 +1,38 @@
|
||||
| Supported Targets | ESP32-H2 |
|
||||
| ----------------- | -------- |
|
||||
|
||||
# OpenThread Radio Co-Processor (RCP) Example
|
||||
|
||||
This example demonstrates an [OpenThread Radio Co-Processor](https://openthread.io/platforms/co-processor).
|
||||
|
||||
OpenThread RCP doesn't function alone, it needs to work together with a Host and this example covers two common user scenarios:
|
||||
- Work with a Host Processor to perform a [Thread Border Router](https://openthread.io/guides/border-router).
|
||||
- Work as a [Thread Sniffer](https://openthread.io/guides/pyspinel/sniffer).
|
||||
|
||||
## How to use example
|
||||
|
||||
### Hardware Required
|
||||
|
||||
To run this example, an ESP32-H2 board is required.
|
||||
|
||||
### Configure the project
|
||||
|
||||
The default communication interface is port 0 of ESP32-H2 UART running at 115200 baud, change the configuration in [esp_ot_config.h](main/esp_ot_config.h) if you want to use another interface or need different communication parameters.
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Build the project and flash it to the board:
|
||||
|
||||
```
|
||||
idf.py -p <PORT> build flash
|
||||
```
|
||||
|
||||
Now you'll get an OpenThread RCP, you can try the following use cases:
|
||||
|
||||
#### Thread Border Router
|
||||
|
||||
Please refer to [ot_br](../ot_br) example for the setup steps.
|
||||
|
||||
#### Thread Sniffer
|
||||
|
||||
Please refer to [Thread Sniffer](https://openthread.io/guides/pyspinel/sniffer) for the detailed instructions.
|
2
examples/openthread/ot_rcp/main/CMakeLists.txt
Normal file
2
examples/openthread/ot_rcp/main/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "esp_ot_rcp.c"
|
||||
INCLUDE_DIRS ".")
|
48
examples/openthread/ot_rcp/main/esp_ot_config.h
Normal file
48
examples/openthread/ot_rcp/main/esp_ot_config.h
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) CO LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_openthread_types.h"
|
||||
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_NATIVE, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_RCP_UART, \
|
||||
.host_uart_config = { \
|
||||
.port = 0, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = UART_PIN_NO_CHANGE, \
|
||||
.tx_pin = UART_PIN_NO_CHANGE, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
|
||||
{ \
|
||||
.storage_partition_name = "ot_storage", \
|
||||
.netif_queue_size = 10, \
|
||||
.task_queue_size = 10, \
|
||||
}
|
66
examples/openthread/ot_rcp/main/esp_ot_rcp.c
Normal file
66
examples/openthread/ot_rcp/main/esp_ot_rcp.c
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "esp_event.h"
|
||||
#include "esp_openthread.h"
|
||||
#include "esp_ot_config.h"
|
||||
#include "esp_vfs_eventfd.h"
|
||||
#include "driver/uart.h"
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32H2
|
||||
#error "RCP is only supported for esp32h2"
|
||||
#endif
|
||||
|
||||
#define TAG "ot_esp_rcp"
|
||||
|
||||
extern void otAppNcpInit(otInstance *instance);
|
||||
|
||||
static void ot_task_worker(void *aContext)
|
||||
{
|
||||
esp_openthread_platform_config_t config = {
|
||||
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
|
||||
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
|
||||
};
|
||||
|
||||
// Initialize the OpenThread stack
|
||||
ESP_ERROR_CHECK(esp_openthread_init(&config));
|
||||
|
||||
// Initialize the OpenThread ncp
|
||||
otAppNcpInit(esp_openthread_get_instance());
|
||||
|
||||
// Run the main loop
|
||||
esp_openthread_launch_mainloop();
|
||||
|
||||
// Clean up
|
||||
esp_vfs_eventfd_unregister();
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
// Used eventfds:
|
||||
// * ot task queue
|
||||
// * radio driver
|
||||
esp_vfs_eventfd_config_t eventfd_config = {
|
||||
.max_fds = 2,
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
|
||||
xTaskCreate(ot_task_worker, "ot_rcp_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);
|
||||
}
|
6
examples/openthread/ot_rcp/partitions.csv
Normal file
6
examples/openthread/ot_rcp/partitions.csv
Normal file
@ -0,0 +1,6 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 1M,
|
||||
ot_storage, data, 0x3a, , 0x2000,
|
|
48
examples/openthread/ot_rcp/sdkconfig.defaults
Normal file
48
examples/openthread/ot_rcp/sdkconfig.defaults
Normal file
@ -0,0 +1,48 @@
|
||||
CONFIG_IDF_TARGET="esp32h2"
|
||||
#
|
||||
# libsodium
|
||||
#
|
||||
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
# end of libsodium
|
||||
|
||||
#
|
||||
# Partition Table
|
||||
#
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
CONFIG_PARTITION_TABLE_MD5=y
|
||||
# end of Partition Table
|
||||
|
||||
#
|
||||
# mbedTLS
|
||||
#
|
||||
|
||||
CONFIG_MBEDTLS_CMAC_C=y
|
||||
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
# end of TLS Key Exchange Methods
|
||||
|
||||
CONFIG_MBEDTLS_ECJPAKE_C=y
|
||||
# end of mbedTLS
|
||||
|
||||
#
|
||||
# OpenThread
|
||||
#
|
||||
CONFIG_OPENTHREAD_ENABLED=y
|
||||
CONFIG_OPENTHREAD_RADIO=y
|
||||
CONFIG_OPENTHREAD_DIAG=y
|
||||
CONFIG_OPENTHREAD_COMMISSIONER=n
|
||||
CONFIG_OPENTHREAD_JOINER=n
|
||||
CONFIG_OPENTHREAD_BORDER_ROUTER=n
|
||||
CONFIG_OPENTHREAD_ESP_LIB_FROM_INTERNAL_SRC=n
|
||||
# end of OpenThread
|
||||
|
||||
|
||||
#
|
||||
# Deprecated options for backward compatibility
|
||||
#
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_ERROR=y
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=n
|
||||
# End of deprecated options
|
Loading…
Reference in New Issue
Block a user