mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
fix factory reset using LITTLEFS
This commit is contained in:
@@ -236,24 +236,15 @@ void System::button_OnLongPress(PButton & b) {
|
||||
// button indefinite press
|
||||
void System::button_OnVLongPress(PButton & b) {
|
||||
LOG_DEBUG(F("Button pressed - very long press"));
|
||||
#ifndef EMSESP_STANDALONE
|
||||
LOG_WARNING(F("Performing factory reset..."));
|
||||
EMSESP::console_.loop();
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
// remove all files under config
|
||||
File root = LITTLEFS.open(FS_CONFIG_DIRECTORY);
|
||||
File file;
|
||||
Serial.printf("Removing files: ", file.name());
|
||||
while (file = root.openNextFile()) {
|
||||
Serial.printf("%s ", file.name());
|
||||
LITTLEFS.remove(file.name());
|
||||
}
|
||||
Serial.println();
|
||||
#ifdef EMSESP_TEST
|
||||
Test::listDir(LITTLEFS, FS_CONFIG_DIRECTORY, 3);
|
||||
#endif
|
||||
|
||||
// restart
|
||||
WiFi.disconnect(true);
|
||||
delay(500);
|
||||
ESP.restart();
|
||||
EMSESP::esp8266React.factoryReset();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -265,16 +256,16 @@ void System::button_init(bool refresh) {
|
||||
|
||||
// Allow 0 for Boot-button on NodeMCU-32s?
|
||||
// if (pbutton_gpio_) {
|
||||
if (!myPButton_.init(pbutton_gpio_, HIGH)) {
|
||||
LOG_INFO(F("External multi-functional button not detected"));
|
||||
} else {
|
||||
LOG_INFO(F("External multi-functional button enabled"));
|
||||
}
|
||||
if (!myPButton_.init(pbutton_gpio_, HIGH)) {
|
||||
LOG_INFO(F("External multi-functional button not detected"));
|
||||
} else {
|
||||
LOG_INFO(F("External multi-functional button enabled"));
|
||||
}
|
||||
|
||||
myPButton_.onClick(BUTTON_Debounce, button_OnClick);
|
||||
myPButton_.onDblClick(BUTTON_DblClickDelay, button_OnDblClick);
|
||||
myPButton_.onLongPress(BUTTON_LongPressDelay, button_OnLongPress);
|
||||
myPButton_.onVLongPress(BUTTON_VLongPressDelay, button_OnVLongPress);
|
||||
myPButton_.onClick(BUTTON_Debounce, button_OnClick);
|
||||
myPButton_.onDblClick(BUTTON_DblClickDelay, button_OnDblClick);
|
||||
myPButton_.onLongPress(BUTTON_LongPressDelay, button_OnLongPress);
|
||||
myPButton_.onVLongPress(BUTTON_VLongPressDelay, button_OnVLongPress);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -978,6 +978,7 @@ void Test::add_device(uint8_t device_id, uint8_t product_id) {
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
void Test::listDir(fs::FS & fs, const char * dirname, uint8_t levels) {
|
||||
Serial.println();
|
||||
Serial.printf("Listing directory: %s\r\n", dirname);
|
||||
|
||||
File root = fs.open(dirname);
|
||||
|
||||
@@ -44,8 +44,6 @@ class Test {
|
||||
static void uart_telegram_withCRC(const char * rx_data);
|
||||
static void add_device(uint8_t device_id, uint8_t product_id);
|
||||
static void debug(uuid::console::Shell & shell, const std::string & command);
|
||||
|
||||
private:
|
||||
#ifndef EMSESP_STANDALONE
|
||||
static void listDir(fs::FS & fs, const char * dirname, uint8_t levels);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user