forked from TheLuckyChip/LuckyBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_config.cpp
103 lines (98 loc) · 2.33 KB
/
file_config.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "file_config.h"
// Загрузка данных сохраненных в EEPROM
bool loadConfig()
{
// считаем конфигурацию WiFi
EEPROM.begin(2048);
uint16_t index = 1700;
uint8_t cnt = 0;
SSDP_Name = "";
while (1) {
if (EEPROM.read(index) != 255 && EEPROM.read(index) != 0 && cnt < 60) {
SSDP_Name += " ";
SSDP_Name[cnt] = EEPROM.read(index);
index++;
cnt++;
}
else {
if (cnt <= 2) SSDP_Name = "LuckyBox";
break;
}
}
index = 1760;
cnt = 0;
_ssid = "";
while (1) {
if (EEPROM.read(index) != 255 && EEPROM.read(index) != 0 && cnt < 60) {
_ssid += " ";
_ssid[cnt] = EEPROM.read(index);
index++;
cnt++;
}
else {
if (cnt <= 2) _ssid = "SSID";
break;
}
}
index = 1820;
cnt = 0;
_ssidAP = "";
while (1) {
if (EEPROM.read(index) != 255 && EEPROM.read(index) != 0 && cnt < 60) {
_ssidAP += " ";
_ssidAP[cnt] = EEPROM.read(index);
index++;
cnt++;
}
else {
if (cnt <= 2) _ssidAP = "LuckyBox";
break;
}
}
index = 1900;
cnt = 0;
_password = "";
while (1) {
if (EEPROM.read(index) != 255 && EEPROM.read(index) != 0 && cnt < 32) {
_password += " ";
_password[cnt] = EEPROM.read(index);
index++;
cnt++;
}
else {
if (cnt < 8) _password = "PASSWORD";
break;
}
}
index = 1940;
cnt = 0;
_passwordAP = "";
while (1) {
if (EEPROM.read(index) != 255 && EEPROM.read(index) != 0 && cnt < 32) {
_passwordAP += " ";
_passwordAP[cnt] = EEPROM.read(index);
index++;
cnt++;
}
else {
if (cnt < 8) _passwordAP = "12345678";
break;
}
}
Serial.print("SSDP Name = "); Serial.println(SSDP_Name);
Serial.print("SSID = "); Serial.print(_ssid);
Serial.print(" password = "); Serial.println(_password);
Serial.print("SSIDAP = "); Serial.print(_ssidAP); Serial.print(" - ");
String addrMac = WiFi.softAPmacAddress();
String addrMacMod = " ";
addrMacMod[0] = addrMac[0]; addrMacMod[1] = addrMac[1];
addrMacMod[2] = addrMac[3]; addrMacMod[3] = addrMac[4];
addrMacMod[4] = addrMac[6]; addrMacMod[5] = addrMac[7];
addrMacMod[6] = addrMac[9]; addrMacMod[7] = addrMac[10];
addrMacMod[8] = addrMac[12]; addrMacMod[9] = addrMac[13];
addrMacMod[10] = addrMac[15]; addrMacMod[11] = addrMac[16];
Serial.print(addrMacMod);
Serial.print(" passwordAP = "); Serial.println(_passwordAP);
Serial.println();
EEPROM.end();
}