From b7fd68c4380991305d266e521037f50c5c17a8b1 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Thu, 23 Sep 2021 17:23:38 +0800 Subject: [PATCH] openthread: reduce default log verbosity Packet logging increases latency and packet drop rate significantly. --- components/ieee802154/lib | 2 +- components/openthread/lib | 2 +- .../openthread-core-esp32x-ftd-config.h | 40 ++++++------------- .../openthread-core-esp32x-radio-config.h | 22 ++++------ examples/openthread/ot_br/main/esp_ot_br.c | 2 + examples/openthread/ot_cli/main/esp_ot_cli.c | 8 ++++ tools/ci/check_copyright_ignore.txt | 2 - 7 files changed, 32 insertions(+), 46 deletions(-) diff --git a/components/ieee802154/lib b/components/ieee802154/lib index 1d3cb8b1ad..387c762a71 160000 --- a/components/ieee802154/lib +++ b/components/ieee802154/lib @@ -1 +1 @@ -Subproject commit 1d3cb8b1adfd6e338f6edd448a555bb25dfb692f +Subproject commit 387c762a711ca70a1b86d66716736f162a52ff4a diff --git a/components/openthread/lib b/components/openthread/lib index fbcc8349d3..be71bb0334 160000 --- a/components/openthread/lib +++ b/components/openthread/lib @@ -1 +1 @@ -Subproject commit fbcc8349d3914c0bf7f331cf028255fd5dc86b39 +Subproject commit be71bb03345f963ee745f5e7c7e3fcdef24bf482 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 6f0dd0fbbd..0f84664ab7 100644 --- a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-ftd-config.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 @@ -56,21 +48,15 @@ * 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 + +/** + * @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 diff --git a/components/openthread/private_include/openthread-core-esp32x-radio-config.h b/components/openthread/private_include/openthread-core-esp32x-radio-config.h index 4e5e667dd1..d5be07f5ef 100644 --- a/components/openthread/private_include/openthread-core-esp32x-radio-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-radio-config.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 @@ -63,9 +55,9 @@ #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 +#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_WARN #elif CONFIG_LOG_DEFAULT_LEVEL_DEBUG -#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG +#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_INFO #elif CONFIG_LOG_DEFAULT_LEVEL_VERBOSE #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG #endif diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index 1e667f9669..6111039558 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -42,6 +42,7 @@ #include "openthread/error.h" #include "openthread/instance.h" #include "openthread/ip6.h" +#include "openthread/logging.h" #include "openthread/tasklet.h" #include "openthread/thread.h" #include "openthread/thread_ftd.h" @@ -168,6 +169,7 @@ static void ot_task_worker(void *aContext) ESP_ERROR_CHECK(esp_openthread_border_router_init(get_example_netif())); esp_openthread_lock_acquire(portMAX_DELAY); + (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); otAppCliInit(esp_openthread_get_instance()); create_config_network(esp_openthread_get_instance()); launch_openthread_network(esp_openthread_get_instance()); diff --git a/examples/openthread/ot_cli/main/esp_ot_cli.c b/examples/openthread/ot_cli/main/esp_ot_cli.c index e771c7f634..5bee92058e 100644 --- a/examples/openthread/ot_cli/main/esp_ot_cli.c +++ b/examples/openthread/ot_cli/main/esp_ot_cli.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* OpenThread Command Line Example This example code is in the Public Domain (or CC0 licensed, at your option.) @@ -28,6 +33,7 @@ #include "hal/uart_types.h" #include "openthread/cli.h" #include "openthread/instance.h" +#include "openthread/logging.h" #include "openthread/tasklet.h" #if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION @@ -61,6 +67,8 @@ static void ot_task_worker(void *aContext) // Initialize the OpenThread stack ESP_ERROR_CHECK(esp_openthread_init(&config)); + // The OpenThread log level directly matches ESP log level + (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); // Initialize the OpenThread cli otAppCliInit(esp_openthread_get_instance()); diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index bb101de637..f62db32555 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -2108,8 +2108,6 @@ 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/openthread/private_include/openthread-core-esp32x-ftd-config.h -components/openthread/private_include/openthread-core-esp32x-radio-config.h components/partition_table/check_sizes.py components/partition_table/gen_empty_partition.py components/partition_table/gen_esp32part.py