mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2026-04-28 12:03:07 -07:00
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#ifndef Settings_h
|
|
#define Settings_h
|
|
|
|
#include "configs.h"
|
|
|
|
#include "SPIFFS.h"
|
|
#include <FS.h>
|
|
#include <ArduinoJson.h>
|
|
|
|
#define FORMAT_SPIFFS_IF_FAILED true
|
|
|
|
#ifdef HAS_SCREEN
|
|
#include "Display.h"
|
|
|
|
extern Display display_obj;
|
|
#endif
|
|
|
|
class Settings {
|
|
|
|
private:
|
|
String json_settings_string;
|
|
|
|
// Flat cache populated once at begin() and kept in sync by saveSetting().
|
|
// All loadSetting<T>() reads hit this struct — zero heap, zero JSON parse.
|
|
struct SettingsCache {
|
|
bool ForcePMKID = false;
|
|
bool ForceProbe = false;
|
|
bool SavePCAP = true;
|
|
bool EnableLED = true;
|
|
bool EPDeauth = false;
|
|
bool ChanHop = false;
|
|
String ClientSSID = "";
|
|
String ClientPW = "";
|
|
} _cache;
|
|
|
|
void _buildCache(); // parse json_settings_string -> _cache
|
|
|
|
public:
|
|
bool begin();
|
|
|
|
template <typename T>
|
|
T loadSetting(String name);
|
|
|
|
template <typename T>
|
|
T saveSetting(String key, bool value);
|
|
|
|
template <typename T>
|
|
T saveSetting(String key, String value);
|
|
|
|
bool toggleSetting(String key);
|
|
String getSettingType(String key);
|
|
String setting_index_to_name(int i);
|
|
int getNumberSettings();
|
|
|
|
String getSettingsString();
|
|
bool createDefaultSettings(fs::FS &fs, bool spec = false, uint8_t index = 0, String typeStr = "bool", String name = "");
|
|
void printJsonSettings(String json_string);
|
|
};
|
|
|
|
#endif
|