Global Webinterface Upgrade

This commit is contained in:
Dmitry Borisenko
2020-05-28 00:33:26 +02:00
parent 48ddb1a505
commit 3135e5658f
20 changed files with 390 additions and 388 deletions

View File

@@ -1,16 +1,4 @@
void Time_Init() {
server.on("/time", HTTP_GET, [](AsyncWebServerRequest * request) {
if (request->hasArg("timezone")) {
jsonWriteStr(configSetup, "timezone", request->getParam("timezone")->value());
}
if (request->hasArg("ntp")) {
jsonWriteStr(configSetup, "ntp", request->getParam("ntp")->value());
}
saveConfig();
reconfigTime();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
ts.add(TIME_SYNC, 30000, [&](void*) {
time_check();
}, nullptr, true);
@@ -24,11 +12,11 @@ void time_check() {
}
void reconfigTime() {
if (WiFi.status() == WL_CONNECTED) {
if (WiFi.status() == WL_CONNECTED) {
String ntp = jsonReadStr(configSetup, "ntp");
configTime(0, 0, ntp.c_str());
configTime(0, 0, ntp.c_str());
int i = 0;
Serial.println("[i] Awaiting for time ");
Serial.println("[i] Awaiting for time ");
#ifdef ESP32
struct tm timeinfo;
while (!getLocalTime(&timeinfo) && i <= 4) {
@@ -41,7 +29,7 @@ void reconfigTime() {
//while (!time(nullptr) && i < 4) {
// Serial.print(".");
// i++;
delay(2000);
delay(2000);
//}
#endif
if (GetTimeUnix() != "failed") {