projects
/
manu
/
arduino-maison.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c2263c0
)
Fix wifi reconnect
author
Emmanuel Lacour
<elacour@easter-eggs.com>
Wed, 22 Dec 2021 21:01:44 +0000
(22:01 +0100)
committer
Emmanuel Lacour
<elacour@easter-eggs.com>
Wed, 22 Dec 2021 21:01:44 +0000
(22:01 +0100)
station-meteo/station-meteo.ino
patch
|
blob
|
history
diff --git
a/station-meteo/station-meteo.ino
b/station-meteo/station-meteo.ino
index
589c4bb
..
5a96ba8
100644
(file)
--- a/
station-meteo/station-meteo.ino
+++ b/
station-meteo/station-meteo.ino
@@
-73,10
+73,15
@@
void setup(void)
Serial.println(wifi_ssid);
// Connect to WPA/WPA2 network
WiFi.begin(wifi_ssid, wifi_pass);
Serial.println(wifi_ssid);
// Connect to WPA/WPA2 network
WiFi.begin(wifi_ssid, wifi_pass);
+ delay(500);
// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
+ WiFi.begin(wifi_ssid, wifi_pass);
delay(500);
delay(500);
+ if (WiFi.status() != WL_CONNECTED) {
+ delay(2000);
+ }
}
Serial.println("Connected to wifi");
}
Serial.println("Connected to wifi");
@@
-92,13
+97,12
@@
void loop(void)
{
delay(POLL_INT);
{
delay(POLL_INT);
- // Check wifi connexion
- if ( WiFi.status() != WL_CONNECTED ) {
- int retry = 0;
+ // Reconnect if needed
+ while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(wifi_ssid, wifi_pass);
WiFi.begin(wifi_ssid, wifi_pass);
- while (retry < 10 || WiFi.status() != WL_CONNECTED) {
- retry++;
- delay(
5
00);
+ delay(500);
+ if (WiFi.status() != WL_CONNECTED) {
+ delay(
20
00);
}
}
}
}