From 08d86587376864e7951d8ffabea13abd43b5d314 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 28 Aug 2022 13:54:34 +0200 Subject: [PATCH] setup page complete converted to static version --- tools/esp8266/api.cpp | 13 ++++++++----- tools/esp8266/html/setup.html | 10 +++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/esp8266/api.cpp b/tools/esp8266/api.cpp index 8270797f..2cded6ed 100644 --- a/tools/esp8266/api.cpp +++ b/tools/esp8266/api.cpp @@ -44,8 +44,12 @@ void api::onSystem(AsyncWebServerRequest *request) { AsyncJsonResponse* response = new AsyncJsonResponse(); JsonObject root = response->getRoot(); - root[F("ssid")] = mSysCfg->stationSsid; + root[F("ssid")] = mSysCfg->stationSsid; root[F("device_name")] = mSysCfg->deviceName; + root[F("version")] = String(mVersion); + root[F("build")] = String(AUTO_GIT_HASH); + root[F("ts_uptime")] = mApp->getUptime(); + root[F("ts_now")] = mApp->getTimestamp(); response->setLength(); //response->addHeader("Access-Control-Allow-Origin", "*"); @@ -80,8 +84,8 @@ void api::onInverterList(AsyncWebServerRequest *request) { obj[F("power_limit_option")] = iv->powerLimit[1]; } } - root[F("interval")] = String(mConfig->sendInterval); - root[F("retries")] = String(mConfig->maxRetransPerPyld); + root[F("interval")] = String(mConfig->sendInterval); + root[F("retries")] = String(mConfig->maxRetransPerPyld); root[F("max_num_inverters")] = MAX_NUM_INVERTERS; response->setLength(); @@ -150,8 +154,7 @@ void api::onSerial(AsyncWebServerRequest *request) { AsyncJsonResponse* response = new AsyncJsonResponse(); JsonObject root = response->getRoot(); - // next line cause a chrash but why? - //root[F("interval")] = mConfig->serialInterval; + root[F("interval")] = (uint16_t)mConfig->serialInterval; root[F("show_live_data")] = mConfig->serialShowIv; root[F("debug")] = mConfig->serialDebug; diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index bf1e3b1c..d540e7e6 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -145,7 +145,7 @@ @@ -265,6 +265,7 @@ function parseSys(obj) { for(var i of [["device", "device_name"], ["ssid", "ssid"]]) document.getElementsByName(i[0])[0].value = obj[i[1]]; + document.getElementById("version").innerHTML = "Git SHA: " + obj["build"] + " :: " + obj["version"]; } function parseIv(obj) { @@ -322,12 +323,19 @@ ], obj["power_level"])); } + function parseSerial(obj) { + for(var i of [["serEn", "show_live_data"], ["serDbg", "debug"]]) + document.getElementsByName(i[0])[0].checked = obj[i[1]]; + document.getElementsByName("serIntvl")[0].value = obj["interval"]; + } + getAjax("/api/system", parseSys); getAjax("/api/inverter/list", parseIv); getAjax("/api/mqtt", parseMqtt); getAjax("/api/ntp", parseNtp); getAjax("/api/pinout", parsePinout); getAjax("/api/radio", parseRadio); + getAjax("/api/serial", parseSerial);