mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +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;
|
_shouldRestart = true;
|
||||||
} else if (strcmp(command, "destroy") == 0) {
|
} else if (strcmp(command, "destroy") == 0) {
|
||||||
_formatreq = true;
|
_formatreq = true;
|
||||||
|
} else if (strcmp(command, "forcentp") == 0) {
|
||||||
|
myDebug("HHHH"); // XXX
|
||||||
|
NTP.getNtpTime();
|
||||||
} else if (strcmp(command, "geteventlog") == 0) {
|
} else if (strcmp(command, "geteventlog") == 0) {
|
||||||
uint8_t page = doc["page"];
|
uint8_t page = doc["page"];
|
||||||
_sendEventLog(page);
|
_sendEventLog(page);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class NtpClient {
|
|||||||
|
|
||||||
static byte NTPpacket[NTP_PACKET_SIZE];
|
static byte NTPpacket[NTP_PACKET_SIZE];
|
||||||
|
|
||||||
private:
|
|
||||||
static ICACHE_FLASH_ATTR time_t getNtpTime();
|
static ICACHE_FLASH_ATTR time_t getNtpTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ function listCustomStats() {
|
|||||||
} else {
|
} else {
|
||||||
var color = "";
|
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;
|
l.className = "list-group-item list-group-item-" + color;
|
||||||
list.appendChild(l);
|
list.appendChild(l);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1713,9 +1713,13 @@ void WebCallback(JsonObject root) {
|
|||||||
JsonObject item = list.createNestedObject();
|
JsonObject item = list.createNestedObject();
|
||||||
item["type"] = (it)->model_type;
|
item["type"] = (it)->model_type;
|
||||||
item["model"] = (it)->model_string;
|
item["model"] = (it)->model_string;
|
||||||
item["deviceid"] = (it)->device_id;
|
|
||||||
item["version"] = (it)->version;
|
item["version"] = (it)->version;
|
||||||
item["productid"] = (it)->product_id;
|
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");
|
JsonObject thermostat = root.createNestedObject("thermostat");
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<br>
|
<br>
|
||||||
<legend>Event Log</legend>
|
<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>
|
<br>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div>
|
<div>
|
||||||
@@ -282,11 +282,12 @@
|
|||||||
<div id="ntpcontent">
|
<div id="ntpcontent">
|
||||||
<br>
|
<br>
|
||||||
<legend>Time Settings</legend>
|
<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>
|
time (DST)</h6>
|
||||||
<br>
|
<br>
|
||||||
<div class="row form-group">
|
<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 id="utc" class="col-xs-9 col-md-5">
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -310,10 +311,12 @@
|
|||||||
<div class="col-xs-9">
|
<div class="col-xs-9">
|
||||||
<form>
|
<form>
|
||||||
<label class="radio-inline">
|
<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">
|
<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>
|
</form>
|
||||||
|
<button onclick="forcentp()" id="forcentp" class="btn btn-primary btn-xs">Fetch internet time</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row form-group">
|
<div class="row form-group">
|
||||||
@@ -327,7 +330,7 @@
|
|||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
<div class="row form-group">
|
<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"
|
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
|
||||||
data-content="Time in minutes between scheduled NTP refreshes"></i></label>
|
data-content="Time in minutes between scheduled NTP refreshes"></i></label>
|
||||||
<span class="col-xs-9 col-md-5">
|
<span class="col-xs-9 col-md-5">
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function browserTime() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deviceTime() {
|
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));
|
var devTime = Math.floor(utcSeconds + ((t.getTimezoneOffset() * 60) * -1));
|
||||||
t.setUTCSeconds(devTime);
|
t.setUTCSeconds(devTime);
|
||||||
document.getElementById("utc").innerHTML = t.toUTCString().slice(0, -3);
|
document.getElementById("utc").innerHTML = t.toUTCString().slice(0, -3);
|
||||||
@@ -75,6 +75,9 @@ function listntp() {
|
|||||||
|
|
||||||
if (config.ntp.enabled) {
|
if (config.ntp.enabled) {
|
||||||
$("input[name=\"ntpenabled\"][value=\"1\"]").prop("checked", true);
|
$("input[name=\"ntpenabled\"][value=\"1\"]").prop("checked", true);
|
||||||
|
handleNTPON();
|
||||||
|
} else {
|
||||||
|
handleNTPOFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
browserTime();
|
browserTime();
|
||||||
@@ -114,6 +117,11 @@ function saventp() {
|
|||||||
uncommited();
|
uncommited();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function forcentp() {
|
||||||
|
websock.send("{\"command\":\"forcentp\"}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function savegeneral() {
|
function savegeneral() {
|
||||||
var a = document.getElementById("adminpwd").value;
|
var a = document.getElementById("adminpwd").value;
|
||||||
if (a === null || a === "") {
|
if (a === null || a === "") {
|
||||||
@@ -238,6 +246,14 @@ function handleAP() {
|
|||||||
document.getElementById("inputtohide").style.display = "block";
|
document.getElementById("inputtohide").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleNTPON() {
|
||||||
|
document.getElementById("forcentp").style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNTPOFF() {
|
||||||
|
document.getElementById("forcentp").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
function listnetwork() {
|
function listnetwork() {
|
||||||
document.getElementById("inputtohide").value = config.network.ssid;
|
document.getElementById("inputtohide").value = config.network.ssid;
|
||||||
document.getElementById("wifipass").value = config.network.password;
|
document.getElementById("wifipass").value = config.network.password;
|
||||||
|
|||||||
@@ -252,6 +252,9 @@ wss.on('connection', function connection(ws) {
|
|||||||
case "destroy":
|
case "destroy":
|
||||||
console.log("[INFO] Destroy");
|
console.log("[INFO] Destroy");
|
||||||
break;
|
break;
|
||||||
|
case "forcentp":
|
||||||
|
console.log("[INFO] getting ntp time");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("[WARN] Unknown command ");
|
console.log("[WARN] Unknown command ");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user