calculate elapsed time rather than storing next fire time - avoids overflow issues
This commit is contained in:
parent
ec829173f9
commit
b197ee8a80
@ -1,16 +1,18 @@
|
|||||||
#include <APSettingsService.h>
|
#include <APSettingsService.h>
|
||||||
|
|
||||||
APSettingsService::APSettingsService(AsyncWebServer* server, FS* fs) : SettingsService(server, fs, AP_SETTINGS_SERVICE_PATH, AP_SETTINGS_FILE) {
|
APSettingsService::APSettingsService(AsyncWebServer* server, FS* fs) : SettingsService(server, fs, AP_SETTINGS_SERVICE_PATH, AP_SETTINGS_FILE) {
|
||||||
|
onConfigUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
APSettingsService::~APSettingsService() {}
|
APSettingsService::~APSettingsService() {}
|
||||||
|
|
||||||
void APSettingsService::loop() {
|
void APSettingsService::loop() {
|
||||||
unsigned long now = millis();
|
unsigned long currentMillis = millis();
|
||||||
if (_manageAtMillis <= now){
|
unsigned long manageElapsed = (unsigned long)(currentMillis - _lastManaged);
|
||||||
manageAP();
|
if (manageElapsed >= MANAGE_NETWORK_DELAY){
|
||||||
_manageAtMillis = now + MANAGE_NETWORK_DELAY;
|
_lastManaged = currentMillis;
|
||||||
}
|
manageAP();
|
||||||
|
}
|
||||||
handleDNS();
|
handleDNS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,5 +80,5 @@ void APSettingsService::writeToJsonObject(JsonObject& root) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void APSettingsService::onConfigUpdated() {
|
void APSettingsService::onConfigUpdated() {
|
||||||
_manageAtMillis = 0;
|
_lastManaged = millis() - MANAGE_NETWORK_DELAY;
|
||||||
}
|
}
|
@ -42,7 +42,7 @@ class APSettingsService : public SettingsService {
|
|||||||
String _password;
|
String _password;
|
||||||
|
|
||||||
// for the mangement delay loop
|
// for the mangement delay loop
|
||||||
unsigned long _manageAtMillis;
|
unsigned long _lastManaged;
|
||||||
|
|
||||||
// for the captive portal
|
// for the captive portal
|
||||||
DNSServer *_dnsServer;
|
DNSServer *_dnsServer;
|
||||||
@ -54,4 +54,4 @@ class APSettingsService : public SettingsService {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // end APSettingsConfig_h
|
#endif // end APSettingsConfig_h
|
Loading…
Reference in New Issue
Block a user