uEspConfigLib
https://github.com/Naguissa/uEspConfigLib
uEspConfigLib.h
Go to the documentation of this file.
1
21#pragma once
22
23#include <Arduino.h>
24#ifdef ARDUINO_ARCH_ESP32
25 #include <WiFi.h>
26 #include <WiFiAP.h>
27 #include "WebServer.h"
28#else
29 #include "ESP8266WebServer.h"
30#endif
32#include "uEspConfigLibFSNone.h"
35#include "uEspConfigLibFSSd.h"
36#ifdef ARDUINO_ARCH_ESP32
37 #include "WebServer.h"
38 #define uEspConfigLib_WebServer WebServer
39#else
40 #include "ESP8266WebServer.h"
41 #define uEspConfigLib_WebServer ESP8266WebServer
42#endif
43
44
46 uEspConfigLibList() : next(0), name(0), description(0), defaultValue(0), value(0) {};
48 char * name;
49 char * description;
50 char * defaultValue;
51 char * value;
52};
53
54#define uEspConfigLib_free(field) if (field != 0) { free(field); field = 0; }
55#define uEspConfigLib_WebServer_sendContent(data) if (*data != 0) { server->sendContent(data); }
56
58 public:
65
66 // Regular usage functions
74 void addOption(const char *, const char *, const char *);
75
83 bool set(const char *, const char *);
84
91 char * getPointer(const char *);
92
99 bool clear(const char *);
100
101 // Web server functions
110 void handleConfigRequestHtml(uEspConfigLib_WebServer *, const char * = "/uConfigLib/saveConfig");
111
142 void handleConfigRequestJson(uEspConfigLib_WebServer *);
143
158 void handleSaveConfig(uEspConfigLib_WebServer *);
159
160
161 // FS functions
162
168 bool loadConfigFile();
169
175 bool saveConfigFile();
176
177 private:
178 uEspConfigLib(); // 1 arg needed
179 void _copyName(uEspConfigLibList *, const char *);
180 void _copyDefault(uEspConfigLibList *, const char *);
181 void _copyValue(uEspConfigLibList *, const char *);
182 void _copyValue(uEspConfigLibList *, const String);
183 void _copyDescription(uEspConfigLibList *, const char *);
184 void _parseConfigLine(String);
185 uEspConfigLibList *list;
187
188};
189
The deffinitive ESP32 and ESP8266 configuration Arduino library, uEspConfigLib - FileSystem interface...
Definition: uEspConfigLibFSInterface.h:50
The deffinitive ESP32 and ESP8266 configuration Arduino library, uEspConfigLib.
Definition: uEspConfigLib.h:57
char * getPointer(const char *)
Gets a char pointer to the current value of a configuration option.
Definition: uEspConfigLib.cpp:138
void handleConfigRequestJson(uEspConfigLib_WebServer *)
Handles a configuration JSON request.
Definition: uEspConfigLib.cpp:242
void handleSaveConfig(uEspConfigLib_WebServer *)
Handles a save configuration request.
Definition: uEspConfigLib.cpp:294
void handleConfigRequestHtml(uEspConfigLib_WebServer *, const char *="/uConfigLib/saveConfig")
Handles a configuration HTML form request.
Definition: uEspConfigLib.cpp:172
bool set(const char *, const char *)
Changes a configuration option current value.
Definition: uEspConfigLib.cpp:118
bool loadConfigFile()
Loads config file from FileSystem and processes it.
Definition: uEspConfigLib.cpp:346
bool clear(const char *)
Changes a configuration option to its default value.
Definition: uEspConfigLib.cpp:153
void addOption(const char *, const char *, const char *)
Defines a configuration option.
Definition: uEspConfigLib.cpp:80
bool saveConfigFile()
Recreates and overwrites config file to FileSystem with current configurations.
Definition: uEspConfigLib.cpp:365
Definition: uEspConfigLib.h:45