1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-16 07:23:07 +01:00

return status info in boatData request

This commit is contained in:
andreas
2021-10-31 16:31:22 +01:00
parent 165aca2f61
commit c14ed4cfe9
3 changed files with 42 additions and 30 deletions

View File

@@ -6,18 +6,22 @@ GwBoatData::GwBoatData(GwLog *logger){
GwBoatData::~GwBoatData(){
GwBoatItemBase::GwBoatItemMap::iterator it;
for (it=values.begin() ; it != values.end();it++){
delete it->second;
delete *it;
}
}
String GwBoatData::toJson() const {
long minTime=millis();
DynamicJsonDocument json(800);
unsigned long minTime=millis();
GwBoatItemBase::GwBoatItemMap::const_iterator it;
size_t count=0;
size_t elementSizes=0;
for (it=values.begin() ; it != values.end();it++){
if (it->second->isValid(minTime)){
it->second->toJsonDoc(&json,it->first);
}
count++;
elementSizes+=(*it)->getJsonSize();
}
DynamicJsonDocument json(JSON_OBJECT_SIZE(count)+elementSizes);
for (it=values.begin() ; it != values.end();it++){
(*it)->toJsonDoc(&json,minTime);
}
String buf;
serializeJson(json,buf);