forked from filmote/WiFiManagerGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_application.ino
76 lines (34 loc) · 1.25 KB
/
sample_application.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Sample application ..
int init_application() {
status = STATUS_APPLICATION_LOOP;
return loop_application();
}
// -------------------------------------------------------------------------------------------------------
// Process user input ..
//
int loop_application() {
while (status == STATUS_APPLICATION_LOOP) {
// Should we turn the screen off automatically ?
#if defined(CONNECT_DIM_AFTER_CONNECTION)
if (connect_dimAfterConnetionDelay > 0) {
connect_dimAfterConnetionDelay--;
if (connect_dimAfterConnetionDelay == 0) {
display.displayOff();
}
}
#endif
// Is the connection still valid ? Should we attempt to reconnect ??
#if defined(CONNECT_RETRY_AUTOMATICALLY)
if (WiFi.status() != WL_CONNECTED) {
for (int i = 0; i < CONNECT_RETRY_ATTEMPTS; i++) {
wifiStatus = connectSilently();
if (wifiStatus == WL_CONNECTED) break;
}
}
// If unable to connect to the network, return to the connection phase and try again ..
if (wifiStatus != WL_CONNECTED) return STATUS_CONNECT_INIT;
#endif
// Do stuff ..
delay(100);
}
}