diff --git a/components/openthread/CMakeLists.txt b/components/openthread/CMakeLists.txt index f726c4af7a..182f9fcce8 100644 --- a/components/openthread/CMakeLists.txt +++ b/components/openthread/CMakeLists.txt @@ -31,7 +31,7 @@ idf_component_register(SRC_DIRS "${src_dirs}" EXCLUDE_SRCS "${exclude_srcs}" INCLUDE_DIRS "${public_include_dirs}" PRIV_INCLUDE_DIRS "${private_include_dirs}" - REQUIRES mbedtls ieee802154) + REQUIRES mbedtls ieee802154 console) if(CONFIG_OPENTHREAD_ENABLED) if(CONFIG_OPENTHREAD_RADIO) diff --git a/components/openthread/include/esp_openthread_cli.h b/components/openthread/include/esp_openthread_cli.h new file mode 100644 index 0000000000..afc1df9ea1 --- /dev/null +++ b/components/openthread/include/esp_openthread_cli.h @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_openthread.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief This function initializes the OpenThread command line interface(CLI). + * + */ +void esp_openthread_cli_init(void); + +/** + * @brief This function feeds a line to the OpenThread CLI. + * + * @note This function is thread-safe, the line will be copied and posted to + * the OpenThread task queue. + * + * @param[in] line The input line. + * + * @return + * - ESP_OK on success + * - ESP_ERR_NO_MEM if allocation has failed + * + */ +esp_err_t esp_openthread_cli_input(const char *line); + +/** + * @brief This function launches an exclusive loop for the OpenThread CLI. + * + * @param[in] priority The priority of the created task. + * + */ +void esp_openthread_cli_create_task(void); + + +#ifdef __cplusplus +} +#endif diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index 6111039558..c92f633065 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -19,6 +19,7 @@ #include "esp_netif_net_stack.h" #include "esp_openthread.h" #include "esp_openthread_border_router.h" +#include "esp_openthread_cli.h" #include "esp_openthread_lock.h" #include "esp_openthread_netif_glue.h" #include "esp_openthread_types.h" @@ -49,8 +50,6 @@ #define TAG "esp_ot_br" -extern void otAppCliInit(otInstance *aInstance); - static int hex_digit_to_int(char hex) { if ('A' <= hex && hex <= 'F') { @@ -170,12 +169,13 @@ static void ot_task_worker(void *aContext) esp_openthread_lock_acquire(portMAX_DELAY); (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); - otAppCliInit(esp_openthread_get_instance()); + esp_openthread_cli_init(); create_config_network(esp_openthread_get_instance()); launch_openthread_network(esp_openthread_get_instance()); esp_openthread_lock_release(); // Run the main loop + esp_openthread_cli_create_task(); esp_openthread_launch_mainloop(); // Clean up diff --git a/examples/openthread/ot_br/partitions.csv b/examples/openthread/ot_br/partitions.csv index ded8c6adfd..084c4662e2 100644 --- a/examples/openthread/ot_br/partitions.csv +++ b/examples/openthread/ot_br/partitions.csv @@ -2,5 +2,5 @@ # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap nvs, data, nvs, 0x9000, 0x6000, phy_init, data, phy, 0xf000, 0x1000, -factory, app, factory, 0x10000, 1200K, +factory, app, factory, 0x10000, 1400K, ot_storage, data, 0x3a, , 0x2000, diff --git a/examples/openthread/ot_cli/main/esp_ot_cli.c b/examples/openthread/ot_cli/main/esp_ot_cli.c index 5bee92058e..7fd86945ec 100644 --- a/examples/openthread/ot_cli/main/esp_ot_cli.c +++ b/examples/openthread/ot_cli/main/esp_ot_cli.c @@ -1,8 +1,3 @@ -/* - * 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.) @@ -21,6 +16,7 @@ #include "esp_netif.h" #include "esp_netif_types.h" #include "esp_openthread.h" +#include "esp_openthread_cli.h" #include "esp_openthread_lock.h" #include "esp_openthread_netif_glue.h" #include "esp_openthread_types.h" @@ -42,8 +38,6 @@ #define TAG "ot_esp_cli" -extern void otAppCliInit(otInstance *aInstance); - #if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t *config) { @@ -70,7 +64,7 @@ static void ot_task_worker(void *aContext) // The OpenThread log level directly matches ESP log level (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); // Initialize the OpenThread cli - otAppCliInit(esp_openthread_get_instance()); + esp_openthread_cli_init(); #if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION esp_netif_t *openthread_netif; @@ -81,6 +75,7 @@ static void ot_task_worker(void *aContext) #endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION // Run the main loop + esp_openthread_cli_create_task(); esp_openthread_launch_mainloop(); // Clean up diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 087b8d93fb..54abd3501c 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -3525,6 +3525,8 @@ examples/network/simple_sniffer/main/cmd_sniffer.h examples/network/simple_sniffer/main/simple_sniffer_example_main.c examples/openthread/ot_br/main/esp_ot_br.c examples/openthread/ot_br/main/esp_ot_config.h +examples/openthread/ot_cli/main/esp_ot_cli.c +examples/openthread/ot_cli/main/esp_ot_config.h examples/openthread/ot_rcp/main/esp_ot_config.h examples/openthread/ot_rcp/main/esp_ot_rcp.c examples/peripherals/adc/esp32c3/adc/main/adc_dma_example_main.c