Add reboot command and late terminal activation
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "esp_console.h"
|
||||
#include "linenoise/linenoise.h"
|
||||
@@ -109,6 +110,22 @@ static const char *const s_completion_candidates[] = {
|
||||
"wifi traceroute",
|
||||
};
|
||||
|
||||
static ssize_t console_read_with_late_terminal_upgrade(int file_descriptor,
|
||||
void *buffer,
|
||||
size_t size)
|
||||
{
|
||||
ssize_t received = read(file_descriptor, buffer, size);
|
||||
if (received > 0 && linenoiseIsDumbMode()) {
|
||||
/*
|
||||
* The current line remains in the safe dumb reader. The next call to
|
||||
* linenoise() starts enhanced mode only after a terminal has proven it
|
||||
* can send data, so its cursor-position query cannot block unattended.
|
||||
*/
|
||||
linenoiseSetDumbMode(0);
|
||||
}
|
||||
return received;
|
||||
}
|
||||
|
||||
static void console_completion_callback(const char *buffer, linenoiseCompletions *completions)
|
||||
{
|
||||
/* Preserve ESP-IDF completion for registered root command names. */
|
||||
@@ -134,5 +151,7 @@ static void console_completion_callback(const char *buffer, linenoiseCompletions
|
||||
|
||||
void console_completion_install(void)
|
||||
{
|
||||
/* Preserve ESP-IDF's safe boot-time mode until actual UART input arrives. */
|
||||
linenoiseSetReadFunction(&console_read_with_late_terminal_upgrade);
|
||||
linenoiseSetCompletionCallback(&console_completion_callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user