Save files appending on same session and new file on new session

This commit is contained in:
Emanuele Trabattoni
2026-04-07 15:53:52 +02:00
parent 668b590d7c
commit 877236ee4e
11 changed files with 1112 additions and 1043 deletions

View File

@@ -6,19 +6,34 @@
#include <SPIFFS.h>
#include <string>
#include <fstream>
#include <filesystem>
// Project Includes
#include "isr.h"
#include "psvector.h"
const uint32_t max_history = 1024;
const bool SAVE_HISTORY_TO_SPIFFS = true; // Set to true to enable saving history to SPIFFS, false to disable
struct dataSaveParams
{
PSRAMVector<ignitionBoxStatus> *history;
const std::filesystem::path file_path;
};
void save_history(const PSRAMVector<ignitionBoxStatus> &history, const std::filesystem::path& file_path);
static void saveHistoryTask(void *pvParameters)
{
auto *history = static_cast<PSRAMVector<ignitionBoxStatus> *>(pvParameters);
save_history(*history);
auto *params = static_cast<dataSaveParams *>(pvParameters);
auto &history = *params->history;
auto &file_path = params->file_path;
if (!params) {
LOG_ERROR("Invalid parameters for saveHistoryTask");
return;
}
save_history(history, file_path);
history.reserve(max_history); // ensure writable buffer has the correct size
vTaskDelete(NULL);
}
void save_history(const PSRAMVector<ignitionBoxStatus> &history);