This commit is contained in:
Yuri Trikoz
2020-06-24 01:16:00 +03:00
parent b50911ddcf
commit e375cca3dc
16 changed files with 541 additions and 109 deletions

View File

@@ -268,4 +268,30 @@ int timeZoneInSeconds(const byte timeZone) {
break;
}
return res;
}
}
unsigned long millis_since(unsigned long sinse) {
return millis_passed(sinse, millis());
}
unsigned long millis_passed(unsigned long start, unsigned long finish) {
unsigned long result = 0;
if (start <= finish) {
unsigned long passed = finish - start;
if (passed <= __LONG_MAX__) {
result = static_cast<long>(passed);
} else {
result = static_cast<long>((__LONG_MAX__ - finish) + start + 1u);
}
} else {
unsigned long passed = start - finish;
if (passed <= __LONG_MAX__) {
result = static_cast<long>(passed);
result = -1 * result;
} else {
result = static_cast<long>((__LONG_MAX__ - start) + finish + 1u);
result = -1 * result;
}
}
return result;
}

View File

@@ -43,8 +43,9 @@ void startSTAMode() {
}
} while (keepConnecting && tries--);
if (WiFi.status() == WL_CONNECTED) {
initMQTT();
if (isNetworkActive()) {
MqttClient::init();
setLedStatus(LED_OFF);
} else {
startAPMode();