1
6
7
8
9
10
11
12
18
19
20
21
22
25
32
33
37
46
50
59
60
64
65
66
67
68
69
70
71
72
73
74
75
76
104
105
106
107
108
109
110
111
112
113
116
117
118
119
120
121
122
123
124
125
126
127
130
131
132
133
134
139
140
141
142
143
144
145
146
147
148
149
150
151
152
159
160
161
167
168
169
176
177
178
181
182
186
187
192
193
198
199
203
204
210
211
215
216
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
349
350
354
355
356
360
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/* ... */
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include "sdkconfig.h"
#include "esp_heap_caps.h"
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "soc/uart_channel.h"6 includes
typedef struct linenoiseCompletions linenoiseCompletions;
/* ... */
typedef struct {
size_t max_cmdline_length;
size_t max_cmdline_args;
uint32_t heap_alloc_caps;
int hint_color;
int hint_bold;
}{ ... } esp_console_config_t;
/* ... */
#define ESP_CONSOLE_CONFIG_DEFAULT() \
{ \
.max_cmdline_length = 256, \
.max_cmdline_args = 32, \
.heap_alloc_caps = MALLOC_CAP_DEFAULT, \
.hint_color = 39, \
.hint_bold = 0 \
}{...}
...
/* ... */
typedef struct {
uint32_t max_history_len;
const char *history_save_path;
uint32_t task_stack_size;
uint32_t task_priority;
BaseType_t task_core_id;
const char *prompt;
size_t max_cmdline_length;
}{ ... } esp_console_repl_config_t;
/* ... */
#define ESP_CONSOLE_REPL_CONFIG_DEFAULT() \
{ \
.max_history_len = 32, \
.history_save_path = NULL, \
.task_stack_size = 4096, \
.task_priority = 2, \
.task_core_id = tskNO_AFFINITY, \
.prompt = NULL, \
.max_cmdline_length = 0, \
}{...}
...
#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM
/* ... */
typedef struct {
int channel;
int baud_rate;
int tx_gpio_num;
int rx_gpio_num;
}{ ... } esp_console_dev_uart_config_t;
#if CONFIG_ESP_CONSOLE_UART_CUSTOM
#define ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT() \
{ \
.channel = CONFIG_ESP_CONSOLE_UART_NUM, \
.baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE, \
.tx_gpio_num = (CONFIG_ESP_CONSOLE_UART_TX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_TX_GPIO : UART_NUM_0_TXD_DIRECT_GPIO_NUM, \
.rx_gpio_num = (CONFIG_ESP_CONSOLE_UART_RX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_RX_GPIO : UART_NUM_0_RXD_DIRECT_GPIO_NUM, \
}{...}
...#else/* ... */
#define ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT() \
{ \
.channel = CONFIG_ESP_CONSOLE_UART_NUM, \
.baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE, \
.tx_gpio_num = -1, \
.rx_gpio_num = -1, \
}{...}
...#endif/* ... */ /* ... */
#endif
#if CONFIG_ESP_CONSOLE_USB_CDC || (defined __DOXYGEN__ && SOC_USB_OTG_SUPPORTED)
/* ... */
typedef struct {
}{...} esp_console_dev_usb_cdc_config_t;
#define ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT() {}/* ... */
#endif
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || (defined __DOXYGEN__ && SOC_USB_SERIAL_JTAG_SUPPORTED)
/* ... */
typedef struct {
}{...} esp_console_dev_usb_serial_jtag_config_t;
#define ESP_CONSOLE_DEV_USB_SERIAL_JTAG_CONFIG_DEFAULT() {}/* ... */
#endif
typedef enum {
ESP_CONSOLE_HELP_VERBOSE_LEVEL_0 = 0,
ESP_CONSOLE_HELP_VERBOSE_LEVEL_1 = 1,
ESP_CONSOLE_HELP_VERBOSE_LEVEL_MAX_NUM = 2
}{ ... } esp_console_help_verbose_level_e;
/* ... */
esp_err_t esp_console_init(const esp_console_config_t *config);
/* ... */
esp_err_t esp_console_deinit(void);
/* ... */
typedef int (*esp_console_cmd_func_t)(int argc, char **argv);
/* ... */
typedef int (*esp_console_cmd_func_with_context_t)(void *context, int argc, char **argv);
/* ... */
typedef struct {
/* ... */
const char *command;
/* ... */
const char *help;
/* ... */
const char *hint;
/* ... */
esp_console_cmd_func_t func;
/* ... */
void *argtable;
/* ... */
esp_console_cmd_func_with_context_t func_w_context;
/* ... */
void *context;
}{ ... } esp_console_cmd_t;
/* ... */
esp_err_t esp_console_cmd_register(const esp_console_cmd_t *cmd);
/* ... */
esp_err_t esp_console_cmd_deregister(const char *cmd_name);
/* ... */
esp_err_t esp_console_run(const char *cmdline, int *cmd_ret);
/* ... */
size_t esp_console_split_argv(char *line, char **argv, size_t argv_size);
/* ... */
void esp_console_get_completion(const char *buf, linenoiseCompletions *lc);
/* ... */
const char *esp_console_get_hint(const char *buf, int *color, int *bold);
/* ... */
esp_err_t esp_console_register_help_command(void);
/* ... */
esp_err_t esp_console_set_help_verbose_level(esp_console_help_verbose_level_e verbose_level);
/* ... */
/* ... */
typedef struct esp_console_repl_s esp_console_repl_t;
/* ... */
struct esp_console_repl_s {
/* ... */
esp_err_t (*del)(esp_console_repl_t *repl);
}{ ... };
#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM
/* ... */
esp_err_t esp_console_new_repl_uart(const esp_console_dev_uart_config_t *dev_config, const esp_console_repl_config_t *repl_config, esp_console_repl_t **ret_repl);/* ... */
#endif
#if CONFIG_ESP_CONSOLE_USB_CDC || (defined __DOXYGEN__ && SOC_USB_OTG_SUPPORTED)
/* ... */
esp_err_t esp_console_new_repl_usb_cdc(const esp_console_dev_usb_cdc_config_t *dev_config, const esp_console_repl_config_t *repl_config, esp_console_repl_t **ret_repl);/* ... */
#endif
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || (defined __DOXYGEN__ && SOC_USB_SERIAL_JTAG_SUPPORTED)
/* ... */
esp_err_t esp_console_new_repl_usb_serial_jtag(const esp_console_dev_usb_serial_jtag_config_t *dev_config, const esp_console_repl_config_t *repl_config, esp_console_repl_t **ret_repl);/* ... */
#endif
/* ... */
esp_err_t esp_console_start_repl(esp_console_repl_t *repl);
#ifdef __cplusplus
}{...}
#endif