From a9fa7b6e63205a372d225d171334522beddf9537 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Fri, 6 Dec 2024 02:20:07 +0700 Subject: [PATCH] Delete local storage function --- src/AgValue.cpp | 9 +++++++++ src/AgValue.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AgValue.cpp b/src/AgValue.cpp index b25fc1f..a18aac3 100644 --- a/src/AgValue.cpp +++ b/src/AgValue.cpp @@ -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)) { diff --git a/src/AgValue.h b/src/AgValue.h index c7182e3..e50b750 100644 --- a/src/AgValue.h +++ b/src/AgValue.h @@ -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