mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-23 16:07:20 +01:00
Fix: Properly calculate db size for SystemInfo
So far the calculated size for the tagDB in the frontend was purely based on the size of each of its static entries. However the data pointer as well as the json based config string can occupy additional memory which is not accounted for. We are therefore introducing a helper function to properly calculate the DBs size. Signed-off-by: Mimoja <git@mimoja.de>
This commit is contained in:
@@ -94,7 +94,7 @@ function connect() {
|
||||
processTags(msg.tags);
|
||||
}
|
||||
if (msg.sys) {
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + msg.sys.dbsize + ' bytes ┇ db record count: ' + msg.sys.recordcount + ' ┇ filesystem free: ' + convertSize(msg.sys.littlefsfree);
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + convertSize(msg.sys.dbsize) + " ("+ msg.sys.dbsize + ' bytes) ┇ db record count: ' + msg.sys.recordcount + ' ┇ filesystem free: ' + convertSize(msg.sys.littlefsfree);
|
||||
if (msg.sys.apstate) {
|
||||
$("#apstatecolor").style.color = apstate[msg.sys.apstate].color;
|
||||
$("#apstate").innerHTML = apstate[msg.sys.apstate].state;
|
||||
|
||||
@@ -127,15 +127,25 @@ void wsErr(String text) {
|
||||
if (wsMutex) xSemaphoreGive(wsMutex);
|
||||
}
|
||||
|
||||
size_t dbSize(){
|
||||
size_t size = tagDB.size() * sizeof(tagRecord);
|
||||
for(auto &tag : tagDB) {
|
||||
if (tag->data)
|
||||
size += tag->len;
|
||||
size += tag->modeConfigJson.length();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void wsSendSysteminfo() {
|
||||
DynamicJsonDocument doc(150);
|
||||
DynamicJsonDocument doc(250);
|
||||
JsonObject sys = doc.createNestedObject("sys");
|
||||
time_t now;
|
||||
time(&now);
|
||||
sys["currtime"] = now;
|
||||
sys["heap"] = ESP.getFreeHeap();
|
||||
sys["recordcount"] = tagDB.size();
|
||||
sys["dbsize"] = tagDB.size() * sizeof(tagRecord);
|
||||
sys["dbsize"] = dbSize();
|
||||
sys["littlefsfree"] = Storage.freeSpace();
|
||||
sys["apstate"] = apInfo.state;
|
||||
sys["runstate"] = config.runStatus;
|
||||
|
||||
Reference in New Issue
Block a user