forked from Ryz3D/restSmart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestSmart.h
86 lines (71 loc) · 1.18 KB
/
restSmart.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#ifndef RESTSMART_PORT
#define RESTSMART_PORT 80
#endif
#ifndef RESTSMART_DEBUG
#define RESTSMART_DEBUG false
#endif
#ifndef DISABLE_EEPROM
#define DISABLE_EEPROM false
#endif
#ifndef STRING_BUFFER
#define STRING_BUFFER 10
#endif
#include <Arduino.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include <ESPAsyncWebServer.h>
#include <vector>
#if !DISABLE_EEPROM
#include <EEPROM.h>
#endif
enum PropType
{
Invalid,
Bool,
Float,
Int,
Color,
Str,
};
class PropColor
{
public:
PropColor(uint8_t r, uint8_t g, uint8_t b);
uint8_t r, g, b;
};
class Prop
{
public:
uint8_t getSize();
void read();
void write();
void setFromBuffer();
String stringify();
String id;
String rxBuffer;
PropType type;
bool eepromSave = true;
uint16_t startAddress;
uint8_t floatPrecision = 2;
bool *valueBool;
float *valueFloat;
int *valueInt;
PropColor *valueColor;
String *valueStr;
};
class RestSmart
{
public:
void updateProps();
void loop();
AsyncWebServer server = AsyncWebServer(80);
std::vector<Prop> props;
uint16_t eepromStart;
String wifiSSID;
String wifiPassword;
String wifiHostname;
private:
String stringify();
void connect();
};