mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Global Webinterface Upgrade
This commit is contained in:
20
Time.ino
20
Time.ino
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user