mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-24 17:27:21 +00:00
console_repl: change config structure to support different devices
This commit is contained in:
@@ -75,7 +75,7 @@ static struct {
|
||||
struct arg_int *tos;
|
||||
struct arg_str *host;
|
||||
struct arg_end *end;
|
||||
} ping_args;;
|
||||
} ping_args;
|
||||
|
||||
static int do_ping_cmd(int argc, char **argv)
|
||||
{
|
||||
@@ -161,6 +161,26 @@ static void register_ping(void)
|
||||
ESP_ERROR_CHECK(esp_console_cmd_register(&ping_cmd));
|
||||
}
|
||||
|
||||
static esp_console_repl_t *s_repl = NULL;
|
||||
|
||||
/* handle 'quit' command */
|
||||
static int do_cmd_quit(int argc, char **argv)
|
||||
{
|
||||
printf("ByeBye\r\n");
|
||||
s_repl->del(s_repl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static esp_err_t register_quit(void)
|
||||
{
|
||||
esp_console_cmd_t command = {
|
||||
.command = "quit",
|
||||
.help = "Quit REPL environment",
|
||||
.func = &do_cmd_quit
|
||||
};
|
||||
return esp_console_cmd_register(&command);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
@@ -170,12 +190,15 @@ void app_main(void)
|
||||
ESP_ERROR_CHECK(example_connect());
|
||||
|
||||
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
|
||||
esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
|
||||
// init console REPL environment
|
||||
ESP_ERROR_CHECK(esp_console_repl_init(&repl_config));
|
||||
ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &s_repl));
|
||||
|
||||
/* register command `ping` */
|
||||
register_ping();
|
||||
/* register command `quit` */
|
||||
register_quit();
|
||||
|
||||
// start console REPL
|
||||
ESP_ERROR_CHECK(esp_console_repl_start());
|
||||
ESP_ERROR_CHECK(esp_console_start_repl(s_repl));
|
||||
}
|
||||
|
Reference in New Issue
Block a user