From a271753a6afc6e028034e363a009f641ef279658 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Tue, 4 Jan 2022 19:14:12 +0800 Subject: [PATCH] openthread: enable 1.2 multicast routing This MR enables Thread 1.2 Backbone Border Router(BBR) feature and multicast routing. --- components/openthread/lib | 2 +- components/openthread/openthread | 2 +- .../openthread-core-esp32x-ftd-config.h | 32 ++++++++++++++++++- examples/openthread/ot_br/main/esp_ot_br.c | 12 +++---- examples/openthread/ot_br/sdkconfig.defaults | 1 + 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/components/openthread/lib b/components/openthread/lib index ed7eace382..901353a8c1 160000 --- a/components/openthread/lib +++ b/components/openthread/lib @@ -1 +1 @@ -Subproject commit ed7eace382134d0ac6fb2b33650895d8d0e547af +Subproject commit 901353a8c17d5c3040b3850d571550b0472b921b diff --git a/components/openthread/openthread b/components/openthread/openthread index 3726888937..e736d2488d 160000 --- a/components/openthread/openthread +++ b/components/openthread/openthread @@ -1 +1 @@ -Subproject commit 37268889370467c5e48e306d322472d6910ebb13 +Subproject commit e736d2488d9d4f787650d81f2b84f59a194f2b41 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 979b7cdb86..772f6d2df8 100644 --- a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -204,6 +204,16 @@ #define OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE CONFIG_OPENTHREAD_TREL #endif +/** + * @def OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + * + * Define to 1 to enable Backbone Router support. + * + */ +#ifndef OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE +#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 1 +#endif + #endif // CONFIG_OPENTHREAD_BORDER_ROUTER /** @@ -356,6 +366,26 @@ */ #define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1 +/** + * @def OPENTHREAD_CONFIG_DUA_ENABLE + * + * Define as 1 to support Thread 1.2 Domain Unicast Address feature. + * + */ +#ifndef OPENTHREAD_CONFIG_DUA_ENABLE +#define OPENTHREAD_CONFIG_DUA_ENABLE 0 +#endif + +/** + * @def OPENTHREAD_CONFIG_MLR_ENABLE + * + * Define as 1 to support Thread 1.2 Multicast Listener Registration feature. + * + */ +#ifndef OPENTHREAD_CONFIG_MLR_ENABLE +#define OPENTHREAD_CONFIG_MLR_ENABLE 1 +#endif + /** * @def OPENTHREAD_CONFIG_DTLS_MAX_CONTENT_LEN * diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index 033aa08dbd..3c975d8a35 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -37,9 +37,9 @@ #include "sdkconfig.h" #include "driver/uart.h" #include "freertos/FreeRTOS.h" -#include "freertos/portmacro.h" #include "freertos/task.h" #include "hal/uart_types.h" +#include "openthread/backbone_router_ftd.h" #include "openthread/border_router.h" #include "openthread/cli.h" #include "openthread/dataset.h" @@ -50,7 +50,6 @@ #include "openthread/ip6.h" #include "openthread/logging.h" #include "openthread/tasklet.h" -#include "openthread/thread.h" #include "openthread/thread_ftd.h" #include "esp_ot_wifi_cmd.h" #include "esp_ot_cli_extension.h" @@ -137,10 +136,6 @@ static void create_config_network(otInstance *instance) ESP_LOGE(TAG, "Failed to set OpenThread active dataset."); abort(); } - if (otBorderRouterRegister(instance) != OT_ERROR_NONE) { - ESP_LOGE(TAG, "Failed to register border router."); - abort(); - } return; } @@ -154,6 +149,11 @@ static void launch_openthread_network(otInstance *instance) ESP_LOGE(TAG, "Failed to enable OpenThread"); abort(); } + if (otBorderRouterRegister(instance) != OT_ERROR_NONE) { + ESP_LOGE(TAG, "Failed to register border router."); + abort(); + } + otBackboneRouterSetEnabled(instance, true); } #endif // CONFIG_OPENTHREAD_BR_AUTO_START diff --git a/examples/openthread/ot_br/sdkconfig.defaults b/examples/openthread/ot_br/sdkconfig.defaults index 091805179f..4f9d52487a 100644 --- a/examples/openthread/ot_br/sdkconfig.defaults +++ b/examples/openthread/ot_br/sdkconfig.defaults @@ -43,6 +43,7 @@ CONFIG_LWIP_MULTICAST_PING=y CONFIG_LWIP_NETIF_STATUS_CALLBACK=y CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y +CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM=y # end of lwIP #