From 4048e737e83838e9e3d42bd873c48302caf5ee35 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 14 Apr 2022 12:44:56 +0200 Subject: [PATCH] Added additional system information --- src/WebApi.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/WebApi.cpp b/src/WebApi.cpp index 23b80e1..00d7b64 100644 --- a/src/WebApi.cpp +++ b/src/WebApi.cpp @@ -1,9 +1,11 @@ #include "WebApi.h" #include "ArduinoJson.h" #include "AsyncJson.h" +#include "Configuration.h" #include "WiFiSettings.h" #include "defaults.h" #include +#include WebApiClass::WebApiClass() : _server(HTTP_PORT) @@ -78,12 +80,33 @@ void WebApiClass::onSystemStatus(AsyncWebServerRequest* request) JsonObject root = response->getRoot(); root[F("hostname")] = WiFi.getHostname(); - root[F("heapfree")] = ESP.getFreeHeap(); - root[F("heaptotal")] = ESP.getHeapSize(); + root[F("sdkversion")] = ESP.getSdkVersion(); root[F("cpufreq")] = ESP.getCpuFreqMHz(); - root[F("sketchtotal")] = ESP.getSketchSize() + ESP.getFreeSketchSpace(); - root[F("sketchused")] = ESP.getSketchSize(); + + root[F("heap_total")] = ESP.getHeapSize(); + root[F("heap_used")] = ESP.getHeapSize() - ESP.getFreeHeap(); + root[F("sketch_total")] = ESP.getSketchSize() + ESP.getFreeSketchSpace(); + root[F("sketch_used")] = ESP.getSketchSize(); + root[F("littlefs_total")] = LITTLEFS.totalBytes(); + root[F("littlefs_used")] = LITTLEFS.usedBytes(); + + root[F("chiprevision")] = ESP.getChipRevision(); + root[F("chipmodel")] = ESP.getChipModel(); + root[F("chipcores")] = ESP.getChipCores(); + + String reason; + reason = ResetReason.get_reset_reason_verbose(0); + root[F("resetreason_0")] = reason; + + reason = ResetReason.get_reset_reason_verbose(1); + root[F("resetreason_1")] = reason; + + root[F("cfgsavecount")] = Configuration.get().Cfg_SaveCount; + + char version[16]; + sprintf(version, "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff); + root[F("firmware_version")] = version; response->setLength(); request->send(response);