mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
libretiny
This commit is contained in:
22
src/NTP.cpp
22
src/NTP.cpp
@@ -1,9 +1,23 @@
|
||||
#include "NTP.h"
|
||||
|
||||
#if defined(LIBRETINY)
|
||||
#include "lwip/apps/sntp.h"
|
||||
#endif
|
||||
|
||||
#include "Global.h"
|
||||
#include "utils/SerialPrint.h"
|
||||
|
||||
void ntpInit() {
|
||||
#if defined(USE_LIBRETINY)
|
||||
if (sntp_enabled()) {
|
||||
sntp_stop();
|
||||
}
|
||||
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
||||
sntp_setservername(0, jsonReadStr(settingsFlashJson, F("ntp")).c_str());
|
||||
sntp_setservername(1, "pool.ntp.org");
|
||||
sntp_setservername(2, "ru.pool.ntp.org");
|
||||
sntp_init();
|
||||
#endif
|
||||
synchTime();
|
||||
|
||||
ts.add(
|
||||
@@ -44,7 +58,15 @@ void ntpInit() {
|
||||
}
|
||||
|
||||
void synchTime() {
|
||||
#if defined LIBRETINY
|
||||
// force resync
|
||||
if (sntp_enabled()) {
|
||||
sntp_stop();
|
||||
sntp_init();
|
||||
}
|
||||
#else
|
||||
configTime(0, 0, "pool.ntp.org", "ru.pool.ntp.org", jsonReadStr(settingsFlashJson, F("ntp")).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
//событие смены даты
|
||||
|
||||
Reference in New Issue
Block a user