mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
time works
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Utils\StringUtils.h"
|
||||
|
||||
#define ONE_MINUTE_s 60
|
||||
#define ONE_HOUR_m 60
|
||||
#define ONE_HOUR_s 60 * ONE_MINUTE_s
|
||||
|
||||
time_t t;
|
||||
@@ -13,22 +14,20 @@ String getTimeUnix() {
|
||||
t = time(NULL);
|
||||
tm = localtime(&t);
|
||||
Serial.printf("%04d/%02d/%02d(%s) %02d:%02d:%02d\n",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
wd[tm->tm_wday],
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, wd[tm->tm_wday],
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
delay(1000);
|
||||
time_t now = time(nullptr);
|
||||
if (now < 30000) {
|
||||
return "failed";
|
||||
} else {
|
||||
return String(now);
|
||||
}
|
||||
return String(now);
|
||||
}
|
||||
|
||||
boolean getUnixTimeStr(String& res) {
|
||||
time_t now = time(nullptr);
|
||||
res = String(now);
|
||||
return now < 30000;
|
||||
return now > 30000;
|
||||
}
|
||||
|
||||
String getTime() {
|
||||
@@ -158,3 +157,11 @@ unsigned long millis_passed(unsigned long start, unsigned long finish) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int getOffsetInSeconds(int timezone) {
|
||||
return getOffsetInMinutes(timezone) * ONE_MINUTE_s;
|
||||
}
|
||||
|
||||
int getOffsetInMinutes(int timezone) {
|
||||
return timezone * ONE_HOUR_m;
|
||||
}
|
||||
|
||||
16
src/main.cpp
16
src/main.cpp
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "HttpServer.h"
|
||||
#include "Bus/BusScanner.h"
|
||||
#include "Utils/Timings.h"
|
||||
|
||||
void not_async_actions();
|
||||
|
||||
@@ -84,22 +85,27 @@ void saveConfig() {
|
||||
writeFile(String("config.json"), configSetupJson);
|
||||
}
|
||||
|
||||
Timings metric;
|
||||
|
||||
void loop() {
|
||||
#ifdef OTA_UPDATES_ENABLED
|
||||
ArduinoOTA.handle();
|
||||
#endif
|
||||
|
||||
#ifdef WS_enable
|
||||
ws.cleanupClients();
|
||||
#endif
|
||||
|
||||
metric.add(MT_ONE);
|
||||
not_async_actions();
|
||||
|
||||
metric.add(MT_TWO);
|
||||
MqttClient::loop();
|
||||
|
||||
loopCmd();
|
||||
|
||||
loopButton();
|
||||
|
||||
loopScenario();
|
||||
|
||||
#ifdef UDP_ENABLED
|
||||
loopUdp();
|
||||
#endif
|
||||
@@ -107,6 +113,12 @@ void loop() {
|
||||
loopSerial();
|
||||
|
||||
ts.update();
|
||||
|
||||
if (metric._counter > 100000) {
|
||||
metric.print();
|
||||
} else {
|
||||
metric.count();
|
||||
}
|
||||
}
|
||||
|
||||
void not_async_actions() {
|
||||
|
||||
Reference in New Issue
Block a user