Merge branch 'feature/ot-esp-console' into 'master'

openthread: Use esp console for CLI

See merge request espressif/esp-idf!15365
This commit is contained in:
Shu Chen 2021-10-19 09:38:40 +00:00
commit dc19bd4e5a
6 changed files with 55 additions and 13 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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,

1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
3 nvs, data, nvs, 0x9000, 0x6000,
4 phy_init, data, phy, 0xf000, 0x1000,
5 factory, app, factory, 0x10000, 1200K, factory, app, factory, 0x10000, 1400K,
6 ot_storage, data, 0x3a, , 0x2000,

View File

@ -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

View File

@ -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