diff --git a/src/web/html/api.js b/src/web/html/api.js index 3a8ad7f1..508a671d 100644 --- a/src/web/html/api.js +++ b/src/web/html/api.js @@ -31,32 +31,6 @@ function parseESP(obj) { document.getElementById("esp_type").innerHTML="Board: " + obj["esp_type"]; } -function parseSysInfo(obj) { - const data = ["sdk_version", "cpu_freq", "chip_revision", "chip_model", "chip_cores", "esp_type"]; - - var ul = document.getElementById("info"); - - if(!isNaN(obj["heap_total"])) { - document.getElementById("info").innerHTML = 'Heap: bytes ( bytes)'; - changeProgressbar("heap", obj["heap_used"], obj["heap_total"]); - } - - for (const [key, value] of Object.entries(obj)) { - if(!data.includes(key) || (typeof value == 'undefined')) continue; - var li = document.createElement("li"); - li.appendChild(document.createTextNode(key + ": " + value)); - ul.appendChild(li); - } -} - -function changeProgressbar(id, value, max) { - document.getElementById(id).value = value; - document.getElementById(id).max = max; - - document.getElementById("heap_used").textContent = value; - document.getElementById("heap_total").textContent = max; -} - function setHide(id, hide) { var elm = document.getElementById(id); if(hide) { @@ -67,7 +41,6 @@ function setHide(id, hide) { elm.classList.remove('hide'); } - function toggle(id) { var e = document.getElementById(id); if(!e.classList.contains("hide")) diff --git a/src/web/html/system.html b/src/web/html/system.html index a3219d6b..d8a473a2 100644 --- a/src/web/html/system.html +++ b/src/web/html/system.html @@ -18,7 +18,7 @@
-
+
    @@ -44,6 +44,21 @@ parseESP(obj); } + function parseSysInfo(obj) { + const data = ["sdk", "cpu_freq", "chip_revision", + "chip_model", "chip_cores", "esp_type", "mac", "wifi_rssi", + "flash_size", "sketch_used", "heap_total", "heap_free", "heap_frag", + "max_free_blk", "version", "core_version", "reboot_reason"]; + + var ul = document.getElementById("info"); + for (const [key, value] of Object.entries(obj)) { + if(!data.includes(key) || (typeof value == 'undefined')) continue; + var li = document.createElement("li"); + li.appendChild(document.createTextNode(key + ": " + value)); + ul.appendChild(li); + } + } + function parse(obj) { if(null != obj) { parseMenu(obj["menu"]); diff --git a/src/web/webApi.cpp b/src/web/webApi.cpp index f06b8bb0..e71aa511 100644 --- a/src/web/webApi.cpp +++ b/src/web/webApi.cpp @@ -142,30 +142,47 @@ void webApi::onDwnldSetup(AsyncWebServerRequest *request) { //----------------------------------------------------------------------------- void webApi::getSysInfo(JsonObject obj) { - obj[F("ssid")] = mConfig->sys.stationSsid; - obj[F("device_name")] = mConfig->sys.deviceName; - obj[F("version")] = String(mVersion); - obj[F("build")] = String(AUTO_GIT_HASH); - obj[F("ts_uptime")] = mApp->getUptime(); - obj[F("ts_now")] = mApp->getTimestamp(); - obj[F("ts_sunrise")] = mApp->getSunrise(); - obj[F("ts_sunset")] = mApp->getSunset(); - obj[F("ts_sun_upd")] = mApp->getLatestSunTimestamp(); - obj[F("wifi_rssi")] = WiFi.RSSI(); - obj[F("pwd_set")] = (strlen(mConfig->sys.adminPwd) > 0); - - obj[F("hostname")] = WiFi.getHostname(); - obj[F("sdk_version")] = ESP.getSdkVersion(); - obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); + obj[F("ssid")] = mConfig->sys.stationSsid; + obj[F("device_name")] = mConfig->sys.deviceName; + obj[F("version")] = String(mVersion); + obj[F("build")] = String(AUTO_GIT_HASH); + obj[F("ts_uptime")] = mApp->getUptime(); + obj[F("ts_now")] = mApp->getTimestamp(); + obj[F("ts_sunrise")] = mApp->getSunrise(); + obj[F("ts_sunset")] = mApp->getSunset(); + obj[F("ts_sun_upd")] = mApp->getLatestSunTimestamp(); + obj[F("wifi_rssi")] = WiFi.RSSI(); + obj[F("mac")] = WiFi.macAddress(); + obj[F("hostname")] = WiFi.getHostname(); + obj[F("pwd_set")] = (strlen(mConfig->sys.adminPwd) > 0); + + obj[F("sdk")] = ESP.getSdkVersion(); + obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); + obj[F("heap_free")] = ESP.getFreeHeap(); + obj[F("sketch_total")] = ESP.getFreeSketchSpace(); + obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb + #if defined(ESP32) obj[F("heap_total")] = ESP.getHeapSize(); - obj[F("heap_used")] = ESP.getHeapSize() - ESP.getFreeHeap(); - obj[F("chip_revision")] = ESP.getChipRevision(); - obj[F("chip_model")] = ESP.getChipModel(); - obj[F("chip_cores")] = ESP.getChipCores(); + obj[F("chip_revision")] = ESP.getChipRevision(); + obj[F("chip_model")] = ESP.getChipModel(); + obj[F("chip_cores")] = ESP.getChipCores(); + //obj[F("core_version")] = F("n/a"); + //obj[F("flash_size")] = F("n/a"); + //obj[F("heap_frag")] = F("n/a"); + //obj[F("max_free_blk")] = F("n/a"); + //obj[F("reboot_reason")] = F("n/a"); +#else + //obj[F("heap_total")] = F("n/a"); + //obj[F("chip_revision")] = F("n/a"); + //obj[F("chip_model")] = F("n/a"); + //obj[F("chip_cores")] = F("n/a"); + obj[F("core_version")] = ESP.getCoreVersion(); + obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb + obj[F("heap_frag")] = ESP.getHeapFragmentation(); + obj[F("max_free_blk")] = ESP.getMaxFreeBlockSize(); + obj[F("reboot_reason")] = ESP.getResetReason(); #endif - obj[F("sketch_total")] = ESP.getFreeSketchSpace(); - obj[F("sketch_used")] = ESP.getSketchSize(); //obj[F("littlefs_total")] = LittleFS.totalBytes(); //obj[F("littlefs_used")] = LittleFS.usedBytes();