2023-11-28 11:24:17 +00:00
|
|
|
#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 <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
static void register_timestamp(void);
|
|
|
|
|
|
|
|
void register_utils_commands(void) {
|
|
|
|
register_timestamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct {
|
2023-11-28 12:49:01 +00:00
|
|
|
struct arg_lit *disable;
|
2023-11-28 11:24:17 +00:00
|
|
|
struct arg_end *end;
|
|
|
|
} timestamp_args;
|
|
|
|
|
|
|
|
static int timestamp(int argc, char **argv) {
|
2023-12-16 09:51:13 +00:00
|
|
|
const int nerrors = arg_parse(argc, argv, (void **) ×tamp_args);
|
2023-11-28 12:49:01 +00:00
|
|
|
if (nerrors != 0) {
|
|
|
|
arg_print_errors(stderr, timestamp_args.end, argv[0]);
|
|
|
|
return 1;
|
2023-11-28 11:24:17 +00:00
|
|
|
}
|
2023-11-28 12:49:01 +00:00
|
|
|
if (timestamp_args.disable->count) {
|
2023-11-28 11:24:17 +00:00
|
|
|
print_w_clr_time("Disabled timestamps!", LOG_COLOR_PURPLE, true);
|
|
|
|
timestamp_enabled = false;
|
2023-11-28 12:49:01 +00:00
|
|
|
} else {
|
|
|
|
print_w_clr_time("Enabled timestamps!", LOG_COLOR_PURPLE, true);
|
|
|
|
timestamp_enabled = true;
|
2023-11-28 11:24:17 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_timestamp(void) {
|
|
|
|
|
2023-11-28 14:09:17 +00:00
|
|
|
timestamp_args.disable = arg_lit0("d", "disable", "Set to disable timestamps.");
|
|
|
|
timestamp_args.end = arg_end(2);
|
2023-11-28 11:24:17 +00:00
|
|
|
|
|
|
|
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));
|
|
|
|
}
|