feat: persistent config
This commit is contained in:
@@ -27,6 +27,8 @@ public:
|
||||
void setWiFiConfig(const String& ssid, const String& password,
|
||||
uint32_t connect_timeout_ms = 10000,
|
||||
uint32_t retry_delay_ms = 500);
|
||||
bool saveConfig();
|
||||
void restartNode();
|
||||
|
||||
// Network status methods
|
||||
bool isConnected() const { return WiFi.isConnected(); }
|
||||
|
||||
@@ -1,9 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class Config {
|
||||
public:
|
||||
// Default Configuration Constants
|
||||
static constexpr const char* DEFAULT_WIFI_SSID = "shroud";
|
||||
static constexpr const char* DEFAULT_WIFI_PASSWORD = "th3r31sn0sp00n";
|
||||
static constexpr uint16_t DEFAULT_UDP_PORT = 4210;
|
||||
static constexpr uint16_t DEFAULT_API_SERVER_PORT = 80;
|
||||
static constexpr unsigned long DEFAULT_DISCOVERY_INTERVAL_MS = 1000;
|
||||
static constexpr unsigned long DEFAULT_CLUSTER_LISTEN_INTERVAL_MS = 10;
|
||||
static constexpr unsigned long DEFAULT_HEARTBEAT_INTERVAL_MS = 5000;
|
||||
static constexpr unsigned long DEFAULT_STATUS_UPDATE_INTERVAL_MS = 1000;
|
||||
static constexpr unsigned long DEFAULT_MEMBER_INFO_UPDATE_INTERVAL_MS = 10000;
|
||||
static constexpr unsigned long DEFAULT_PRINT_INTERVAL_MS = 5000;
|
||||
static constexpr unsigned long DEFAULT_NODE_ACTIVE_THRESHOLD_MS = 10000;
|
||||
static constexpr unsigned long DEFAULT_NODE_INACTIVE_THRESHOLD_MS = 60000;
|
||||
static constexpr unsigned long DEFAULT_NODE_DEAD_THRESHOLD_MS = 120000;
|
||||
static constexpr unsigned long DEFAULT_WIFI_CONNECT_TIMEOUT_MS = 15000;
|
||||
static constexpr unsigned long DEFAULT_WIFI_RETRY_DELAY_MS = 500;
|
||||
static constexpr unsigned long DEFAULT_RESTART_DELAY_MS = 10;
|
||||
static constexpr uint16_t DEFAULT_JSON_DOC_SIZE = 1024;
|
||||
static constexpr uint32_t DEFAULT_LOW_MEMORY_THRESHOLD_BYTES = 10000;
|
||||
static constexpr uint32_t DEFAULT_CRITICAL_MEMORY_THRESHOLD_BYTES = 5000;
|
||||
static constexpr size_t DEFAULT_MAX_CONCURRENT_HTTP_REQUESTS = 3;
|
||||
|
||||
// WiFi Configuration
|
||||
String wifi_ssid;
|
||||
String wifi_password;
|
||||
@@ -40,4 +64,12 @@ public:
|
||||
|
||||
// Constructor
|
||||
Config();
|
||||
|
||||
// Persistence methods
|
||||
bool saveToFile(const String& filename = "/config.json");
|
||||
bool loadFromFile(const String& filename = "/config.json");
|
||||
void setDefaults();
|
||||
|
||||
private:
|
||||
static const char* CONFIG_FILE_PATH;
|
||||
};
|
||||
Reference in New Issue
Block a user