diff --git a/components/openthread/Kconfig b/components/openthread/Kconfig index ab63e14185..50b3e30a00 100644 --- a/components/openthread/Kconfig +++ b/components/openthread/Kconfig @@ -92,6 +92,13 @@ menu "OpenThread" help Select this option to enable border router features in OpenThread. + config OPENTHREAD_TREL + bool "Enable Thread Radio Encapsulation Link" + depends on OPENTHREAD_BORDER_ROUTER + default n + help + Select this option to enable sending 15.4 frames through the backbone interface. + config OPENTHREAD_ESP_LIB_FROM_INTERNAL_SRC bool "Build esp_openthread libraries from source" depends on OPENTHREAD_ENABLED diff --git a/components/openthread/include/esp_openthread_border_router.h b/components/openthread/include/esp_openthread_border_router.h index b7df61d09a..8f77a08838 100644 --- a/components/openthread/include/esp_openthread_border_router.h +++ b/components/openthread/include/esp_openthread_border_router.h @@ -1,16 +1,8 @@ -// 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 +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -23,14 +15,22 @@ extern "C" { #endif +/** + * @brief Sets the backbone interface used for border routing. + * + * @note This function must be called before esp_openthread_init + * + * @param[in] backbone_netif The backbone network interface (WiFi or ethernet) + * + */ +void esp_openthread_set_backbone_netif(esp_netif_t *backbone_netif); + /** * @brief Initializes the border router features of OpenThread. * * @note Calling this function will make the device behave as an OpenThread * border router. Kconfig option CONFIG_OPENTHREAD_BORDER_ROUTER is required. * - * @param[in] backbone_netif The backbone network interface (WiFi or ethernet) - * * @return * - ESP_OK on success * - ESP_ERR_NOT_SUPPORTED if feature not supported @@ -38,7 +38,7 @@ extern "C" { * - ESP_FIAL on other failures * */ -esp_err_t esp_openthread_border_router_init(esp_netif_t *backbone_netif); +esp_err_t esp_openthread_border_router_init(void); /** * @brief Deinitializes the border router features of OpenThread. diff --git a/components/openthread/include/esp_openthread_types.h b/components/openthread/include/esp_openthread_types.h index 8fed9fbd0d..b5337a55af 100644 --- a/components/openthread/include/esp_openthread_types.h +++ b/components/openthread/include/esp_openthread_types.h @@ -1,16 +1,8 @@ -// 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 +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -28,14 +20,17 @@ extern "C" { * */ typedef enum { - OPENTHREAD_EVENT_START, /*!< OpenThread stack start */ - OPENTHREAD_EVENT_STOP, /*!< OpenThread stack stop */ - OPENTHREAD_EVENT_IF_UP, /*!< OpenThread network interface up */ - OPENTHREAD_EVENT_IF_DOWN, /*!< OpenThread network interface down */ - OPENTHREAD_EVENT_GOT_IP6, /*!< OpenThread stack added IPv6 address */ - OPENTHREAD_EVENT_LOST_IP6, /*!< OpenThread stack removed IPv6 address */ - OPENTHREAD_EVENT_MULTICAST_GROUP_JOIN, /*!< OpenThread stack joined IPv6 multicast group */ - OPENTHREAD_EVENT_MULTICAST_GROUP_LEAVE, /*!< OpenThread stack left IPv6 multicast group */ + OPENTHREAD_EVENT_START, /*!< OpenThread stack start */ + OPENTHREAD_EVENT_STOP, /*!< OpenThread stack stop */ + OPENTHREAD_EVENT_IF_UP, /*!< OpenThread network interface up */ + OPENTHREAD_EVENT_IF_DOWN, /*!< OpenThread network interface down */ + OPENTHREAD_EVENT_GOT_IP6, /*!< OpenThread stack added IPv6 address */ + OPENTHREAD_EVENT_LOST_IP6, /*!< OpenThread stack removed IPv6 address */ + OPENTHREAD_EVENT_MULTICAST_GROUP_JOIN, /*!< OpenThread stack joined IPv6 multicast group */ + OPENTHREAD_EVENT_MULTICAST_GROUP_LEAVE, /*!< OpenThread stack left IPv6 multicast group */ + OPENTHREAD_EVENT_TREL_ADD_IP6, /*!< OpenThread stack added TREL IPv6 address */ + OPENTHREAD_EVENT_TREL_REMOVE_IP6, /*!< OpenThread stack removed TREL IPv6 address */ + OPENTHREAD_EVENT_TREL_MULTICAST_GROUP_JOIN, /*!< OpenThread stack joined TREL IPv6 multicast group */ } esp_openthread_event_t; /** diff --git a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h index 0f84664ab7..bee73b8082 100644 --- a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h @@ -194,6 +194,16 @@ #define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 1 #endif +/** + * @def OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + * + * Set to 1 to enable support for Thread Radio Encapsulation Link (TREL). + * + */ +#ifndef OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE +#define OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE CONFIG_OPENTHREAD_TREL +#endif + #endif // CONFIG_OPENTHREAD_BORDER_ROUTER /** diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index c92f633065..beae87aa9e 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -161,13 +161,14 @@ static void ot_task_worker(void *aContext) assert(openthread_netif != NULL); // Initialize the OpenThread stack + esp_openthread_set_backbone_netif(get_example_netif()); ESP_ERROR_CHECK(esp_openthread_init(&config)); // Initialize border routing features - ESP_ERROR_CHECK(esp_netif_attach(openthread_netif, esp_openthread_netif_glue_init(&config))); - ESP_ERROR_CHECK(esp_openthread_border_router_init(get_example_netif())); - esp_openthread_lock_acquire(portMAX_DELAY); + ESP_ERROR_CHECK(esp_netif_attach(openthread_netif, esp_openthread_netif_glue_init(&config))); + ESP_ERROR_CHECK(esp_openthread_border_router_init()); + (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); esp_openthread_cli_init(); create_config_network(esp_openthread_get_instance()); diff --git a/examples/openthread/ot_br/sdkconfig.defaults b/examples/openthread/ot_br/sdkconfig.defaults index 87c25df107..091805179f 100644 --- a/examples/openthread/ot_br/sdkconfig.defaults +++ b/examples/openthread/ot_br/sdkconfig.defaults @@ -31,6 +31,7 @@ CONFIG_MBEDTLS_ECJPAKE_C=y # CONFIG_OPENTHREAD_ENABLED=y CONFIG_OPENTHREAD_BORDER_ROUTER=y +CONFIG_OPENTHREAD_TREL=y # end of OpenThread # @@ -48,6 +49,7 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y # mDNS # CONFIG_MDNS_STRICT_MODE=y +CONFIG_MDNS_MULTIPLE_INSTANCE=y # end of mDNS # diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index d157d2de9e..dec0ee5cd2 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -2052,10 +2052,8 @@ components/openssl/platform/ssl_pm.c components/openssl/platform/ssl_port.c components/openssl/test/test_openssl.c components/openthread/include/esp_openthread.h -components/openthread/include/esp_openthread_border_router.h components/openthread/include/esp_openthread_lock.h components/openthread/include/esp_openthread_netif_glue.h -components/openthread/include/esp_openthread_types.h components/partition_table/check_sizes.py components/partition_table/gen_empty_partition.py components/partition_table/gen_esp32part.py