IR blaster with esp32, WIP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
esp-irblaster/main/console/commands/cmd_factory_reset.c

51 lines
1.2 KiB

//
// Created by MightyPork on 2018/12/08.
//
#include <string.h>
#include <linenoise/linenoise.h>
#include <settings.h>
#include <utils.h>
#include <nvs_flash.h>
#include "console/cmd_common.h"
#include <console/cmddef.h>
static int cmd_factory_reset(console_ctx_t *ctx, cmd_signature_t *reg)
{
static struct {
struct arg_str *magic;
struct arg_end *end;
} cmd_args;
if (reg) {
cmd_args.magic = arg_str1(NULL, NULL, "<passphrase>", "Passphrase to prevent accidental erase. Must be 'confirm'");
cmd_args.end = arg_end(2);
reg->argtable = &cmd_args;
reg->command = "factory_reset";
reg->help = "Wipe non-volatile data memory, restoring everything to defaults.";
return 0;
}
if (streq(cmd_args.magic->sval[0], "confirm")) {
nvs_flash_erase();
console_printf("Non-volatile memory erased.\r\n"
"Restarting to apply changes...\r\n\r\n");
vTaskDelay(pdMS_TO_TICKS(500));
esp_restart();
} else {
console_printf("Incorrect passphrase.\r\n");
return 1;
}
return 0;
}
void register_cmd_factory_reset(void)
{
console_cmd_register(cmd_factory_reset, "factory_reset");
}