refactor: Fixed the file hierarchy and switched to platform.io

This commit is contained in:
2026-02-28 21:57:42 +02:00
parent ab1e4f2e6d
commit 30d660268f
65 changed files with 1208 additions and 1281 deletions
+70
View File
@@ -0,0 +1,70 @@
/*
* ═══════════════════════════════════════════════════════════════════════════════════
* FILEMANAGER.HPP - SD Card and File Operations Manager
* ═══════════════════════════════════════════════════════════════════════════════════
*
* 📁 THE FILE SYSTEM ORCHESTRATOR OF VESPER 📁
*
* This class provides a clean, robust interface for all file operations
* including melody file management, configuration persistence, and
* comprehensive error handling with automatic recovery.
*
* 📋 VERSION: 2.0 (Enhanced file management)
* 📅 DATE: 2025
* 👨‍💻 AUTHOR: Advanced Bell Systems
* ═══════════════════════════════════════════════════════════════════════════════════
*/
#ifndef FILEMANAGER_HPP
#define FILEMANAGER_HPP
#include <Arduino.h>
#include <SD.h>
#include <HTTPClient.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <esp_task_wdt.h>
#include "../Logging/Logging.hpp"
#include "../ConfigManager/ConfigManager.hpp"
class FileManager {
private:
ConfigManager* configManager;
public:
// Constructor
FileManager(ConfigManager* config);
// Core file operations
bool downloadFile(const String& url, const String& directory, const String& filename);
bool addMelody(JsonVariant doc); // Download melody file from JSON data
String listFilesAsJson(const char* dirPath);
// File utilities
bool fileExists(const String& filePath);
bool deleteFile(const String& filePath);
bool createDirectory(const String& dirPath);
size_t getFileSize(const String& filePath);
// Generic read/write for JSON data
bool writeJsonFile(const String& filePath, JsonDocument& doc);
bool readJsonFile(const String& filePath, JsonDocument& doc);
// Append a single text line to a file (used by SD log channel)
bool appendLine(const String& filePath, const String& line);
// ═══════════════════════════════════════════════════════════════════════════════
// HEALTH CHECK METHOD
// ═══════════════════════════════════════════════════════════════════════════════
/** @brief Check if FileManager is in healthy state */
bool isHealthy() const;
private:
// Helper functions
bool initializeSD();
bool ensureDirectoryExists(const String& dirPath);
};
#endif