Save files appending on same session and new file on new session
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user