Remove all files but the pin_mapping.json from filesystem on factory reset
This allows to create more user defined files and get them deleted on factory reset.
This commit is contained in:
parent
48a722f826
commit
557c5d645e
@ -11,4 +11,5 @@ public:
|
|||||||
static int getTimezoneOffset();
|
static int getTimezoneOffset();
|
||||||
static void restartDtu();
|
static void restartDtu();
|
||||||
static bool checkJsonAlloc(const DynamicJsonDocument& doc, const char* function, const uint16_t line);
|
static bool checkJsonAlloc(const DynamicJsonDocument& doc, const char* function, const uint16_t line);
|
||||||
|
static void removeAllFiles();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,7 +6,9 @@
|
|||||||
#include "Display_Graphic.h"
|
#include "Display_Graphic.h"
|
||||||
#include "Led_Single.h"
|
#include "Led_Single.h"
|
||||||
#include "MessageOutput.h"
|
#include "MessageOutput.h"
|
||||||
|
#include "PinMapping.h"
|
||||||
#include <Esp.h>
|
#include <Esp.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
|
||||||
uint32_t Utils::getChipId()
|
uint32_t Utils::getChipId()
|
||||||
{
|
{
|
||||||
@ -76,3 +78,17 @@ bool Utils::checkJsonAlloc(const DynamicJsonDocument& doc, const char* function,
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Remove all files but the PINMAPPING_FILENAME
|
||||||
|
void Utils::removeAllFiles()
|
||||||
|
{
|
||||||
|
auto root = LittleFS.open("/");
|
||||||
|
auto file = root.getNextFileName();
|
||||||
|
|
||||||
|
while (file != "") {
|
||||||
|
if (file != PINMAPPING_FILENAME) {
|
||||||
|
LittleFS.remove(file);
|
||||||
|
}
|
||||||
|
file = root.getNextFileName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -108,7 +108,7 @@ void WebApiConfigClass::onConfigDelete(AsyncWebServerRequest* request)
|
|||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|
||||||
LittleFS.remove(CONFIG_FILENAME);
|
Utils::removeAllFiles();
|
||||||
Utils::restartDtu();
|
Utils::restartDtu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user