-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.h
56 lines (55 loc) · 1.47 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
boolean loadSavedConfig()
{
String ssid = "";
String password = "";
if (EEPROM.read(0) != 0)
{
for (int i = 0; i < 32; ++i)
{
ssid += char(EEPROM.read(i));
}
//Serial.print("SSID: ");
//Serial.println(ssid);
for (int i = 32; i < 96; ++i)
{
password += char(EEPROM.read(i));
}
//Serial.print("Password: ");
//Serial.println(password);
// WiFi.begin(ssid.c_str(), password.c_str());
//in case of err remove these 4 line
IPAddress ip(192, 168, 1, 123);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.begin(ssid.c_str(), password.c_str());
WiFi.config(ip, gateway, subnet);
return true;
}
else
{
//Serial.println("Saved Configuration not found.");
return false;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
boolean checkWiFiConnection() {
int count = 0;
//Serial.print("Waiting to connect to the specified WiFi network");
while ( count < 30 ) {
if (WiFi.status() == WL_CONNECTED) {
Serial.println();
//Serial.println("Connected!");
return (true);
}
delay(500);
//Serial.print(".");
//if (state5 == HIGH)
// state5 = LOW;
// else
// state5 = HIGH;
//digitalWrite(ledPin5, state5);
count++;
}
//Serial.println("Timed out.");
return false;
}