kopia lustrzana https://github.com/espressif/esp-idf
openthread: add ot_rcp example
rodzic
f65c8249af
commit
4175aa0892
|
@ -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
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
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"
|
||||
)
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,292 @@
|
|||
// 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
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE 1
|
|
@ -1 +1 @@
|
|||
Subproject commit 105f3610d2258d7a7dd1c72f5f1adea89077c6cc
|
||||
Subproject commit 5e09d71ee4a6a8165ae4cdbabc46b79a88a95c11
|
|
@ -0,0 +1,77 @@
|
|||
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"
|
||||
)
|
||||
|
||||
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,8 @@ 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/openthread/include/openthread-core-esp32x-ftd-config.h \
|
||||
$(PROJECT_PATH)/components/openthread/include/openthread-core-esp32x-radio-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,5 @@ 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
|
||||
|
||||
.. include-build-file:: inc/openthread-core-esp32x-ftd-config.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() \
|
||||
|
|
|
@ -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)
|
|
@ -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
|
|
@ -0,0 +1,69 @@
|
|||
| Supported Targets | ESP32-H2 |
|
||||
| ----------------- | -------- |
|
||||
|
||||
# OpenThread radio co-processor (RCP) example
|
||||
|
||||
## Overview
|
||||
|
||||
This example demonstrates an openthread radio co-processor.
|
||||
The RCP can receive/transmit 15.4-type packets, encode and send the packet to the host device.
|
||||
You can use the RCP to implement an Openthread sniffer. You cani also connect the RCP to the host device which do not have a 15.4-radio to join in an Openthread network.
|
||||
|
||||
To run this example, an ESP32-H2 board is required.
|
||||
|
||||
### Config ESP32-H2 uart
|
||||
|
||||
Modify the file `esp_ot_config.h`.
|
||||
|
||||
In the file `esp_ot_config.h`, there are three parameters.
|
||||
As for `ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG` and `ESP_OPENTHREAD_DEFAULT_PORT_CONFIG`, modification is not recommended.
|
||||
As for the parameters in `ESP_OPENTHREAD_DEFAULT_HOST_CONFIG`, you can refer to ESP uart example `example/peripherals/uart/uart_echo/README.md`
|
||||
|
||||
### Build, Flash, and Run
|
||||
|
||||
Build the project and flash it to the board
|
||||
|
||||
```
|
||||
idf.py -p <PORT> build flash
|
||||
```
|
||||
|
||||
Now you'll get an ot-rcp (for this example, there is no output in console).
|
||||
|
||||
# OpenThread sniffer example (Linux or macOS based)
|
||||
|
||||
## Overview
|
||||
|
||||
This example is about how to run a sniffer to capture Thread packet, which refers to [openthread.io](https://openthread.io/guides/pyspinel/sniffer).
|
||||
Openthread group just supports Linux and macOS.
|
||||
|
||||
## How to use example
|
||||
|
||||
### Hardware connection
|
||||
|
||||
To run this example, you need an ESP32-H2 borad flashed with ot-rcp application.
|
||||
|
||||
### Set up the sniffer environment
|
||||
|
||||
The sniffer tool connects to an openthread RCP device and converts it into a promiscuous packet sniffer. RCP
|
||||
will encode and send the packet to host after capturing a 15.4-type packet. On the host, Pyspinel should be run for
|
||||
decoding the packet and generating a pcap (packet capture) stream to be saved or piped directly into Wireshark.
|
||||
|
||||
Clone and install Pyspinel and dependencies, refer to [openthread.io](https://openthread.io/guides/pyspinel/sniffer#installation).
|
||||
|
||||
### Install and config Wireshark
|
||||
|
||||
For installing the Wireshark, refer to [Espressif Wireshark User Guide](
|
||||
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wireshark-user-guide.html).
|
||||
|
||||
You need to config Wireshark with some properties for the Thread network.
|
||||
For Wireshark configuration, refer to [openthread.io](https://openthread.io/guides/pyspinel/sniffer#thread_network_properties).
|
||||
|
||||
### Run the sniffer
|
||||
|
||||
For example, to sniff on Channel 15 using a device mounted at /dev/ttyUSB0 with the baudrate 115200 in the Wireshark output:
|
||||
|
||||
```
|
||||
cd ~/pyspinel
|
||||
python sniffer.py -c 15 -u /dev/ttyUSB0 --crc -b 115200 | wireshark -k -i -
|
||||
```
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
idf_component_register(SRCS "esp_ot_rcp.c"
|
||||
INCLUDE_DIRS ".")
|
|
@ -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 = 92160, \
|
||||
.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, \
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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,
|
|
|
@ -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
|
Ładowanie…
Reference in New Issue