- Added MainUI class for displaying voice state, status icon, and buttons. - Introduced MainUIHandler to manage UI interactions and bridge communication. - Created SettingsUI for displaying QR code and configuration instructions. - Implemented SettingsUIHandler to manage settings and web server interactions. - Developed WebHandler for handling HTTP requests for settings configuration. - Updated AppRegistry to initialize with the new Discord app descriptor. - Enhanced InteractionHandler to support keyboard interactions across app switches. - Updated UIHandler to manage app switching and rendering of app icons. - Enabled QR code support in LVGL configuration.
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include <string>
|
|
#include <memory>
|
|
#include "io/nvs_handler.h"
|
|
|
|
class SettingHandler {
|
|
public:
|
|
SettingHandler(std::unique_ptr<NVSStorageHandler> storage) :
|
|
remote_ip_(""),
|
|
remote_port_(0),
|
|
local_port_(0),
|
|
storage_(std::move(storage)) { }
|
|
~SettingHandler() = default;
|
|
|
|
esp_err_t init(const EventGroupHandle_t& system_event_group) {
|
|
storage_->init(system_event_group);
|
|
return ESP_OK;
|
|
}
|
|
|
|
void load_settings();
|
|
void save_settings(const std::string& ip, uint16_t port) {
|
|
save_settings(ip, port, local_port_);
|
|
}
|
|
void save_settings(const std::string& ip, uint16_t port, uint16_t local_port);
|
|
|
|
bool is_configured() const { return !remote_ip_.empty() && remote_port_ != 0 && local_port_ != 0; }
|
|
|
|
std::string get_remote_ip() const { return remote_ip_; }
|
|
uint16_t get_remote_port() const { return remote_port_; }
|
|
uint16_t get_local_port() const { return local_port_; }
|
|
|
|
private:
|
|
static constexpr uint16_t DEFAULT_LOCAL_PORT = 4212;
|
|
|
|
static constexpr const char* NVS_KEY_IP = "bridge_ip";
|
|
static constexpr const char* NVS_KEY_PORT = "bridge_port";
|
|
static constexpr const char* NVS_KEY_LOCAL_PORT = "local_port";
|
|
|
|
std::string remote_ip_;
|
|
uint16_t remote_port_;
|
|
uint16_t local_port_;
|
|
std::unique_ptr<NVSStorageHandler> storage_;
|
|
};
|