NTP time added
This commit is contained in:
parent
03ccd2b12e
commit
79cf50a630
|
|
@ -81,6 +81,9 @@
|
|||
"username": "admin",
|
||||
"password": ""
|
||||
},
|
||||
"ntp": {
|
||||
"gmtCorrection": 0
|
||||
},
|
||||
"other": {
|
||||
"rememberStationTime": 30,
|
||||
"lowPowerMode": false,
|
||||
|
|
|
|||
|
|
@ -1639,6 +1639,55 @@
|
|||
</div>
|
||||
<hr />
|
||||
|
||||
<div class="row my-5 d-flex align-items-top">
|
||||
<div class="col-lg-3 col-sm-12">
|
||||
<h5>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="20"
|
||||
height="20"
|
||||
fill="currentColor"
|
||||
class="bi bi-cloud-upload-fill"
|
||||
viewBox="0 0 16 16"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M8 0a5.53 5.53 0 0 0-3.594 1.342c-.766.66-1.321 1.52-1.464 2.383C1.266 4.095 0 5.555 0 7.318 0 9.366 1.708 11 3.781 11H7.5V5.707L5.354 7.854a.5.5 0 1 1-.708-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 5.707V11h4.188C14.502 11 16 9.57 16 7.773c0-1.636-1.242-2.969-2.834-3.194C12.923 1.999 10.69 0 8 0m-.5 14.5V11h1v3.5a.5.5 0 0 1-1 0"
|
||||
/>
|
||||
</svg>
|
||||
NTP
|
||||
</h5>
|
||||
<small
|
||||
>Set your GMT Time Zone.
|
||||
</small>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-12">
|
||||
<div class="col-12">
|
||||
<label
|
||||
for="ntp.gmtCorrection"
|
||||
class="form-label"
|
||||
>GMT Time Correction for accurate Local Time</label
|
||||
>
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="number"
|
||||
name="ntp.gmtCorrection"
|
||||
id="ntp.gmtCorrection"
|
||||
placeholder="0"
|
||||
class="form-control"
|
||||
step="1"
|
||||
min="-23"
|
||||
max="23"
|
||||
/>
|
||||
<span class="input-group-text"
|
||||
>hours</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div class="row my-5 d-flex align-items-top">
|
||||
<div class="col-lg-3 col-sm-12">
|
||||
<h5>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -508,12 +511,8 @@ function loadReceivedPackets(packets) {
|
|||
packets.forEach((packet) => {
|
||||
const element = document.createElement("tr");
|
||||
|
||||
date.setTime(packet.millis);
|
||||
|
||||
const p = date.toUTCString().split(' ')
|
||||
|
||||
element.innerHTML = `
|
||||
<td>${p[p.length-2]}</td>
|
||||
<td>${packet.rxTime}</td>
|
||||
<td>${packet.packet}</td>
|
||||
<td>${packet.RSSI}</td>
|
||||
<td>${packet.SNR}</td>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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!");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,13 @@ public:
|
|||
String password;
|
||||
};
|
||||
|
||||
class NTP {
|
||||
public:
|
||||
int gmtCorrection;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Configuration {
|
||||
public:
|
||||
String callsign;
|
||||
|
|
@ -138,6 +145,7 @@ public:
|
|||
TNC tnc;
|
||||
OTA ota;
|
||||
WEBADMIN webadmin;
|
||||
NTP ntp;
|
||||
|
||||
void init();
|
||||
void writeFile();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef NTP_UTILS_H_
|
||||
#define NTP_UTILS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace NTP_Utils {
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
String getFormatedTime();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class ReceivedPacket {
|
||||
public:
|
||||
long millis;
|
||||
String rxTime;
|
||||
String packet;
|
||||
int RSSI;
|
||||
float SNR;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace WEB_Utils {
|
|||
StaticJsonDocument<1536> data;
|
||||
|
||||
for (int i = 0; i < receivedPackets.size(); i++) {
|
||||
data[i]["millis"] = receivedPackets[i].millis;
|
||||
data[i]["rxTime"] = receivedPackets[i].rxTime;
|
||||
data[i]["packet"] = receivedPackets[i].packet;
|
||||
data[i]["RSSI"] = receivedPackets[i].RSSI;
|
||||
data[i]["SNR"] = receivedPackets[i].SNR;
|
||||
|
|
@ -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", "");
|
||||
|
|
|
|||
Loading…
Reference in New Issue