Skip to content

Commit

Permalink
ignore compensated value send to AG server. And udpate JSON properties
Browse files Browse the repository at this point in the history
  • Loading branch information
pnt325 committed Apr 20, 2024
1 parent 4063536 commit a2b30a5
Showing 1 changed file with 52 additions and 34 deletions.
86 changes: 52 additions & 34 deletions src/AgValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
if (config->hasSensorSHT) {
if (this->Temperature > -1001) {
root["atmp"] = ag->round2(this->Temperature);
root["atmpCompensated"] = ag->round2(this->Temperature);
if (localServer) {
root["atmpCompensated"] = ag->round2(this->Temperature);
}
}
if (this->Humidity >= 0) {
root["rhum"] = this->Humidity;
root["rhumCompensated"] = this->Humidity;
if (localServer) {
root["rhumCompensated"] = this->Humidity;
}
}
}

Expand All @@ -55,11 +59,13 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
ag->round2((this->pm03PCount_1 + this->pm03PCount_2) / 2.0);
root["atmp"] = ag->round2((this->temp_1 + this->temp_2) / 2.0f);
root["rhum"] = ag->round2((this->hum_1 + this->hum_2) / 2.0f);
root["atmpCompensated"] =
ag->round2(ag->pms5003t_2.temperatureCompensated(
(this->temp_1 + this->temp_2) / 2.0f));
root["rhumCompensated"] = (int)ag->pms5003t_2.humidityCompensated(
(this->hum_1 + this->hum_2) / 2.0f);
if (localServer) {
root["atmpCompensated"] =
ag->round2(ag->pms5003t_2.temperatureCompensated(
(this->temp_1 + this->temp_2) / 2.0f));
root["rhumCompensated"] = (int)ag->pms5003t_2.humidityCompensated(
(this->hum_1 + this->hum_2) / 2.0f);
}
}

if (fwMode == FW_MODE_O_1PS || fwMode == FW_MODE_O_1PST) {
Expand All @@ -70,10 +76,12 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["pm003Count"] = this->pm03PCount_1;
root["atmp"] = ag->round2(this->temp_1);
root["rhum"] = this->hum_1;
root["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
if (localServer) {
root["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
}
}
if (config->hasSensorPMS2) {
root["pm01"] = this->pm01_2;
Expand All @@ -82,10 +90,12 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["pm003Count"] = this->pm03PCount_2;
root["atmp"] = ag->round2(this->temp_2);
root["rhum"] = this->hum_2;
root["atmpCompensated"] =
ag->round2(ag->pms5003t_2.temperatureCompensated(this->temp_2));
root["rhumCompensated"] =
(int)ag->pms5003t_2.humidityCompensated(this->hum_2);
if (localServer) {
root["atmpCompensated"] =
ag->round2(ag->pms5003t_2.temperatureCompensated(this->temp_2));
root["rhumCompensated"] =
(int)ag->pms5003t_2.humidityCompensated(this->hum_2);
}
}
} else {
if (fwMode == FW_MODE_O_1P) {
Expand All @@ -96,21 +106,25 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["pm003Count"] = this->pm03PCount_1;
root["atmp"] = ag->round2(this->temp_1);
root["rhum"] = this->hum_1;
root["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
if (localServer) {
root["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
}
} else if (config->hasSensorPMS2) {
root["pm01"] = this->pm01_2;
root["pm02"] = this->pm25_2;
root["pm10"] = this->pm10_2;
root["pm003Count"] = this->pm03PCount_2;
root["atmp"] = ag->round2(this->temp_2);
root["rhum"] = this->hum_2;
root["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_2));
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
if (localServer) {
root["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_2));
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
}
}
} else {
if (config->hasSensorPMS1) {
Expand All @@ -120,21 +134,25 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["channels"]["1"]["pm003Count"] = this->pm03PCount_1;
root["channels"]["1"]["atmp"] = ag->round2(this->temp_1);
root["channels"]["1"]["rhum"] = this->hum_1;
root["channels"]["1"]["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["channels"]["1"]["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
if (localServer) {
root["channels"]["1"]["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["channels"]["1"]["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
}
} else if (config->hasSensorPMS2) {
root["channels"]["2"]["pm01"] = this->pm01_2;
root["channels"]["2"]["pm02"] = this->pm25_2;
root["channels"]["2"]["pm10"] = this->pm10_2;
root["channels"]["2"]["pm003Count"] = this->pm03PCount_2;
root["channels"]["2"]["atmp"] = ag->round2(this->temp_2);
root["channels"]["2"]["rhum"] = this->hum_2;
root["channels"]["2"]["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_2));
root["channels"]["2"]["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
if (localServer) {
root["channels"]["2"]["atmpCompensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_2));
root["channels"]["2"]["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
}
}
}
}
Expand All @@ -154,12 +172,12 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["noxRaw"] = this->NOxRaw;
}
}
root["boot"] = bootCount;
root["bootCount"] = bootCount;

if (localServer) {
root["ledMode"] = config->getLedBarModeName();
root["firmwareVersion"] = ag->getVersion();
root["fwMode"] = AgFirmwareModeName(fwMode);
root["firmware"] = ag->getVersion();
root["model"] = AgFirmwareModeName(fwMode);
}

return JSON.stringify(root);
Expand Down

0 comments on commit a2b30a5

Please sign in to comment.