-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb_interface.h
More file actions
84 lines (74 loc) · 2.15 KB
/
web_interface.h
File metadata and controls
84 lines (74 loc) · 2.15 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* TT Control, advanced sinusoidal control of multi-phase turntable motors
* Created by Ashley Cox at The Blind Man's Workshop
* https://theblindmansworkshop.com
* No part of this code may be used or reproduced for commercial purposes without written permission and contractual agreement
* All external libraries and frameworks are the property of their respective authors and governed by their respective licenses
*/
#ifndef WEB_INTERFACE_H
#define WEB_INTERFACE_H
#include <Arduino.h>
#include "config.h"
#if NETWORK_ENABLE
#include <WebServer.h>
#include <ArduinoJson.h>
#endif
class WebInterface {
public:
WebInterface();
void begin();
void update();
bool isStarted() const;
private:
#if NETWORK_ENABLE
WebServer _server;
bool _started;
char _authToken[17];
uint32_t _authExpiresMs;
char* _rawBody;
size_t _rawBodyLength;
size_t _rawBodyCapacity;
bool _rawBodyOverflow;
bool _rawBodyComplete;
void setupRoutes();
void sendJson(int code, JsonDocument& doc);
void sendStaticHtml(PGM_P content, size_t contentLength);
void sendError(int code, const char* message);
bool parseBody(JsonDocument& doc);
void handleRawBody();
void releaseRawBody();
bool isOpenSetupRequest();
bool rejectOpenSetupAccess();
bool hasWriteAccess();
bool requireWriteAccess();
void clearAuthToken();
void issueAuthToken();
void streamStatus(Print& out);
void populateStatus(JsonDocument& doc);
void handleRoot();
void handleSetupRoot();
void handleAuthGet();
void handleAuthPost();
void handlePreferencesGet();
void handlePreferencesPost();
void handleSchemaGet();
void handleStatus();
void handleEventsGet();
void handleSettingsGet();
void handleSettingsPost();
void handleControl();
void handleNetworkGet();
void handleNetworkPost();
void handleNetworkScan();
void handleDiagnosticsGet();
void handlePresetsGet();
void handlePresetPost();
void handleErrorsGet();
void handleErrorsPost();
void handleNotFound();
#else
bool _started;
#endif
};
extern WebInterface webInterface;
#endif // WEB_INTERFACE_H