Przeglądaj źródła

Load info page data with one system info request

SybexXx 3 dni temu
rodzic
commit
ae79a13d9e

+ 72 - 32
code/components/jomjol_helper/Helper.cpp

@@ -26,6 +26,8 @@ extern "C"
 #include <esp_log.h>
 #include <esp_mac.h>
 #include <esp_timer.h>
+#include <esp_heap_caps.h>
+#include <stdint.h>
 #include "../../include/defines.h"
 
 #include "ClassLogFile.h"
@@ -51,40 +53,41 @@ bool SDCardIsMMC;
 // #define DEBUG_DETAIL_ON
 
 /////////////////////////////////////////////////////////////////////////////////////////////
-string getESPHeapInfo()
+ESPHeapStats getESPHeapStats()
 {
-	string espInfoResultStr = "";
-	char aMsgBuf[80];
-
-	size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
-
-	size_t aFreeSPIHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
-	size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
-
-	size_t aHeapLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
-	size_t aHeapIntLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
-
-	size_t aMinFreeHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
-	size_t aMinFreeInternalHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
-
-	sprintf(aMsgBuf, "Heap Total: %ld", (long)aFreeHeapSize);
-	espInfoResultStr += string(aMsgBuf);
-
-	sprintf(aMsgBuf, " | SPI Free: %ld", (long)aFreeSPIHeapSize);
-	espInfoResultStr += string(aMsgBuf);
-	sprintf(aMsgBuf, " | SPI Large Block:  %ld", (long)aHeapLargestFreeBlockSize);
-	espInfoResultStr += string(aMsgBuf);
-	sprintf(aMsgBuf, " | SPI Min Free: %ld", (long)aMinFreeHeapSize);
-	espInfoResultStr += string(aMsgBuf);
-
-	sprintf(aMsgBuf, " | Int Free: %ld", (long)(aFreeInternalHeapSize));
-	espInfoResultStr += string(aMsgBuf);
-	sprintf(aMsgBuf, " | Int Large Block:  %ld", (long)aHeapIntLargestFreeBlockSize);
-	espInfoResultStr += string(aMsgBuf);
-	sprintf(aMsgBuf, " | Int Min Free: %ld", (long)(aMinFreeInternalHeapSize));
-	espInfoResultStr += string(aMsgBuf);
+    ESPHeapStats stats = {};
+    stats.totalFree = heap_caps_get_free_size(MALLOC_CAP_8BIT);
+    stats.externalFree = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
+    stats.internalFree = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
+    stats.externalLargestFreeBlock = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
+    stats.internalLargestFreeBlock = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
+    stats.externalMinFree = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
+    stats.internalMinFree = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
+    return stats;
+}
 
-	return espInfoResultStr;
+string getESPHeapInfo()
+{
+    const ESPHeapStats stats = getESPHeapStats();
+    string espInfoResultStr;
+    char aMsgBuf[80];
+
+    sprintf(aMsgBuf, "Heap Total: %ld", (long)stats.totalFree);
+    espInfoResultStr += string(aMsgBuf);
+    sprintf(aMsgBuf, " | SPI Free: %ld", (long)stats.externalFree);
+    espInfoResultStr += string(aMsgBuf);
+    sprintf(aMsgBuf, " | SPI Large Block:  %ld", (long)stats.externalLargestFreeBlock);
+    espInfoResultStr += string(aMsgBuf);
+    sprintf(aMsgBuf, " | SPI Min Free: %ld", (long)stats.externalMinFree);
+    espInfoResultStr += string(aMsgBuf);
+    sprintf(aMsgBuf, " | Int Free: %ld", (long)stats.internalFree);
+    espInfoResultStr += string(aMsgBuf);
+    sprintf(aMsgBuf, " | Int Large Block:  %ld", (long)stats.internalLargestFreeBlock);
+    espInfoResultStr += string(aMsgBuf);
+    sprintf(aMsgBuf, " | Int Min Free: %ld", (long)stats.internalMinFree);
+    espInfoResultStr += string(aMsgBuf);
+
+    return espInfoResultStr;
 }
 
 size_t getESPHeapSize()
@@ -174,6 +177,43 @@ string getSDCardSectorSize()
 	return std::to_string(SDCardSectorSize);
 }
 
+SDCardDetails getSDCardDetails()
+{
+    SDCardDetails details = {};
+
+    // SDCardCsd is populated by SaveSDCardInfo() after a card has been initialized.
+    if (SDCardCsd.sector_size == 0)
+    {
+        return details;
+    }
+
+    details.cardAvailable = true;
+    details.manufacturer = getSDCardManufacturer();
+    details.name.assign(SDCardCid.name, strnlen(SDCardCid.name, sizeof(SDCardCid.name)));
+    details.capacityMB = std::to_string(
+        (static_cast<uint64_t>(SDCardCsd.capacity) * SDCardCsd.sector_size) / (1024ULL * 1024ULL));
+    details.sectorSizeBytes = std::to_string(SDCardCsd.sector_size);
+
+    FATFS *fs = nullptr;
+    DWORD freeClusters = 0;
+    if (f_getfree("0:", &freeClusters, &fs) != FR_OK || fs == nullptr ||
+        fs->csize == 0 || fs->n_fatent < 2)
+    {
+        return details;
+    }
+
+    const uint64_t totalSectors = static_cast<uint64_t>(fs->n_fatent - 2) * fs->csize;
+    const uint64_t freeSectors = static_cast<uint64_t>(freeClusters) * fs->csize;
+    const uint64_t sectorSize = SDCardCsd.sector_size;
+
+    details.partitionSizeMB = std::to_string((totalSectors * sectorSize) / (1024ULL * 1024ULL));
+    details.partitionFreeMB = std::to_string((freeSectors * sectorSize) / (1024ULL * 1024ULL));
+    details.partitionAllocationSizeBytes = std::to_string(fs->ssize);
+    details.partitionAvailable = true;
+
+    return details;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 

+ 27 - 0
code/components/jomjol_helper/Helper.h

@@ -49,9 +49,36 @@ std::vector<std::string> ZerlegeZeile(std::string input, std::string delimiter =
 
 ///////////////////////////
 
+struct ESPHeapStats
+{
+    size_t totalFree;
+    size_t externalFree;
+    size_t externalLargestFreeBlock;
+    size_t externalMinFree;
+    size_t internalFree;
+    size_t internalLargestFreeBlock;
+    size_t internalMinFree;
+};
+
+ESPHeapStats getESPHeapStats();
 size_t getESPHeapSize();
 string getESPHeapInfo();
 
+struct SDCardDetails
+{
+    bool cardAvailable;
+    bool partitionAvailable;
+    std::string manufacturer;
+    std::string name;
+    std::string capacityMB;
+    std::string sectorSizeBytes;
+    std::string partitionSizeMB;
+    std::string partitionFreeMB;
+    std::string partitionAllocationSizeBytes;
+};
+
+SDCardDetails getSDCardDetails();
+
 /////////////////////////////
 string getSDCardPartitionSize();
 string getSDCardFreePartitionSpace();

+ 104 - 26
code/main/server_main.cpp

@@ -29,6 +29,49 @@ std::string starttime = "";
 
 static const char *TAG = "MAIN SERVER";
 
+static void appendJsonStringField(std::string &json, const char *key,
+                                  const std::string &value, bool &firstField)
+{
+    if (!firstField)
+    {
+        json.push_back(',');
+    }
+    firstField = false;
+
+    json.push_back('"');
+    json.append(key);
+    json.append("\":\"");
+
+    for (unsigned char ch : value)
+    {
+        switch (ch)
+        {
+        case '"':  json.append("\\\""); break;
+        case '\\': json.append("\\\\"); break;
+        case '\b': json.append("\\b"); break;
+        case '\f': json.append("\\f"); break;
+        case '\n': json.append("\\n"); break;
+        case '\r': json.append("\\r"); break;
+        case '\t': json.append("\\t"); break;
+        default:
+            if (ch < 0x20)
+            {
+                char escaped[7];
+                snprintf(escaped, sizeof(escaped), "\\u%04x", ch);
+                json.append(escaped);
+            }
+            else
+            {
+                json.push_back(static_cast<char>(ch));
+            }
+            break;
+        }
+    }
+
+    json.push_back('"');
+}
+
+
 /* An HTTP GET handler */
 esp_err_t info_get_handler(httpd_req_t *req)
 {
@@ -376,34 +419,69 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
 
 esp_err_t sysinfo_handler(httpd_req_t *req)
 {
-    std::string zw;
-    std::string cputemp = std::to_string((int)temperatureRead());
-    std::string gitversion = libfive_git_version();
-    std::string buildtime = build_time();
-    std::string gitbranch = libfive_git_branch();
-    std::string gittag = libfive_git_version();
-    std::string gitrevision = libfive_git_revision();
-    std::string htmlversion = getHTMLversion();
-    char freeheapmem[11];
-    sprintf(freeheapmem, "%lu", (long) getESPHeapSize());
-    
-    zw = string("[{") + 
-        "\"firmware\": \"" + gitversion + "\"," +
-        "\"buildtime\": \"" + buildtime + "\"," +
-        "\"gitbranch\": \"" + gitbranch + "\"," +
-        "\"gittag\": \"" + gittag + "\"," +
-        "\"gitrevision\": \"" + gitrevision + "\"," +
-        "\"html\": \"" + htmlversion + "\"," +
-        "\"cputemp\": \"" + cputemp + "\"," +
-        "\"hostname\": \"" + *getHostname() + "\"," +
-        "\"IPv4\": \"" + *getIPAddress() + "\"," +
-        "\"freeHeapMem\": \"" + freeheapmem + "\"" +
-        "}]";
+    // Collect each group once. In particular, SD partition statistics share one f_getfree()
+    // call instead of performing three separate FATFS queries.
+    const ESPHeapStats heap = getESPHeapStats();
+    const SDCardDetails sdCard = getSDCardDetails();
+
+    esp_chip_info_t chipInfo = {};
+    esp_chip_info(&chipInfo);
+
+    const std::string *hostnameValue = getHostname();
+    const std::string *ipAddressValue = getIPAddress();
+    const std::string *ssidValue = getSSID();
+
+    const std::string hostname = hostnameValue ? *hostnameValue : std::string();
+    const std::string ipAddress = ipAddressValue ? *ipAddressValue : std::string();
+    const std::string ssid = ssidValue ? *ssidValue : std::string();
+
+    std::string json;
+    json.reserve(1400);
+    json.append("[{");
+    bool firstField = true;
+
+    // Keep the original /sysinfo keys and array/object envelope for existing clients.
+    appendJsonStringField(json, "firmware", libfive_git_version(), firstField);
+    appendJsonStringField(json, "buildtime", build_time(), firstField);
+    appendJsonStringField(json, "gitbranch", libfive_git_branch(), firstField);
+    appendJsonStringField(json, "gittag", libfive_git_version(), firstField);
+    appendJsonStringField(json, "gitrevision", libfive_git_revision(), firstField);
+    appendJsonStringField(json, "html", getHTMLversion(), firstField);
+    appendJsonStringField(json, "cputemp", std::to_string((int)temperatureRead()), firstField);
+    appendJsonStringField(json, "hostname", hostname, firstField);
+    appendJsonStringField(json, "IPv4", ipAddress, firstField);
+    appendJsonStringField(json, "freeHeapMem", std::to_string((unsigned long long)heap.totalFree), firstField);
+
+    // Additional fields used by info.html.
+    appendJsonStringField(json, "starttime", starttime, firstField);
+    appendJsonStringField(json, "uptime", getFormatedUptime(false), firstField);
+    appendJsonStringField(json, "SSID", ssid, firstField);
+
+    appendJsonStringField(json, "chipCores", std::to_string(chipInfo.cores), firstField);
+    appendJsonStringField(json, "chipRevision", std::to_string(chipInfo.revision), firstField);
+    appendJsonStringField(json, "chipFeatures", std::to_string(chipInfo.features), firstField);
+
+    appendJsonStringField(json, "sdCardManufacturer", sdCard.manufacturer, firstField);
+    appendJsonStringField(json, "sdCardName", sdCard.name, firstField);
+    appendJsonStringField(json, "sdCardCapacity", sdCard.capacityMB, firstField);
+    appendJsonStringField(json, "sdCardSectorSize", sdCard.sectorSizeBytes, firstField);
+    appendJsonStringField(json, "sdCardPartitionSize", sdCard.partitionSizeMB, firstField);
+    appendJsonStringField(json, "sdCardFreePartitionSpace", sdCard.partitionFreeMB, firstField);
+    appendJsonStringField(json, "sdCardPartitionAllocationSize", sdCard.partitionAllocationSizeBytes, firstField);
+
+    appendJsonStringField(json, "RAMTotalFree", std::to_string((unsigned long long)heap.totalFree), firstField);
+    appendJsonStringField(json, "ExtRAMFree", std::to_string((unsigned long long)heap.externalFree), firstField);
+    appendJsonStringField(json, "ExtRAMLargestFree", std::to_string((unsigned long long)heap.externalLargestFreeBlock), firstField);
+    appendJsonStringField(json, "ExtRAMMinFree", std::to_string((unsigned long long)heap.externalMinFree), firstField);
+    appendJsonStringField(json, "IntRAMFree", std::to_string((unsigned long long)heap.internalFree), firstField);
+    appendJsonStringField(json, "IntRAMLargestFree", std::to_string((unsigned long long)heap.internalLargestFreeBlock), firstField);
+    appendJsonStringField(json, "IntRAMMinFree", std::to_string((unsigned long long)heap.internalMinFree), firstField);
+
+    json.append("}]");
 
+    httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
     httpd_resp_set_type(req, "application/json");
-    httpd_resp_send(req, zw.c_str(), zw.length());
-
-    return ESP_OK;
+    return httpd_resp_send(req, json.c_str(), json.length());
 }
 
 

+ 103 - 292
sd-card/html/info.html

@@ -248,296 +248,107 @@ Copyright &copy; 2020 - 2024 by <a href="https://github.com/jomjol/AI-on-the-edg
 </html>
 
 <script type="text/javascript">
-
-	function loadLastRestart() 
-	{
-		url = getDomainname() + '/starttime';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
-				//Input format: 19700101-010019
-				var timestamp = xhttp.response.substr(6,2) + "." +
-						   xhttp.response.substr(4,2) + "." +
-						   xhttp.response.substr(0,4) + " " +
-						   xhttp.response.substr(9,2) + ":" +
-						   xhttp.response.substr(11,2) + ":" +
-						   xhttp.response.substr(13,2);
- 				document.getElementById("starttime").value = timestamp;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadUptime() 
-	{
-		url = getDomainname() + '/uptime';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("uptime").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadFWVersion() 
-	{
-		url = getDomainname() + '/info?type=FirmwareVersion';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("firmware").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadFWBuildTime() 
-	{
-		url = getDomainname() + '/info?type=BuildTime';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
-				// Input format: 2023-04-02 10:56
-				var timestamp = xhttp.response.substr(8,2) + "." +
-								xhttp.response.substr(5,2) + "." +
-								xhttp.response.substr(0,4) + " " +
-								xhttp.response.substr(11,2) + ":" +
-								xhttp.response.substr(14,2);
- 				document.getElementById("build-time").value = timestamp;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadHTMLVersion() 
-	{
-		url = getDomainname() + '/info?type=HTMLVersion';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("web-ui").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadHostname() 
-	{
-		url = getDomainname() + '/info?type=Hostname';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("hostname").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadIPAddress() 
-	{
-		url = getDomainname() + '/info?type=IP';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("IP-address").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadWLANSSID() 
-	{
-		url = getDomainname() + '/info?type=SSID';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("wlan-ssid").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardManufacturer() 
-	{
-		url = getDomainname() + '/info?type=SDCardManufacturer';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardManufacturer").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardName() 
-	{
-		url = getDomainname() + '/info?type=SDCardName';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardName").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardCapacity() 
-	{
-		url = getDomainname() + '/info?type=SDCardCapacity';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardCapacity").value = xhttp.response + " MB";
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardSectorSize() 
-	{
-		url = getDomainname() + '/info?type=SDCardSectorSize';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardSectorSize").value = xhttp.response + " byte";
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardPartitionSize() 
-	{
-		url = getDomainname() + '/info?type=SDCardPartitionSize';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardPartitionSize").value = xhttp.response + " MB";
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardFreePartitionSpace() 
-	{
-		url = getDomainname() + '/info?type=SDCardFreePartitionSpace';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardFreePartitionSpace").value = xhttp.response + " MB";
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadSDCardPartitionAllocationSize() 
-	{
-		url = getDomainname() + '/info?type=SDCardPartitionAllocationSize';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
- 				document.getElementById("SDCardPartitionAllocationSize").value = xhttp.response + " byte";
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadMemoryInfo() 
-	{
-		url = getDomainname() + '/heap';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {
-				data = xhttp.response.split("|");
- 				document.getElementById("RAMTotalFree").value = data[0].split("l: ")[1] + " byte";
-				document.getElementById("IntRAMFree").value = data[4].split(":")[1] + " byte";
-				document.getElementById("IntRAMLargestFree").value = data[5].split(":")[1] + " byte";
-				document.getElementById("IntRAMMinFree").value = data[6].split(":")[1] + " byte";
-				document.getElementById("ExtRAMFree").value = data[1].split(":")[1] + " byte";
-				document.getElementById("ExtRAMLargestFree").value = data[2].split(":")[1] + " byte";
-				document.getElementById("ExtRAMMinFree").value = data[3].split(":")[1] + " byte";
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadChipCores() 
-	{
-		url = getDomainname() + '/info?type=ChipCores';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {				
- 				document.getElementById("chip-cores").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadChipRevision() 
-	{
-		url = getDomainname() + '/info?type=ChipRevision';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {				
- 				document.getElementById("chip-revision").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function loadChipFeatures() 
-	{
-		url = getDomainname() + '/info?type=ChipFeatures';     
-		var xhttp = new XMLHttpRequest();
-		xhttp.onreadystatechange = function() {
-			if (this.readyState == 4 && this.status == 200) {				
- 				document.getElementById("chip-features").value = xhttp.response;
-			}
-		}
-		xhttp.open("GET", url, true);
-		xhttp.send();
-	}
-
-	function init()
-	{
-		loadMemoryInfo();
-		loadLastRestart();
-		loadUptime();
-		loadFWVersion();
-		loadFWBuildTime();
-		loadHTMLVersion();
-		loadHostname();
-		loadIPAddress();
-		loadWLANSSID();
-		loadSDCardManufacturer();
-		loadSDCardName();
-		loadSDCardCapacity();
-		loadSDCardSectorSize();
-		loadSDCardPartitionSize();
-		loadSDCardFreePartitionSpace();
-		loadSDCardPartitionAllocationSize();
-		loadChipCores();
-		loadChipRevision();
-		loadChipFeatures();
-	}
-
-	init();
+    function setOutput(id, value, suffix)
+    {
+        var field = document.getElementById(id);
+        if (!field) {
+            return;
+        }
+
+        if (value === undefined || value === null || value === "") {
+            field.value = "N/A";
+        } else {
+            field.value = String(value) + (suffix || "");
+        }
+    }
+
+    function formatStartTime(value)
+    {
+        if (!value || value.length < 15) {
+            return value || "";
+        }
+
+        // Input format: YYYYMMDD-HHMMSS
+        return value.substr(6, 2) + "." +
+               value.substr(4, 2) + "." +
+               value.substr(0, 4) + " " +
+               value.substr(9, 2) + ":" +
+               value.substr(11, 2) + ":" +
+               value.substr(13, 2);
+    }
+
+    function formatBuildTime(value)
+    {
+        if (!value || value.length < 16) {
+            return value || "";
+        }
+
+        // Input format: YYYY-MM-DD HH:MM
+        return value.substr(8, 2) + "." +
+               value.substr(5, 2) + "." +
+               value.substr(0, 4) + " " +
+               value.substr(11, 2) + ":" +
+               value.substr(14, 2);
+    }
+
+    function loadSystemInfo()
+    {
+        var request = new XMLHttpRequest();
+        request.onreadystatechange = function() {
+            if (this.readyState !== 4) {
+                return;
+            }
+
+            if (this.status !== 200) {
+                console.error("Could not load system information:", this.status);
+                return;
+            }
+
+            try {
+                var response = JSON.parse(this.responseText);
+                var info = Array.isArray(response) ? response[0] : response;
+                if (!info || typeof info !== "object") {
+                    throw new Error("Invalid system information response");
+                }
+
+                setOutput("starttime", formatStartTime(info.starttime));
+                setOutput("uptime", info.uptime);
+                setOutput("firmware", info.firmware);
+                setOutput("build-time", formatBuildTime(info.buildtime));
+                setOutput("web-ui", info.html);
+
+                setOutput("chip-cores", info.chipCores);
+                setOutput("chip-revision", info.chipRevision);
+                setOutput("chip-features", info.chipFeatures);
+
+                setOutput("hostname", info.hostname);
+                setOutput("IP-address", info.IPv4);
+                setOutput("wlan-ssid", info.SSID);
+
+                setOutput("SDCardManufacturer", info.sdCardManufacturer);
+                setOutput("SDCardName", info.sdCardName);
+                setOutput("SDCardCapacity", info.sdCardCapacity, " MB");
+                setOutput("SDCardSectorSize", info.sdCardSectorSize, " byte");
+                setOutput("SDCardPartitionSize", info.sdCardPartitionSize, " MB");
+                setOutput("SDCardFreePartitionSpace", info.sdCardFreePartitionSpace, " MB");
+                setOutput("SDCardPartitionAllocationSize", info.sdCardPartitionAllocationSize, " byte");
+
+                setOutput("RAMTotalFree", info.RAMTotalFree, " byte");
+                setOutput("ExtRAMFree", info.ExtRAMFree, " byte");
+                setOutput("ExtRAMLargestFree", info.ExtRAMLargestFree, " byte");
+                setOutput("ExtRAMMinFree", info.ExtRAMMinFree, " byte");
+                setOutput("IntRAMFree", info.IntRAMFree, " byte");
+                setOutput("IntRAMLargestFree", info.IntRAMLargestFree, " byte");
+                setOutput("IntRAMMinFree", info.IntRAMMinFree, " byte");
+            } catch (error) {
+                console.error("Could not parse system information:", error);
+            }
+        };
+
+        request.open("GET", getDomainname() + "/sysinfo", true);
+        request.send();
+    }
+
+    loadSystemInfo();
 </script>
+