feat(openthread): add ot_console_stop to deinit OT console

This commit is contained in:
Tan Yan Quan
2026-02-06 20:18:11 +08:00
parent 2343653af2
commit cc4f020278
2 changed files with 13 additions and 2 deletions
@@ -56,6 +56,12 @@ void ot_external_coexist_init(void);
*/ */
void ot_console_start(void); void ot_console_start(void);
/**
* @brief De-initializes the console.
*
*/
void ot_console_stop(void);
/** /**
* @brief Form or join the Thread network automatically. * @brief Form or join the Thread network automatically.
* *
@@ -22,9 +22,10 @@
#include "iperf_cmd.h" #include "iperf_cmd.h"
#endif #endif
static esp_console_repl_t *repl = NULL;
void ot_console_start(void) void ot_console_start(void)
{ {
esp_console_repl_t *repl = NULL;
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
/* Prompt to be printed before each line. /* Prompt to be printed before each line.
* This can be customized, made dynamic, etc. * This can be customized, made dynamic, etc.
@@ -39,7 +40,6 @@ void ot_console_start(void)
#elif defined(CONFIG_ESP_CONSOLE_USB_CDC) #elif defined(CONFIG_ESP_CONSOLE_USB_CDC)
esp_console_dev_usb_cdc_config_t hw_config = ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT(); esp_console_dev_usb_cdc_config_t hw_config = ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_console_new_repl_usb_cdc(&hw_config, &repl_config, &repl)); ESP_ERROR_CHECK(esp_console_new_repl_usb_cdc(&hw_config, &repl_config, &repl));
#elif defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) #elif defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG)
esp_console_dev_usb_serial_jtag_config_t hw_config = ESP_CONSOLE_DEV_USB_SERIAL_JTAG_CONFIG_DEFAULT(); esp_console_dev_usb_serial_jtag_config_t hw_config = ESP_CONSOLE_DEV_USB_SERIAL_JTAG_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_console_new_repl_usb_serial_jtag(&hw_config, &repl_config, &repl)); ESP_ERROR_CHECK(esp_console_new_repl_usb_serial_jtag(&hw_config, &repl_config, &repl));
@@ -49,6 +49,11 @@ void ot_console_start(void)
ESP_ERROR_CHECK(esp_console_start_repl(repl)); ESP_ERROR_CHECK(esp_console_start_repl(repl));
} }
void ot_console_stop(void)
{
ESP_ERROR_CHECK(esp_console_stop_repl(repl)); // this does esp_console_repl_usb_serial_xxxx_delete
}
void ot_register_external_commands(void) void ot_register_external_commands(void)
{ {
register_system(); register_system();