NTP time added

This commit is contained in:
richonguzman
2024-10-14 11:44:22 -03:00
parent 03ccd2b12e
commit 79cf50a630
12 changed files with 134 additions and 15 deletions
+33
View File
@@ -0,0 +1,33 @@
#include <NTPClient.h>
#include <WiFiUdp.h>
#include "configuration.h"
#include "ntp_utils.h"
#include "time.h"
extern Configuration Config;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 0, 15 * 60 * 1000); // Update interval 15 min
namespace NTP_Utils {
void setup() {
if (!Config.digi.ecoMode && Config.callsign != "NOCALL-10") {
int gmt = Config.ntp.gmtCorrection * 3600;
timeClient.setTimeOffset(gmt);
timeClient.begin();
}
}
void update() {
if (!Config.digi.ecoMode && Config.callsign != "NOCALL-10") timeClient.update();
}
String getFormatedTime() {
if (!Config.digi.ecoMode) return timeClient.getFormattedTime();
return "DigiEcoMode Active";
}
}