Delete local storage function

This commit is contained in:
samuelbles07
2024-12-06 02:20:07 +07:00
parent 1034f1892a
commit a9fa7b6e63
2 changed files with 11 additions and 1 deletions

View File

@ -1068,6 +1068,15 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
void Measurements::setDebug(bool debug) { _debug = debug; }
bool Measurements::resetLocalStorage() {
if (!SPIFFS.remove(FILE_PATH)) {
Serial.println("Failed reset local storage");
return false;
}
return true;
}
void Measurements::saveLocalStorage(AirGradient &ag) {
File file;
if (!SPIFFS.exists(FILE_PATH)) {

View File

@ -142,6 +142,7 @@ public:
String toString(bool localServer, AgFirmwareMode fwMode, int rssi, AirGradient &ag,
Configuration &config);
bool resetLocalStorage();
void saveLocalStorage(AirGradient &ag);
char *getLocalStorage();
@ -176,7 +177,7 @@ private:
IntegerValue _pm_10_pc[2]; // particle count 10
bool _debug = false;
const char *FILE_PATH = "/measurement.csv"; // Local storage file path
const char *FILE_PATH = "/measurements.csv"; // Local storage file path
/**
* @brief Get PMS5003 firmware version string