541 версия

This commit is contained in:
IoT Manager
2023-10-06 01:36:13 +02:00
parent 487c44ef54
commit 9563b43bd9
3 changed files with 23 additions and 30 deletions

View File

@@ -44,18 +44,15 @@
const LOG_MAX_MESSAGES = 100;
let reconnectTimeout = 60; //период проверки соединения с устройством
let remainingTimeout = reconnectTimeout;
let connecting = true;
let tickerTask;
let preventReconnect = false;
const waitingAckTimeout = 18000; //время ожидания ответа от устройства
const rebootingTimeout = 30000;
const updatingTimeout = 130000;
let rebootOrUpdateProcess = false;
let rebootTimer;
let opened = true;
let preventMove = false;
let screenSize;
const blobDebug = false;
const devMode = true;
const devMode = false;
let percent;
@@ -977,7 +974,12 @@
tickerTask = setTimeout(wsTestMsgTask, 1000);
if (!preventReconnect) {
remainingTimeout--;
if (socketConnected) showAwaitingCircle = false;
if (rebootOrUpdateProcess && socketConnected) {
rebootOrUpdateProcess = false;
showAwaitingCircle = false;
reconnectTimeout = 60;
remainingTimeout = reconnectTimeout;
}
percent = scale(remainingTimeout, reconnectTimeout, 0, 0, 100);
if (remainingTimeout <= 0) {
if (debug) console.log("[i]", "----timer tick----");
@@ -988,10 +990,6 @@
wsConnect(device.ws);
wsEventAdd(device.ws);
} else {
if (device.ws === selectedWs) {
//clearInterval(tickerTask);
connecting = true;
}
wsSendMsg(device.ws, "/tst|");
ack(device.ws, false);
}
@@ -1149,6 +1147,7 @@
}
function rebootEsp() {
rebootOrUpdateProcess = true;
if (debug) console.log("[i]", "reboot...");
wsSendMsg(selectedWs, "/reboot|");
markDeviceStatus(selectedWs, false);
@@ -1158,6 +1157,16 @@
remainingTimeout = reconnectTimeout;
}
function updateBuild(path) {
rebootOrUpdateProcess = true;
console.log(path);
wsSendMsg(selectedWs, "/update|" + path);
showAwaitingCircle = true;
socketConnected = false;
reconnectTimeout = 20;
remainingTimeout = reconnectTimeout;
}
function applicationReboot() {
console.log("[i]", "reboot svelte...");
for (const [key, value] of Object.entries(pageReady)) {
@@ -1169,13 +1178,6 @@
}, 1000);
}
function rebootingTask() {
clearTimeout(rebootTimer);
clearData();
connectToAllDevices();
showAwaitingCircle = false;
}
function cancelAlarm(alarmKey) {
console.log("[x]", alarmKey);
errorsJson[alarmKey] = 0;
@@ -1213,15 +1215,6 @@
}
}
function updateBuild(path) {
console.log(path);
wsSendMsg(selectedWs, "/update|" + path);
showAwaitingCircle = true;
socketConnected = false;
reconnectTimeout = 10;
//rebootTimer = setTimeout(rebootingTask, updatingTimeout);
}
function moduleOrder(id, key, value) {
console.log("order: ", id, key, value);
let json = {