Op ntp server

This commit is contained in:
richonguzman 2025-10-11 12:40:07 -03:00
parent 1abaa299e0
commit 2a86cdb0d8
9 changed files with 30 additions and 6 deletions

View file

@ -52,6 +52,7 @@ ____________________________________________________
# Timeline (Versions):
- 2025-10-11 User defined NTP server added.
- 2025-10-10 Changed Wiki into a pdf manual.
- 2025-09-26 Heltec Wireless Bridge support added.
- 2025-09-09 MQTT added (pub+sub), Status defined by Op now and many fixes more.

View file

@ -101,6 +101,7 @@
"rfOnly": true
},
"ntp": {
"server": "pool.ntp.org",
"gmtCorrection": 0.0
},
"other": {

View file

@ -1990,6 +1990,21 @@
</small>
</div>
<div class="col-lg-9 col-sm-12">
<div class="col-12">
<label
for="ntp.server"
class="form-label"
>NTP Server hostname</label
>
<div class="input-group">
<input
type="text"
name="ntp.server"
id="ntp.server"
class="form-control"
/>
</div>
</div>
<div class="col-12">
<label
for="ntp.gmtCorrection"

View file

@ -241,6 +241,7 @@ function loadSettings(settings) {
document.getElementById("remoteManagement.rfOnly").checked = settings.remoteManagement.rfOnly;
// NTP
document.getElementById("ntp.server").value = settings.ntp.server;
document.getElementById("ntp.gmtCorrection").value = settings.ntp.gmtCorrection;
// Experimental

View file

@ -140,6 +140,7 @@ public:
class NTP {
public:
String server;
float gmtCorrection;
};

View file

@ -67,8 +67,8 @@ ___________________________________________________________________*/
#endif
String versionDate = "2025-09-26";
String versionNumber = "3.1.2.1";
String versionDate = "2025-10-11";
String versionNumber = "3.1.3";
Configuration Config;
WiFiClient aprsIsClient;
WiFiClient mqttClient;

View file

@ -140,6 +140,7 @@ bool Configuration::writeFile() {
data["remoteManagement"]["managers"] = remoteManagement.managers;
data["remoteManagement"]["rfOnly"] = remoteManagement.rfOnly;
data["ntp"]["server"] = ntp.server;
data["ntp"]["gmtCorrection"] = ntp.gmtCorrection;
data["other"]["rebootMode"] = rebootMode;
@ -345,7 +346,9 @@ bool Configuration::readFile() {
remoteManagement.managers = data["remoteManagement"]["managers"] | "";
remoteManagement.rfOnly = data["remoteManagement"]["rfOnly"] | true;
if (!data["ntp"].containsKey("gmtCorrection")) needsRewrite = true;
if (!data["ntp"].containsKey("server") ||
!data["ntp"].containsKey("gmtCorrection")) needsRewrite = true;
ntp.server = data["ntp"]["server"] | "pool.ntp.org";
ntp.gmtCorrection = data["ntp"]["gmtCorrection"] | 0.0;
if (!data["other"].containsKey("rebootMode") ||
@ -371,7 +374,7 @@ bool Configuration::readFile() {
if (needsRewrite) {
Serial.println("Config JSON incomplete, rewriting...");
writeFile();
delay(500);
delay(1000);
ESP.restart();
}
Serial.println("Config read successfuly");
@ -482,6 +485,7 @@ void Configuration::setDefaultValues() {
remoteManagement.managers = "";
remoteManagement.rfOnly = true;
ntp.server = "pool.ntp.org";
ntp.gmtCorrection = 0.0;
rebootMode = false;
@ -506,7 +510,7 @@ Configuration::Configuration() {
if (!exists) {
setDefaultValues();
writeFile();
delay(500);
delay(1000);
ESP.restart();
}

View file

@ -27,7 +27,7 @@
extern Configuration Config;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 0, 15 * 60 * 1000); // Update interval 15 min
NTPClient timeClient(ntpUDP, Config.ntp.server.c_str(), 0, 15 * 60 * 1000); // Update interval 15 min
namespace NTP_Utils {

View file

@ -281,6 +281,7 @@ namespace WEB_Utils {
Config.remoteManagement.managers = getParamStringSafe("remoteManagement.managers", Config.remoteManagement.managers);
Config.remoteManagement.rfOnly = request->hasParam("remoteManagement.rfOnly", true);
Config.ntp.server = getParamStringSafe("ntp.server", Config.ntp.server);
Config.ntp.gmtCorrection = getParamFloatSafe("ntp.gmtCorrection", Config.ntp.gmtCorrection);
Config.rememberStationTime = getParamIntSafe("other.rememberStationTime", Config.rememberStationTime);