Refactor NVS and WiFi handlers for improved memory management and logging

- Updated KVStorageHandler interface to use std::string instead of char* for key-value operations.
- Enhanced NVSStorageHandler to utilize ESP_LOG for error and info messages instead of printf.
- Refactored WifiHandler to manage WiFi credentials using JSON format for better structure and storage.
- Replaced raw pointers with std::unique_ptr in WifiHandler and NetworkHandler for automatic memory management.
- Removed unused TouchHandler and EInkTouchHandler classes to clean up the codebase.
- Adjusted CMakeLists.txt to remove unnecessary include directories.
- Updated lv_conf.h to enable FreeRTOS and gesture recognition features.
This commit is contained in:
GW_MC
2026-01-21 14:00:04 +08:00
parent 14f4b8fdc0
commit 44fb9aa632
12 changed files with 302 additions and 304 deletions

View File

@@ -3,8 +3,8 @@
#include "freertos/event_groups.h"
#include <memory>
typedef bool(*FilterFunc)(const char* const& key);
typedef void (*KeyValueProcessor)(void* arg, const char* const& key, const char* const& value);
typedef bool(*FilterFunc)(const std::string& key);
typedef void (*KeyValueProcessor)(void* arg, const std::string& key, const std::string& value);
class KVStorageHandler {
public:
@@ -13,15 +13,14 @@ public:
virtual void init(const EventGroupHandle_t& system_event_group) = 0;
// Store a key-value pair
virtual void put(const char* const& key, const char* const& value) = 0;
virtual void put(const std::string& key, const std::string& value) = 0;
// Retrieve a value by key, returns nullptr if key not found
// The caller is responsible for freeing the returned memory
virtual std::unique_ptr<char[]> get(const char* const& key) const = 0;
// Retrieve a value by key, returns empty string if key not found
virtual std::string get(const std::string& key) const = 0;
virtual esp_err_t process_all(KeyValueProcessor processor, void* arg) const = 0;
virtual esp_err_t process_filtered(const char* const& key_prefix, KeyValueProcessor processor, void* arg) const = 0;
virtual esp_err_t process_filtered(const std::string& key_prefix, KeyValueProcessor processor, void* arg) const = 0;
virtual esp_err_t process_filtered(FilterFunc filter_func, KeyValueProcessor processor, void* arg) const = 0;
// Delete a key-value pair
virtual void remove(const char* const& key) = 0;
virtual void remove(const std::string& key) = 0;
};