This repository has been archived by the owner on Jan 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathNetwork.h
73 lines (56 loc) · 2.08 KB
/
Network.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
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef NETWORK_H_
#define NETWORK_H_
#include <Arduino.h>
#include <Ethernet.h>
class aJsonObject;
using namespace std;
class Network {
public:
Network();
void Initialize();
void printConfiguration();
void settingsToJSON(aJsonObject *root);
void settingsFromJSON(aJsonObject *root);
bool setup();
private:
void parseIPV4string(char* ipAddress, uint8_t* ipbytes);
void IPAddressToString(char* buff, IPAddress ip);
void readSettings();
bool parseNetworkConfiguration(Stream& stream);
void writeSettings();
void saveNetworkConfiguration(Stream& stream);
int readEEPROM(void* buf, int offset, int len);
int readEEPROM(IPAddress* address, int offset);
int writeEEPROM(void* buf, int offset, int len);
int writeEEPROM(IPAddress* address, int offset);
void addArrayToObject(aJsonObject* object, const char *string, uint8_t* items, int count);
void addArrayToObject(aJsonObject* object, const char *string, IPAddress ip);
void objectToArray(aJsonObject* object, uint8_t* items);
void objectToArray(aJsonObject* object, IPAddress* ip);
public:
static const char* configFilename;
static uint8_t mac_oui[3];
bool use_dhcp;
uint8_t dhcp_refresh_minutes;
uint8_t mac[6];
IPAddress ip;
IPAddress subnet;
IPAddress gateway;
IPAddress dns;
int httpPort;
int websocketPort;
};
#endif