Просмотр исходного кода

br: support Thread Radio Encapsulation Link (TREL)

TREL allows sending 15.4 frames on the backbone link by encapsulating it
in an UDP packet.
Jiacheng Guo 4 лет назад
Родитель
Сommit
1e5c5f38d9

+ 7 - 0
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

+ 16 - 16
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.

+ 16 - 21
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;
 
 /**

+ 10 - 0
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
 
 /**

+ 3 - 2
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_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(get_example_netif()));
+    ESP_ERROR_CHECK(esp_openthread_border_router_init());
 
-    esp_openthread_lock_acquire(portMAX_DELAY);
     (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL);
     esp_openthread_cli_init();
     create_config_network(esp_openthread_get_instance());

+ 2 - 0
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
 
 #

+ 0 - 2
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