Files
ink-board/main/network/network.cpp
GW_MC 44fb9aa632 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.
2026-01-21 14:00:04 +08:00

33 lines
872 B
C++

#include "esp_log.h"
#include "network/network.h"
#include "network/http_handler.h"
#include "common/constants.h"
NetworkHandler::NetworkHandler(
std::unique_ptr<WifiHandler> wifiHandler
) : wifiHandler(std::move(wifiHandler)) { }
NetworkHandler::~NetworkHandler() { }
void NetworkHandler::init(EventGroupHandle_t system_event_group) {
if (this->initialized) {
ESP_LOGW("NetworkHandler", "Already initialized, skipping");
return;
}
this->wifiHandler->init();
this->initialized = true;
xEventGroupSetBits(
system_event_group,
NETWORK_READY_BIT
);
}
WifiHandler& NetworkHandler::get_wifi_handler() {
return *this->wifiHandler;
}
std::unique_ptr<HttpHandler> NetworkHandler::get_http_handler(const esp_http_client_config_t&& config) {
return std::unique_ptr<HttpHandler>(new HttpHandler(std::move(config), this->wifiHandler.get()));
}