diff --git a/data/igate_conf.json b/data/igate_conf.json
index ba5dd8c..e8e8fab 100644
--- a/data/igate_conf.json
+++ b/data/igate_conf.json
@@ -81,6 +81,9 @@
"username": "admin",
"password": ""
},
+ "ntp": {
+ "gmtCorrection": 0
+ },
"other": {
"rememberStationTime": 30,
"lowPowerMode": false,
diff --git a/data_embed/index.html b/data_embed/index.html
index 8ddf42a..a804b2c 100644
--- a/data_embed/index.html
+++ b/data_embed/index.html
@@ -1639,6 +1639,55 @@
+
+
+
+
+ NTP
+
+
Set your GMT Time Zone.
+
+
+
+
+
+
+
+ hours
+
+
+
+
+
+
diff --git a/data_embed/script.js b/data_embed/script.js
index 0fca694..86d42da 100644
--- a/data_embed/script.js
+++ b/data_embed/script.js
@@ -208,6 +208,9 @@ function loadSettings(settings) {
document.getElementById("webadmin.username").value = settings.webadmin.username;
document.getElementById("webadmin.password").value = settings.webadmin.password;
+ // NTP
+ document.getElementById("ntp.gmtCorrection").value = settings.ntp.gmtCorrection;
+
// Experimental
document.getElementById("other.backupDigiMode").checked = settings.other.backupDigiMode;
@@ -507,13 +510,9 @@ function loadReceivedPackets(packets) {
packets.forEach((packet) => {
const element = document.createElement("tr");
-
- date.setTime(packet.millis);
-
- const p = date.toUTCString().split(' ')
element.innerHTML = `
- ${p[p.length-2]} |
+ ${packet.rxTime} |
${packet.packet} |
${packet.RSSI} |
${packet.SNR} |
diff --git a/platformio.ini b/platformio.ini
index 9a14ef0..baf5bc6 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -40,6 +40,7 @@ lib_deps =
ayushsharma82/ElegantOTA @ 3.1.5
mathieucarbou/ESPAsyncWebServer @ 3.2.3
mathieucarbou/AsyncTCP @ 3.2.5
+ arduino-libraries/NTPClient @ 3.2.1
[env:ttgo-lora32-v21]
board = ttgo-lora32-v21
diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp
index 7f5b7ed..55d045e 100644
--- a/src/LoRa_APRS_iGate.cpp
+++ b/src/LoRa_APRS_iGate.cpp
@@ -31,6 +31,7 @@ ________________________________________________________________________________
#include "gps_utils.h"
#include "web_utils.h"
#include "tnc_utils.h"
+#include "ntp_utils.h"
#include "wx_utils.h"
#include "display.h"
#include "utils.h"
@@ -38,7 +39,7 @@ ________________________________________________________________________________
#include "A7670_utils.h"
#endif
-String versionDate = "2024.10.08";
+String versionDate = "2024.10.14";
Configuration Config;
WiFiClient espClient;
@@ -67,8 +68,8 @@ void setup() {
GPS_Utils::generateBeacons();
#ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers
- displayShow("", " STARTUP DELAY ...", "", "", 0);
- delay(STARTUP_DELAY * 60 * 1000);
+ displayShow("", " STARTUP DELAY ...", "", "", 0);
+ delay(STARTUP_DELAY * 60 * 1000);
#endif
#ifdef HELTEC_HTCT62
@@ -113,6 +114,7 @@ void setup() {
#endif
DIGI_Utils::checkEcoMode();
WIFI_Utils::setup();
+ NTP_Utils::setup();
SYSLOG_Utils::setup();
WX_Utils::setup();
WEB_Utils::setup();
@@ -145,6 +147,7 @@ void loop() {
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
#endif
+ NTP_Utils::update();
TNC_Utils::loop();
Utils::checkDisplayInterval();
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 1ea0a7b..93077ca 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -100,6 +100,8 @@ void Configuration::writeFile() {
data["webadmin"]["username"] = webadmin.username;
data["webadmin"]["password"] = webadmin.password;
+ data["ntp"]["gmtCorrection"] = ntp.gmtCorrection;
+
serializeJson(data, configFile);
configFile.close();
@@ -201,6 +203,8 @@ bool Configuration::readFile() {
webadmin.username = data["webadmin"]["username"] | "admin";
webadmin.password = data["webadmin"]["password"] | "";
+ ntp.gmtCorrection = data["ntp"]["gmtCorrection"] | 0;
+
lowPowerMode = data["other"]["lowPowerMode"] | false;
lowVoltageCutOff = data["other"]["lowVoltageCutOff"] | 0;
@@ -318,6 +322,8 @@ void Configuration::init() {
webadmin.username = "admin";
webadmin.password = "";
+ ntp.gmtCorrection = 0;
+
Serial.println("All is Written!");
}
diff --git a/src/configuration.h b/src/configuration.h
index 0ac7292..8ff6d02 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -115,6 +115,13 @@ class WEBADMIN {
String password;
};
+class NTP {
+public:
+ int gmtCorrection;
+};
+
+
+
class Configuration {
public:
String callsign;
@@ -138,6 +145,7 @@ class Configuration {
TNC tnc;
OTA ota;
WEBADMIN webadmin;
+ NTP ntp;
void init();
void writeFile();
diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp
index da9105d..e6b60f5 100644
--- a/src/lora_utils.cpp
+++ b/src/lora_utils.cpp
@@ -4,6 +4,7 @@
#include "aprs_is_utils.h"
#include "boards_pinout.h"
#include "syslog_utils.h"
+#include "ntp_utils.h"
#include "display.h"
#include "utils.h"
@@ -175,9 +176,9 @@ namespace LoRa_Utils {
Utils::println("<--- LoRa Packet Rx : " + packet.substring(3));
Utils::println("(RSSI:" + String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")");
- if (!Config.lowPowerMode) {
+ if (!Config.lowPowerMode && !Config.digi.ecoMode) {
ReceivedPacket receivedPacket;
- receivedPacket.millis = millis();
+ receivedPacket.rxTime = NTP_Utils::getFormatedTime();
receivedPacket.packet = packet.substring(3);
receivedPacket.RSSI = rssi;
receivedPacket.SNR = snr;
diff --git a/src/ntp_utils.cpp b/src/ntp_utils.cpp
new file mode 100644
index 0000000..2955f0a
--- /dev/null
+++ b/src/ntp_utils.cpp
@@ -0,0 +1,33 @@
+#include
+#include
+#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";
+ }
+
+}
\ No newline at end of file
diff --git a/src/ntp_utils.h b/src/ntp_utils.h
new file mode 100644
index 0000000..661eca0
--- /dev/null
+++ b/src/ntp_utils.h
@@ -0,0 +1,14 @@
+#ifndef NTP_UTILS_H_
+#define NTP_UTILS_H_
+
+#include
+
+namespace NTP_Utils {
+
+ void setup();
+ void update();
+ String getFormatedTime();
+
+}
+
+#endif
\ No newline at end of file
diff --git a/src/utils.h b/src/utils.h
index ae55f26..1ad925d 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -5,7 +5,7 @@
class ReceivedPacket {
public:
- long millis;
+ String rxTime;
String packet;
int RSSI;
float SNR;
diff --git a/src/web_utils.cpp b/src/web_utils.cpp
index 25ec6f5..00d7b02 100644
--- a/src/web_utils.cpp
+++ b/src/web_utils.cpp
@@ -81,10 +81,10 @@ namespace WEB_Utils {
StaticJsonDocument<1536> data;
for (int i = 0; i < receivedPackets.size(); i++) {
- data[i]["millis"] = receivedPackets[i].millis;
- data[i]["packet"] = receivedPackets[i].packet;
- data[i]["RSSI"] = receivedPackets[i].RSSI;
- data[i]["SNR"] = receivedPackets[i].SNR;
+ data[i]["rxTime"] = receivedPackets[i].rxTime;
+ data[i]["packet"] = receivedPackets[i].packet;
+ data[i]["RSSI"] = receivedPackets[i].RSSI;
+ data[i]["SNR"] = receivedPackets[i].SNR;
}
String buffer;
@@ -208,6 +208,8 @@ namespace WEB_Utils {
Config.webadmin.password = request->getParam("webadmin.password", true)->value();
}
+ Config.ntp.gmtCorrection = request->getParam("ntp.gmtCorrection", true)->value().toInt();
+
Config.writeFile();
AsyncWebServerResponse *response = request->beginResponse(302, "text/html", "");