-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
74 lines (60 loc) · 1.63 KB
/
config.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
/**
* Configuration library to manage a config file into
* the LittleFS memory.
* Copyright (c) 2006 Tutilus. All right reserved.
* @created_at: 23-03-2022
*
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <Arduino.h>
#include <LittleFS.h>
#include <ArduinoJson.h>
#include <string.h>
#define DEFAULT_MQTT_CHANNEL "/moheato/logs"
#define DEFAULT_MQTT_NETWORK "0.0.0.0"
#define DEFAULT_MQTT_PORT 1183
#define DEFAULT_NETWORK_SSID "moheato-network"
#define DEFAULT_NETWORK_PWD "RSbbmZe4yeBe4w"
#define DEFAULT_NETWORK_CHANNEL 1
#define DEFAULT_NETWORK_AP_MODE 1 // AP activated mode
#define DEFAULT_NETWORK_HIDDEN 0
typedef struct {
String network;
String channel;
int port;
} t_mqtt_config;
typedef struct {
String ssid;
String password;
int channel;
bool ap_mode;
bool hidden;
} t_network_config;
class Config
{
private:
char path[64];
t_mqtt_config mqtt_cfg;
t_network_config network_cfg;
public:
Config(const char* filename);
~Config();
// Get parameters for MQTT
t_mqtt_config getMqttParams(void);
// Get parameters for Network
t_network_config* getNetworkParams(void);
void setNetworkSsid(const String ssid);
void setNetworkPassword(const String password);
void setNetworkChannel(const int channel);
void setNetworkModeAp(const bool active);
void setNetworkHidden(const bool active);
void setMqttNetwork(const String network);
void setMqttChannel(const String channel);
void setMqttPort(const int port);
// Set all value to default
void setDefault(void);
// Save current data to file
void save(void);
};
#endif // CONFIG_H