This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.h
83 lines (68 loc) · 1.51 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
75
76
77
78
79
80
81
82
void config_get(String name)
{
String line;
Serial.print("Loading Configuration: '" + name + "'");
name = "/config/" + name;
File f = SPIFFS.open(name.c_str(), "r");
if (!f)
{
Serial.println(" Failed");
return;
}
Blacklist = f.readStringUntil('\n');
Beacons = f.readStringUntil('\n');
if(f.readStringUntil('\n') == "DIS")
{
DIS = 1;
}
if(name == "/config/autorun")
{
MAD = 1;
autorun = millis();
}
f.close();
Serial.println(" Success");
}
void config_save(String name)
{
String line;
Serial.print("Saving Configuration: '" + name + "'");
name = "/config/" + name;
File f = SPIFFS.open(name.c_str(), "w");
if (!f)
{
Serial.println(" Failed");
return;
}
f.println(Blacklist.c_str());
f.println(Beacons.c_str());
if(DIS == 1)
{
f.println("DIS");
}
f.close();
Serial.println(" Success");
}
void config_del(String name)
{
Serial.print("Deleting Configuration: '" + name + "'");
name = "/config/" + name;
File f = SPIFFS.open(name.c_str(), "w");
if (!f)
{
Serial.println(" Failed");
return;
}
f.close();
SPIFFS.remove(name);
Serial.println(" Success");
}
void config_list()
{
Dir dir = SPIFFS.openDir("/config");
while (dir.next())
{
Serial.println("Avaliable Configs: ");
Serial.println(" + " + dir.fileName());
}
}