Console Peripheral

Console Peripheral is used to control the Audio application from the terminal screen. It provides 2 ways do execute command, one sends an event to esp_peripherals (for a command without parameters), another calls a callback function (need parameters). If there is a callback function, no event will be sent.

Please make sure that the lifetime of periph_console_cmd_t must be ensured during console operation, periph_console_init() only reference, does not make a copy.

Code example

Please refer to cli/main/console_example.c.

API Reference

Header File


esp_periph_handle_t periph_console_init(periph_console_cfg_t *config)

Initialize Console Peripheral.


The esp peripheral handle

  • config: The configuration


struct periph_console_cmd_t

Command structure.

Public Members

const char *cmd

Name of command, must be unique

int id

Command ID will be sent together when the command is matched

const char *help

Explanation of the command

console_cmd_callback_t func

Function callback for the command

struct periph_console_cfg_t

Console Peripheral configuration.

Public Members

int command_num

Total number of commands

const periph_console_cmd_t *commands

Pointer to array of commands

int task_stack

Console task stack, using default if the value is zero

int task_prio

Console task priority (based on freeRTOS priority), using default if the value is zero

int buffer_size

Size of console input buffer

const char *prompt_string

Console prompt string, using default CONSOLE_PROMPT_STRING if the pointer is NULL



Type Definitions

typedef esp_err_t (*console_cmd_callback_t)(esp_periph_handle_t periph, int argc, char *argv[])