openthread : support MTD

This commit is contained in:
zhangwenxu 2021-11-18 11:40:22 +08:00
parent ec9b69d7e3
commit f3fc4deade
6 changed files with 353 additions and 231 deletions

View File

@ -1,8 +1,110 @@
if(CONFIG_OPENTHREAD_ENABLED)
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")
set(exclude_srcs
"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_FTD OR CONFIG_OPENTHREAD_MTD)
list(APPEND src_dirs
"openthread/examples/apps/cli"
"openthread/src/core/backbone_router"
"openthread/src/core/coap"
"openthread/src/core/meshcop"
"openthread/src/core/net"
"openthread/src/cli"
"openthread/src/lib/platform")
list(APPEND exclude_srcs
"openthread/examples/apps/cli/main.c")
elseif(CONFIG_OPENTHREAD_RADIO)
list(APPEND src_dirs
"openthread/src/ncp"
"openthread/examples/apps/ncp")
list(APPEND exclude_srcs
"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/heap_string.cpp"
"openthread/src/core/common/time_ticker.cpp"
"openthread/src/core/common/notifier.cpp"
"openthread/src/core/api/dns_api.cpp"
"openthread/src/core/api/message_api.cpp"
"openthread/src/core/api/tcp_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")
endif()
if(CONFIG_OPENTHREAD_BORDER_ROUTER)
list(APPEND src_dirs
"openthread/src/core/border_router")
endif()
if(CONFIG_OPENTHREAD_FTD)
include(ftd.cmake)
else()
include(radio.cmake)
set_source_files_properties("openthread/src/core/net/srp_server.cpp"
PROPERTIES COMPILE_FLAGS
-Wno-maybe-uninitialized)
endif()
if(CONFIG_OPENTHREAD_FTD)
@ -36,8 +138,10 @@ idf_component_register(SRC_DIRS "${src_dirs}"
if(CONFIG_OPENTHREAD_ENABLED)
if(CONFIG_OPENTHREAD_RADIO)
set(CONFIG_FILE_TYPE "radio")
else()
elseif(CONFIG_OPENTHREAD_FTD)
set(CONFIG_FILE_TYPE "ftd")
elseif(CONFIG_OPENTHREAD_MTD)
set(CONFIG_FILE_TYPE "mtd")
endif()
target_compile_definitions(

View File

@ -1,53 +0,0 @@
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()

View File

@ -393,10 +393,4 @@
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 1
#if CONFIG_OPENTHREAD_FTD
#define OPENTHREAD_FTD 1
#elif CONFIG_OPENTHREAD_MTD
#define OPENTHREAD_MTD 1
#elif CONFIG_OPENTHREAD_RADIO
#define OPENTHREAD_RADIO 1
#endif

View File

@ -0,0 +1,245 @@
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#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.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
/**
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
*
* Define as 1 to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#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 CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS
/**
* @def OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
*
* Enable the external heap.
*
*/
#ifndef OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_TCP_ENABLE
*
* Define to 0 to disable TCP
*
*/
#ifndef OPENTHREAD_CONFIG_TCP_ENABLE
#define OPENTHREAD_CONFIG_TCP_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 1
/**
* @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 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 1
/**
* @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_PING_SENDER_ENABLE
*
* Define to 1 to enable ping sender module.
*
* Ping sender module implements sending ICMPv6 Echo Request messages and processing ICMPv6 Echo Reply messages.
*
*/
#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN
*
* The max length of the OpenThread dtls content buffer.
*
*/
#ifndef OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN
#define OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN 768
#endif
/**
* The configurable definitions via Kconfig
*/
#if CONFIG_OPENTHREAD_COMMISSIONER
#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 0
#endif
#if CONFIG_OPENTHREAD_JOINER
#define OPENTHREAD_CONFIG_JOINER_ENABLE 0
#endif
#if CONFIG_OPENTHREAD_DIAG
#define OPENTHREAD_CONFIG_DIAG_ENABLE 1
#endif
#if CONFIG_OPENTHREAD_SRP_CLIENT
#ifndef OPENTHREAD_CONFIG_ECDSA_ENABLE
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#endif
#ifndef OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1
#endif
#endif
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 1
#define OPENTHREAD_MTD 1

View File

@ -88,24 +88,6 @@
*/
#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
*
@ -114,46 +96,6 @@
*/
#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
*
@ -178,22 +120,6 @@
*/
#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
*
@ -221,14 +147,6 @@
*/
#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
*
@ -303,10 +221,4 @@
#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

View File

@ -1,80 +0,0 @@
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/dns_api.cpp"
"openthread/src/core/api/message_api.cpp"
"openthread/src/core/api/tcp_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")