From 83c5d74d7a20ee52fa8eb2f20b0091eb917bb1f3 Mon Sep 17 00:00:00 2001 From: biver Date: Sat, 30 Apr 2022 09:28:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BD=D1=8F=D0=B5=D0=BC=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=20=D1=88=D1=82=D0=B0=D0=BC=D0=BF?= =?UTF-8?q?=D0=B0=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=B2=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Main.cpp | 6 +++--- src/utils/SerialPrint.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index cdb8be18..01b5d131 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -36,7 +36,7 @@ void setup() { String ntpServer = jsonReadStr(settingsFlashJson, F("ntp")); int timezone = jsonReadInt(settingsFlashJson, F("timezone")); configTime(3600*timezone, 0, ntpServer.c_str(), "ru.pool.ntp.org", "pool.ntp.org"); - Serial.print("Start syncing NTP time"); + Serial.println("Start syncing NTP time"); time(&iotTimeNow); // int i = 0; // while (isNetworkActive() && iotTimeNow < 1510592825 && i < 200) @@ -52,8 +52,8 @@ void setup() { watch = new IoTRTC(0); // создаем объект главного хранилища времени, но с заглушкой (0) для получения системного времени watch->period(60); // время в минутах для синхронизации с часами реального времени или системным watch->begin(); - Serial.print(F("Time from Local: ")); - Serial.println(watch->gettime("d-m-Y, H:i:s, M")); + //Serial.print(F("Time from Local: ")); + //Serial.println(watch->gettime("d-m-Y, H:i:s, M")); //инициализация асинхронного веб сервера и веб сокетов #ifdef ASYNC_WEB_SERVER diff --git a/src/utils/SerialPrint.cpp b/src/utils/SerialPrint.cpp index 7a2e9b40..ed4c7cbc 100644 --- a/src/utils/SerialPrint.cpp +++ b/src/utils/SerialPrint.cpp @@ -1,8 +1,15 @@ #include "utils/SerialPrint.h" +#include "classes/IoTRTC.h" + +extern IoTRTC *watch; void SerialPrint(String errorLevel, String module, String msg) { - String tosend = prettyMillis(millis()) + " [" + errorLevel + "] [" + module + "] " + msg; + String tosend; + if (watch) tosend = watch->gettime("d.m.y H:i:s"); + else tosend = prettyMillis(millis()); + + tosend = tosend + " [" + errorLevel + "] [" + module + "] " + msg; Serial.println(tosend); if (isNetworkActive()) {