-
Notifications
You must be signed in to change notification settings - Fork 40
/
file_config.cpp
120 lines (115 loc) · 2.69 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#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);
// NBNS_Name[cnt] = SSDP_Name[cnt];
index++;
cnt++;
}
else {
if (cnt < 2) {
SSDP_Name = "LuckyBox";
// NBNS_Name[0] = 76;
// NBNS_Name[1] = 117;
// NBNS_Name[2] = 99;
// NBNS_Name[3] = 107;
// NBNS_Name[4] = 121;
// NBNS_Name[5] = 66;
// NBNS_Name[6] = 111;
// NBNS_Name[7] = 120;
// NBNS_Name[8] = 0;
}
// else NBNS_Name[cnt] = 0;
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;
}
}
#if defined Debug_en
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(" - ");
#endif
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];
#if defined Debug_en
Serial.print(addrMacMod);
Serial.print(" passwordAP = "); Serial.println(_passwordAP);
Serial.println();
#endif
EEPROM.end();
}