mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
added back format console command
This commit is contained in:
@@ -152,6 +152,27 @@ void System::restart() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// format fs
|
||||
// format the FS. Wipes everything.
|
||||
void System::format(uuid::console::Shell & shell) {
|
||||
auto msg = F("Resetting all settings to defaults");
|
||||
shell.logger().warning(msg);
|
||||
shell.flush();
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
EMSuart::stop();
|
||||
|
||||
#if defined(ESP8266)
|
||||
LittleFS.format();
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.format();
|
||||
#endif
|
||||
|
||||
System::restart();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// return free heap mem as a percentage
|
||||
uint8_t System::free_mem() {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
@@ -444,6 +465,23 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
||||
restart();
|
||||
});
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(format)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||
shell.enter_password(F_(password_prompt), [=](Shell & shell, bool completed, const std::string & password) {
|
||||
if (completed) {
|
||||
EMSESP::esp8266React.getSecuritySettingsService()->read([&](SecuritySettings & securitySettings) {
|
||||
if (securitySettings.jwtSecret.equals(password.c_str())) {
|
||||
format(shell);
|
||||
} else {
|
||||
shell.println(F("incorrect password"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(passwd)},
|
||||
|
||||
Reference in New Issue
Block a user