From cdf013f6dd85b6074c614c0775f9e60126d23eee Mon Sep 17 00:00:00 2001 From: Anatole SCHRAMM Date: Thu, 13 Oct 2022 14:12:41 +0200 Subject: [PATCH] Removed api end point to retrieve the software version, this information is now included in the systemInfo api end point. Improved dashboard ( still some pannels with missing logic) --- sdCard_content/WWW/indexV2.htm | 36 ++++++++++++++++------------- sdCard_content/WWW/rsrc/scriptV2.js | 7 ++++++ src/app/app.ino | 1 - src/app/webApi.cpp | 16 +------------ src/app/webApi.h | 1 - 5 files changed, 28 insertions(+), 33 deletions(-) diff --git a/sdCard_content/WWW/indexV2.htm b/sdCard_content/WWW/indexV2.htm index 300cd35..a28a894 100644 --- a/sdCard_content/WWW/indexV2.htm +++ b/sdCard_content/WWW/indexV2.htm @@ -53,6 +53,11 @@ { display:block; } + + .cursor-hand + { + cursor: pointer; + } @@ -173,17 +178,11 @@
0
-
- AP IP : +
+ AP IP :
-
- -
-
- MAC : -
-
- +
+ MAC :
@@ -196,7 +195,7 @@ - +
@@ -247,7 +246,7 @@ - + @@ -274,7 +273,13 @@
- Cpu frequency : + Software version : +
+
+    +
+
+ CPU frequency :
- - +
@@ -459,7 +463,7 @@ - +
diff --git a/sdCard_content/WWW/rsrc/scriptV2.js b/sdCard_content/WWW/rsrc/scriptV2.js index 2829495..f8639f9 100644 --- a/sdCard_content/WWW/rsrc/scriptV2.js +++ b/sdCard_content/WWW/rsrc/scriptV2.js @@ -163,6 +163,7 @@ function sysInfoRefreshHandler(data,kind) if(kind === 'OK') { let systemInfoObj = JSON.parse(data); + elemById('softInfo').innerHTML = systemInfoObj.version; elemById('temperature').innerHTML = systemInfoObj['temperature'].level + systemInfoObj['temperature'].unit; elemById('ramInfo').innerHTML = systemInfoObj['free RAM']; let cpuFreq = systemInfoObj['CPU freq']; @@ -180,6 +181,7 @@ function sysInfoRefreshHandler(data,kind) } else { + elemById('softInfo').innerHTML = 'NaN'; elemById('temperature').innerHTML = 'NaN'; elemById('ramInfo').innerHTML = 'NaN'; elemById('fragInfo').innerHTML = 'NaN'; @@ -491,6 +493,11 @@ function apStation() apStationReq.send(); } +function fetchOtaUpdate(button_id) +{ + console.log(button_id); +} + App = { init:function() diff --git a/src/app/app.ino b/src/app/app.ino index 4fb11aa..1b88e85 100644 --- a/src/app/app.ino +++ b/src/app/app.ino @@ -95,7 +95,6 @@ void setup() sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/set/level", &(ioSetLevelApi), &sab, WEBServer::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/get/mode", &(ioGetModeApi), &sab, WEBServer::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServer::GET); - sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/sw/version", &(swVersionApi), &sab, WEBServer::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/ota/update/upload", &(otaUpdateUploadApi), NULL, WEBServer::POST); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/ota/update/device", &(otaUpdateRemoteApi), &sab, WEBServer::GET); diff --git a/src/app/webApi.cpp b/src/app/webApi.cpp index e59e7b0..2c57f21 100644 --- a/src/app/webApi.cpp +++ b/src/app/webApi.cpp @@ -293,7 +293,7 @@ boolean systemInfoApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc ESP.getHeapStats(&freeMem, &biggestContigMemBlock, &frag); TimeSpan ts(p->getUpTime()); - sprintf(buffer, "{\"status\":\"ok\",\"CPU freq\":%u,\"free RAM\":%u,\"heap frag\":%u,\"max block\":%u,\"nb views\":%u,\"up time\":{\"days\":%d,\"hours\":%d,\"minutes\":%d,\"seconds\":%d},\"temperature\":{\"level\":%.2f, \"unit\":\"°C\"}}", ESP.getCpuFreqMHz(), freeMem, frag, biggestContigMemBlock, p->getScreenManager().getViewCount(), ts.days(), ts.hours(), ts.minutes(), ts.seconds(), p->getRTC_DS3231().getTemperature()); + sprintf(buffer, "{\"status\":\"ok\",\"version\":\"%s\",\"CPU freq\":%u,\"free RAM\":%u,\"heap frag\":%u,\"max block\":%u,\"nb views\":%u,\"up time\":{\"days\":%d,\"hours\":%d,\"minutes\":%d,\"seconds\":%d},\"temperature\":{\"level\":%.2f, \"unit\":\"°C\"}}", p->getSoftVersion(), ESP.getCpuFreqMHz(), freeMem, frag, biggestContigMemBlock, p->getScreenManager().getViewCount(), ts.days(), ts.hours(), ts.minutes(), ts.seconds(), p->getRTC_DS3231().getTemperature()); WEBServer::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer)); wc->print(buffer); @@ -577,20 +577,6 @@ boolean ioSetModeApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc, return true; } -boolean swVersionApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc, void *pData) -{ - (void)HRD; - SAB *p = (SAB *)pData; - - char buffer[100] = ""; - - sprintf(buffer ,"{\"status\":\"ok\",\"version\":\"%s\"}", p->getSoftVersion()); - - WEBServer::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer)); - wc->print(buffer); - return true; -} - boolean otaUpdateUploadApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc, void *pData) { (void)HRD; diff --git a/src/app/webApi.h b/src/app/webApi.h index 1cc4569..8671a2a 100644 --- a/src/app/webApi.h +++ b/src/app/webApi.h @@ -30,7 +30,6 @@ boolean ioGetLevelApi(WEBServer::HttpRequestData&, WiFiClient*, void* boolean ioSetLevelApi(WEBServer::HttpRequestData&, WiFiClient*, void*); boolean ioGetModeApi(WEBServer::HttpRequestData&, WiFiClient*, void*); boolean ioSetModeApi(WEBServer::HttpRequestData&, WiFiClient*, void*); -boolean swVersionApi(WEBServer::HttpRequestData&, WiFiClient*, void*); boolean otaUpdateUploadApi(WEBServer::HttpRequestData&, WiFiClient*, void*); boolean otaUpdateRemoteApi(WEBServer::HttpRequestData&, WiFiClient*, void*);