feat: implement LittleFSHandler and FSGuard for improved file management

This commit is contained in:
GW_MC
2026-01-30 15:23:44 +08:00
parent b6c4477c46
commit 2a5088bec3
7 changed files with 821 additions and 85 deletions

View File

@@ -13,6 +13,7 @@
#include "common/constants.h"
#include "common/queue_defs.h"
#include "io/nvs_handler.h"
#include "io/fs_handler.h"
#include "info/info.h"
#include "display/eink_display_handler.h"
#include "display/lvgl_handler.h"
@@ -31,7 +32,6 @@
// nvs storage namespaces, 15 characters max
#define DEFAULT_STORAGE_NAMESPACE "storage"
#define WIFI_CREDENTIALS_STORAGE_NAMESPACE "wifi_cred"
#define TAG "Main"
extern "C" void app_main(void);
@@ -61,9 +61,15 @@ void app_main(void) {
DEFAULT_STORAGE_NAMESPACE
);
auto wifi_handler = std::make_unique<WifiHandler>(
std::unique_ptr<KVStorageHandler>(new NVSStorageHandler(WIFI_CREDENTIALS_STORAGE_NAMESPACE))
);
auto fs_handler = std::make_shared<LittleFSHandler>();
esp_err_t fs_err = fs_handler->init("/littlefs");
if (fs_err != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize LittleFS: %s", esp_err_to_name(fs_err));
vTaskDelay(5000 / portTICK_PERIOD_MS);
return esp_restart();
}
auto wifi_handler = std::make_unique<WifiHandler>(fs_handler);
NetworkHandler* network_handler = new NetworkHandler(std::move(wifi_handler));
EInkDisplayHandler* display_handler = new EInkDisplayHandler();
// Initialize display and touch