Try to (re)connect to WiFi every 5 minutes. (Only when not playing at the moment.)

This commit is contained in:
2019-11-29 05:45:21 +01:00
parent 63b9616677
commit 196021bef5
3 changed files with 51 additions and 35 deletions

View File

@ -1,4 +1,5 @@
#include "controller.h"
#include "main.h"
#include "spi_master.h"
#include "config.h"
#include "playlist.h"
@ -53,12 +54,18 @@ void Controller::loop() {
}
#ifdef OTA_UPDATE_URL
if (!player->is_playing() && _last_update_check_at<millis() && _last_update_check_at + OTA_CHECK_INTERVAL < millis()) {
if (!player->is_playing() && _last_update_check_at < now && _last_update_check_at + OTA_CHECK_INTERVAL < now) {
Updater::run();
} else {
_last_update_check_at = millis();
_last_update_check_at = now;
}
#endif
if (!player->is_playing() && !WiFi.isConnected() && _last_wifi_try_at < now && _last_wifi_try_at + 5*60*1000 < now) {
wifi_connect();
} else {
_last_wifi_try_at = now;
}
TRACE("Controller::loop() done.\n");
}