-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebCfgServer.h
71 lines (58 loc) · 2.13 KB
/
WebCfgServer.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <Preferences.h>
#include <WebServer.h>
#include "Ota.h"
#include "Network.h"
enum class TokenType
{
None,
MqttServer,
MqttPort,
MqttUser,
MqttPass,
MqttPath,
QueryIntervalLockstate,
QueryIntervalBattery,
};
class WebCfgServer
{
public:
WebCfgServer(Network* network, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal);
~WebCfgServer() = default;
void initialize();
void update();
private:
bool processArgs(String& message);
void buildHtml(String& response);
void buildCredHtml(String& response);
void buildOtaHtml(String& response);
void buildMqttConfigHtml(String& response);
void buildConfirmHtml(String& response, const String &message, uint32_t redirectDelay = 5);
void buildConfigureWifiHtml(String& response);
void sendNewCss();
void sendFontsInterMinCss();
void sendFavicon();
void buildHtmlHeader(String& response);
void printInputField(String& response, const char* token, const char* description, const char* value, const size_t maxLength, const bool isPassword = false);
void printInputField(String& response, const char* token, const char* description, const int value, size_t maxLength);
void printCheckBox(String& response, const char* token, const char* description, const bool value);
void printTextarea(String& response, const char *token, const char *description, const char *value, const size_t maxLength);
void buildNavigationButton(String& response, const char* caption, const char* targetPath);
void printParameter(String& response, const char* description, const char* value);
void waitAndProcess(const bool blocking, const uint32_t duration);
void handleOtaUpload();
WebServer _server;
Network* _network;
Preferences* _preferences;
Ota _ota;
String _hostname;
bool _hasCredentials = false;
char _credUser[31] = {0};
char _credPassword[31] = {0};
bool _allowRestartToPortal = false;
uint32_t _transferredSize = 0;
bool _otaStart = true;
unsigned long _otaStartTs = 0;
String _confirmCode = "----";
bool _enabled = true;
};