mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add button to force fetch NTP time
This commit is contained in:
@@ -2303,6 +2303,9 @@ void MyESP::_procMsg(AsyncWebSocketClient * client, size_t sz) {
|
||||
_shouldRestart = true;
|
||||
} else if (strcmp(command, "destroy") == 0) {
|
||||
_formatreq = true;
|
||||
} else if (strcmp(command, "forcentp") == 0) {
|
||||
myDebug("HHHH"); // XXX
|
||||
NTP.getNtpTime();
|
||||
} else if (strcmp(command, "geteventlog") == 0) {
|
||||
uint8_t page = doc["page"];
|
||||
_sendEventLog(page);
|
||||
|
||||
@@ -27,7 +27,6 @@ class NtpClient {
|
||||
|
||||
static byte NTPpacket[NTP_PACKET_SIZE];
|
||||
|
||||
private:
|
||||
static ICACHE_FLASH_ATTR time_t getNtpTime();
|
||||
};
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ function listCustomStats() {
|
||||
} else {
|
||||
var color = "";
|
||||
}
|
||||
l.innerHTML = obj[i].model + ", Version:" + obj[i].version + ", ProductID:" + obj[i].productid + ", DeviceID:" + obj[i].deviceid;
|
||||
l.innerHTML = obj[i].model + " (Version:" + obj[i].version + " ProductID:" + obj[i].productid + " DeviceID:0x" + obj[i].deviceid + ")";
|
||||
l.className = "list-group-item list-group-item-" + color;
|
||||
list.appendChild(l);
|
||||
}
|
||||
|
||||
@@ -1713,9 +1713,13 @@ void WebCallback(JsonObject root) {
|
||||
JsonObject item = list.createNestedObject();
|
||||
item["type"] = (it)->model_type;
|
||||
item["model"] = (it)->model_string;
|
||||
item["deviceid"] = (it)->device_id;
|
||||
item["version"] = (it)->version;
|
||||
item["productid"] = (it)->product_id;
|
||||
|
||||
char s[10];
|
||||
itoa((it)->device_id,s, 16);
|
||||
item["deviceid"] = s; // convert to hex
|
||||
|
||||
}
|
||||
|
||||
JsonObject thermostat = root.createNestedObject("thermostat");
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
<div>
|
||||
<br>
|
||||
<legend>Event Log</legend>
|
||||
<h6 class="text-muted">Dates shown in () represent elapsed time in seconds when NTP is disabled</h6>
|
||||
<h6 class="text-muted">Dates shown in () represent elapsed time in seconds when NTP Time is disabled</h6>
|
||||
<br>
|
||||
<div class="panel panel-default">
|
||||
<div>
|
||||
@@ -282,11 +282,12 @@
|
||||
<div id="ntpcontent">
|
||||
<br>
|
||||
<legend>Time Settings</legend>
|
||||
<h6 class="text-muted">With NTP enabled, all times are adjusted to the local timezone and respect daylight saving
|
||||
<h6 class="text-muted">With Network Time Protocol (NTP) enabled, all times are adjusted to the local timezone and
|
||||
respect daylight saving
|
||||
time (DST)</h6>
|
||||
<br>
|
||||
<div class="row form-group">
|
||||
<label class="col-xs-3">Device Time</label>
|
||||
<label class="col-xs-3">Device Time (UTC)</label>
|
||||
<span id="utc" class="col-xs-9 col-md-5">
|
||||
</span>
|
||||
</div>
|
||||
@@ -310,10 +311,12 @@
|
||||
<div class="col-xs-9">
|
||||
<form>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="1" name="ntpenabled">Enabled</label>
|
||||
<input type="radio" value="1" onclick="handleNTPON();" name="ntpenabled">Enabled</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="0" name="ntpenabled" checked>Disabled</label>
|
||||
<input type="radio" value="0" onclick="handleNTPOFF();" name="ntpenabled" checked>Disabled</label>
|
||||
</form>
|
||||
<button onclick="forcentp()" id="forcentp" class="btn btn-primary btn-xs">Fetch internet time</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
@@ -327,7 +330,7 @@
|
||||
<br>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label class="col-xs-3">Refresh Time<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
|
||||
<label class="col-xs-3">Recalibrate Time<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
|
||||
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
|
||||
data-content="Time in minutes between scheduled NTP refreshes"></i></label>
|
||||
<span class="col-xs-9 col-md-5">
|
||||
|
||||
@@ -51,7 +51,7 @@ function browserTime() {
|
||||
}
|
||||
|
||||
function deviceTime() {
|
||||
var t = new Date(0); // The 0 there is the key, which sets the date to the epoch,
|
||||
var t = new Date(0); // The 0 there is the key, which sets the date to the epoch
|
||||
var devTime = Math.floor(utcSeconds + ((t.getTimezoneOffset() * 60) * -1));
|
||||
t.setUTCSeconds(devTime);
|
||||
document.getElementById("utc").innerHTML = t.toUTCString().slice(0, -3);
|
||||
@@ -75,6 +75,9 @@ function listntp() {
|
||||
|
||||
if (config.ntp.enabled) {
|
||||
$("input[name=\"ntpenabled\"][value=\"1\"]").prop("checked", true);
|
||||
handleNTPON();
|
||||
} else {
|
||||
handleNTPOFF();
|
||||
}
|
||||
|
||||
browserTime();
|
||||
@@ -114,6 +117,11 @@ function saventp() {
|
||||
uncommited();
|
||||
}
|
||||
|
||||
function forcentp() {
|
||||
websock.send("{\"command\":\"forcentp\"}");
|
||||
}
|
||||
|
||||
|
||||
function savegeneral() {
|
||||
var a = document.getElementById("adminpwd").value;
|
||||
if (a === null || a === "") {
|
||||
@@ -238,6 +246,14 @@ function handleAP() {
|
||||
document.getElementById("inputtohide").style.display = "block";
|
||||
}
|
||||
|
||||
function handleNTPON() {
|
||||
document.getElementById("forcentp").style.display = "block";
|
||||
}
|
||||
|
||||
function handleNTPOFF() {
|
||||
document.getElementById("forcentp").style.display = "none";
|
||||
}
|
||||
|
||||
function listnetwork() {
|
||||
document.getElementById("inputtohide").value = config.network.ssid;
|
||||
document.getElementById("wifipass").value = config.network.password;
|
||||
|
||||
@@ -252,6 +252,9 @@ wss.on('connection', function connection(ws) {
|
||||
case "destroy":
|
||||
console.log("[INFO] Destroy");
|
||||
break;
|
||||
case "forcentp":
|
||||
console.log("[INFO] getting ntp time");
|
||||
break;
|
||||
default:
|
||||
console.log("[WARN] Unknown command ");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user