mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
clean code changes
This commit is contained in:
@@ -1009,9 +1009,6 @@ void MyESP::_telnetCommand(char * commandLine) {
|
|||||||
crashDump();
|
crashDump();
|
||||||
} else if (strcmp(cmd, "clear") == 0) {
|
} else if (strcmp(cmd, "clear") == 0) {
|
||||||
crashClear();
|
crashClear();
|
||||||
} else if ((strcmp(cmd, "test") == 0) && (wc == 3)) {
|
|
||||||
char * value = _telnet_readWord(false);
|
|
||||||
crashTest(atoi(value));
|
|
||||||
} else {
|
} else {
|
||||||
myDebug_P(PSTR("Error. Usage: crash <dump | clear | test [n]>"));
|
myDebug_P(PSTR("Error. Usage: crash <dump | clear | test [n]>"));
|
||||||
}
|
}
|
||||||
@@ -1705,7 +1702,7 @@ bool MyESP::_fs_loadConfig() {
|
|||||||
JsonObject ntp = doc["ntp"];
|
JsonObject ntp = doc["ntp"];
|
||||||
_ntp_server = strdup(ntp["server"] | "");
|
_ntp_server = strdup(ntp["server"] | "");
|
||||||
_ntp_interval = ntp["interval"] | 60;
|
_ntp_interval = ntp["interval"] | 60;
|
||||||
if (_ntp_interval == 0)
|
if (_ntp_interval < 2)
|
||||||
_ntp_interval = 60;
|
_ntp_interval = 60;
|
||||||
_ntp_enabled = ntp["enabled"];
|
_ntp_enabled = ntp["enabled"];
|
||||||
|
|
||||||
@@ -2131,52 +2128,7 @@ void MyESP::crashDump() {
|
|||||||
myDebug_P(PSTR("\nTo clean this dump use the command: %scrash clear%s\n"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
|
myDebug_P(PSTR("\nTo clean this dump use the command: %scrash clear%s\n"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Force some crashes to test if stack collection works
|
|
||||||
*/
|
|
||||||
void MyESP::crashTest(uint8_t t) {
|
|
||||||
if (t == 1) {
|
|
||||||
myDebug_P(PSTR("[CRASH] Attempting to divide by zero ..."));
|
|
||||||
int result, zero;
|
|
||||||
zero = 0;
|
|
||||||
result = 1 / zero;
|
|
||||||
Serial.printf("Result = %d", result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t == 2) {
|
|
||||||
myDebug_P(PSTR("[CRASH] Attempting to read through a pointer to no object ..."));
|
|
||||||
int * nullPointer;
|
|
||||||
nullPointer = nullptr;
|
|
||||||
// null pointer dereference - read
|
|
||||||
// attempt to read a value through a null pointer
|
|
||||||
Serial.println(*nullPointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t == 3) {
|
|
||||||
myDebug_P(PSTR("[CRASH] Crashing with hardware WDT (%ld ms) ...\n"), millis());
|
|
||||||
ESP.wdtDisable();
|
|
||||||
while (true) {
|
|
||||||
// stay in an infinite loop doing nothing
|
|
||||||
// this way other process can not be executed
|
|
||||||
//
|
|
||||||
// Note:
|
|
||||||
// Hardware wdt kicks in if software wdt is unable to perfrom
|
|
||||||
// Nothing will be saved in EEPROM for the hardware wdt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t == 4) {
|
|
||||||
myDebug_P(PSTR("[CRASH] Crashing with software WDT (%ld ms) ...\n"), millis());
|
|
||||||
while (true) {
|
|
||||||
// stay in an infinite loop doing nothing
|
|
||||||
// this way other process can not be executed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void MyESP::crashTest(uint8_t t) {
|
|
||||||
}
|
|
||||||
void MyESP::crashClear() {
|
void MyESP::crashClear() {
|
||||||
}
|
}
|
||||||
void MyESP::crashDump() {
|
void MyESP::crashDump() {
|
||||||
|
|||||||
@@ -294,7 +294,6 @@ class MyESP {
|
|||||||
// Crash
|
// Crash
|
||||||
void crashClear();
|
void crashClear();
|
||||||
void crashDump();
|
void crashDump();
|
||||||
void crashTest(uint8_t t);
|
|
||||||
void crashInfo();
|
void crashInfo();
|
||||||
|
|
||||||
// general
|
// general
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ var custom_config = {
|
|||||||
"shower_alert": false,
|
"shower_alert": false,
|
||||||
"publish_time": 120
|
"publish_time": 120
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function custom_commit() {
|
function custom_commit() {
|
||||||
websock.send(JSON.stringify(custom_config));
|
websock.send(JSON.stringify(custom_config));
|
||||||
@@ -95,16 +95,15 @@ function listCustomStats() {
|
|||||||
for (var i = 0; i < obj.length; i++) {
|
for (var i = 0; i < obj.length; i++) {
|
||||||
var l = document.createElement("li");
|
var l = document.createElement("li");
|
||||||
var type = obj[i].type;
|
var type = obj[i].type;
|
||||||
if (type == 1) {
|
|
||||||
var color = "list-group-item-success";
|
|
||||||
} else if (type == 2) {
|
|
||||||
var color = "list-group-item-info";
|
|
||||||
} else if (type == 3) {
|
|
||||||
var color = "list-group-item-warning";
|
|
||||||
} else if (type == 4) {
|
|
||||||
var color = "list-group-item-success";
|
|
||||||
} else {
|
|
||||||
var color = "";
|
var color = "";
|
||||||
|
if (type === 1) {
|
||||||
|
color = "list-group-item-success";
|
||||||
|
} else if (type === 2) {
|
||||||
|
color = "list-group-item-info";
|
||||||
|
} else if (type === 3) {
|
||||||
|
color = "list-group-item-warning";
|
||||||
|
} else if (type === 4) {
|
||||||
|
color = "list-group-item-success";
|
||||||
}
|
}
|
||||||
l.innerHTML = obj[i].model + " (Version:" + obj[i].version + " ProductID:" + obj[i].productid + " DeviceID:0x" + 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 " + color;
|
l.className = "list-group-item " + color;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ var utcSeconds;
|
|||||||
var data = [];
|
var data = [];
|
||||||
var ajaxobj;
|
var ajaxobj;
|
||||||
|
|
||||||
|
var custom_config = {};
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
"command": "configfile",
|
"command": "configfile",
|
||||||
"network": {
|
"network": {
|
||||||
@@ -68,6 +70,14 @@ function syncBrowserTime() {
|
|||||||
$("#ntp").click();
|
$("#ntp").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleNTPON() {
|
||||||
|
document.getElementById("forcentp").style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNTPOFF() {
|
||||||
|
document.getElementById("forcentp").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
function listntp() {
|
function listntp() {
|
||||||
websock.send("{\"command\":\"gettime\"}");
|
websock.send("{\"command\":\"gettime\"}");
|
||||||
|
|
||||||
@@ -247,14 +257,6 @@ 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;
|
||||||
@@ -435,16 +437,18 @@ function getContent(contentname) {
|
|||||||
var customname2 = " " + ajaxobj.customname;
|
var customname2 = " " + ajaxobj.customname;
|
||||||
$("#customname2").text(customname2);
|
$("#customname2").text(customname2);
|
||||||
|
|
||||||
|
var elem;
|
||||||
|
|
||||||
if (config.network.wmode === 0) {
|
if (config.network.wmode === 0) {
|
||||||
var elem = document.getElementById("helpurl");
|
elem = document.getElementById("helpurl");
|
||||||
var helpurl = ajaxobj.appurl + "/wiki"
|
var helpurl = ajaxobj.appurl + "/wiki";
|
||||||
elem.setAttribute("href", helpurl);
|
elem.setAttribute("href", helpurl);
|
||||||
document.getElementById("helpurl").style.display = "block";
|
document.getElementById("helpurl").style.display = "block";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("helpurl").style.display = "none";
|
document.getElementById("helpurl").style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = document.getElementById("appurl");
|
elem = document.getElementById("appurl");
|
||||||
elem.setAttribute("href", ajaxobj.appurl);
|
elem.setAttribute("href", ajaxobj.appurl);
|
||||||
$("#appurl2").text(ajaxobj.appurl);
|
$("#appurl2").text(ajaxobj.appurl);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user