optimize OTA handling
This commit is contained in:
parent
35440ecca0
commit
03a1fc0e21
@ -4,6 +4,8 @@
|
||||
#include "ntp_time.h"
|
||||
#include "display.h"
|
||||
|
||||
#define STAY_CONNECTED_FOR_MINS(min) (min*60)
|
||||
|
||||
int currentHour = -1;
|
||||
time_t timeAtStartup;
|
||||
|
||||
@ -22,9 +24,7 @@ void setup() {
|
||||
timeAtStartup = updateTime();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
ArduinoOTA.handle();
|
||||
|
||||
void loop() {
|
||||
if ((currentHour != hour())) {
|
||||
wifi.reconnect();
|
||||
wifi.printStatus();
|
||||
@ -33,8 +33,11 @@ void loop() {
|
||||
}
|
||||
currentHour = hour();
|
||||
}
|
||||
if (WiFi.status() == WL_CONNECTED && difftime(now(), timeAtStartup) > 60) {
|
||||
wifi.disconnect();
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
ArduinoOTA.handle();
|
||||
if (difftime(now(), timeAtStartup) > STAY_CONNECTED_FOR_MINS(1)) {
|
||||
wifi.disconnect();
|
||||
}
|
||||
}
|
||||
displayTime();
|
||||
displayColon(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user