#include "cmd_utils.h" #include "esp_log.h" #include "inttypes.h" #include "string.h" #include "esp_console.h" #include "argtable3/argtable3.h" #include "xvprintf.h" #include #include static void register_timestamp(void); void register_utils_commands(void) { register_timestamp(); } static struct { struct arg_lit *disable; struct arg_end *end; } timestamp_args; static int timestamp(int argc, char **argv) { const int nerrors = arg_parse(argc, argv, (void **) ×tamp_args); if (nerrors != 0) { arg_print_errors(stderr, timestamp_args.end, argv[0]); return 1; } if (timestamp_args.disable->count) { print_w_clr_time("Disabled timestamps!", LOG_COLOR_PURPLE, true); timestamp_enabled = false; } else { print_w_clr_time("Enabled timestamps!", LOG_COLOR_PURPLE, true); timestamp_enabled = true; } return 0; } static void register_timestamp(void) { timestamp_args.disable = arg_lit0("d", "disable", "Set to disable timestamps."); timestamp_args.end = arg_end(2); const esp_console_cmd_t cmd = { .command = "timestamp", .help = "Enable or disable timestamp in messages.", .hint = NULL, .func = ×tamp, .argtable = ×tamp_args, }; ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); }