-
Notifications
You must be signed in to change notification settings - Fork 2
/
helper.ino
53 lines (47 loc) · 1.11 KB
/
helper.ino
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
void Write_Eeprom_WiFi_Data(String qsid, String qpass)
{
if (qsid.length() > 0 && qpass.length() > 0) {
Serial.println("clearing eeprom");
for (int i = 0; i < 96; ++i) {
EEPROM.write(i, 0);
}
Serial.println("writing eeprom ssid:");
for (int i = 0; i < qsid.length(); ++i)
{
EEPROM.write(i, qsid[i]);
Serial.print("Wrote: ");
Serial.print(qsid[i]);
}
Serial.println("writing eeprom pass:");
for (int i = 0; i < qpass.length(); ++i)
{
EEPROM.write(32 + i, qpass[i]);
Serial.print("Wrote: ");
Serial.print(qpass[i]);
}
EEPROM.commit();
}
}
void Clear_Eeprom_Data()
{
Serial.println("clear eeprom");
Write_Eeprom_WiFi_Data("0", "0");
}
bool Load_WiFi_SSID_From_Eeprom(){
String Read_SSID;
for (int i = 0; i < 32; ++i)
{
Read_SSID += char(EEPROM.read(i));
}
WiFi_Stored_SSID = Read_SSID.c_str();
return true;
}
bool Load_WiFi_Password_From_Eeprom(){
String Read_Password;
for (int i = 32; i < 96; ++i)
{
Read_Password += char(EEPROM.read(i));
}
WiFi_Stored_Password = Read_Password.c_str();
return true;
}