1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

improved counter display on status page

This commit is contained in:
andreas
2021-11-07 17:00:40 +01:00
parent 1deef5c7de
commit 9147359b90
5 changed files with 88 additions and 111 deletions

View File

@@ -42,17 +42,18 @@ template<class T> class GwCounter{
}
int getJsonSize(){
return JSON_OBJECT_SIZE(4)+JSON_OBJECT_SIZE(okCounter.size()+1)+
JSON_OBJECT_SIZE(failCounter.size()+1);
JSON_OBJECT_SIZE(failCounter.size()+1)+
okCounter.size()*5+failCounter.size()*5;
}
void toJson(JsonDocument &json){
JsonObject jo=json.createNestedObject(name);
jo["sumOk"]=globalOk;
jo["sumFail"]=globalFail;
JsonObject jok=jo.createNestedObject("ok");
jo[F("sumOk")]=globalOk;
jo[F("sumFail")]=globalFail;
JsonObject jok=jo.createNestedObject(F("ok"));
for (auto it=okCounter.begin();it!=okCounter.end();it++){
jok[String(it->first)]=it->second;
}
JsonObject jfail=jo.createNestedObject("fail");
JsonObject jfail=jo.createNestedObject(F("fail"));
for (auto it=failCounter.begin();it!=failCounter.end();it++){
jfail[String(it->first)]=it->second;
}