-
Notifications
You must be signed in to change notification settings - Fork 12
/
webinterface.h
48 lines (39 loc) · 1.38 KB
/
webinterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef _WEBINTERFACE_H_
#define _WEBINTERFACE_H_
#include <Arduino.h>
#include <ESP8266WebServer.h>
#include <WiFiUdp.h>
#include <ArduinoJson.h>
#include <FS.h>
#ifndef ARDUINOJSON_VERSION
#error ArduinoJson version 6 not found, please include ArduinoJson.h in your .ino file
#endif
#if ARDUINOJSON_VERSION_MAJOR != 6
#error ArduinoJson version 6 is required
#endif
/* these are for numbers */
#define N_JSON_TO_CONFIG(x, y) { if (root.containsKey(y)) { config.x = root[y]; } }
#define N_CONFIG_TO_JSON(x, y) { root[y] = config.x; }
#define N_KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); config.x = str.toInt(); } }
/* these are for strings */
#define S_JSON_TO_CONFIG(x, y) { if (root.containsKey(y)) { strcpy(config.x, root[y]); } }
#define S_CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define S_KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); strcpy(config.x, str.c_str()); } }
bool defaultConfig(void);
bool loadConfig(void);
bool saveConfig(void);
void handleUpdate1(void);
void handleUpdate2(void);
void handleDirList(void);
void handleNotFound(void);
void handleRedirect(String);
void handleRedirect(const char *);
bool handleStaticFile(String);
bool handleStaticFile(const char *);
void handleJSON();
struct Config {
unsigned int universe;
unsigned int channels;
unsigned int delay;
};
#endif // _WEBINTERFACE_H_