add firmware mode O-1P

This commit is contained in:
Phat Nguyen
2024-04-13 21:07:20 +07:00
parent 09cbbed856
commit ccee987d05
2 changed files with 70 additions and 30 deletions

View File

@ -613,6 +613,14 @@ static void openAirInit(void) {
} else { } else {
Serial.println("Found PMS 2 on Serial1"); Serial.println("Found PMS 2 on Serial1");
} }
if (fwMode == FW_MODE_O_1PP) {
int count = (configuration.hasSensorPMS1 ? 1 : 0) +
(configuration.hasSensorPMS2 ? 1 : 0);
if (count == 1) {
fwMode = FW_MODE_O_1P;
}
}
} }
/** update the PMS poll period base on fw mode and sensor available */ /** update the PMS poll period base on fw mode and sensor available */
@ -621,7 +629,6 @@ static void openAirInit(void) {
pmsSchedule.setPeriod(2000); pmsSchedule.setPeriod(2000);
} }
} }
Serial.printf("Firmware Mode: %s\r\n", AgFirmwareModeName(fwMode)); Serial.printf("Firmware Mode: %s\r\n", AgFirmwareModeName(fwMode));
} }

View File

@ -104,6 +104,39 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["rhum_compensated"] = root["rhum_compensated"] =
(int)ag->pms5003t_2.humidityCompensated(this->hum_2); (int)ag->pms5003t_2.humidityCompensated(this->hum_2);
} }
} else {
if (fwMode == FW_MODE_O_1P) {
if (config->hasSensorPMS1) {
root["pm01"] = this->pm01_1;
root["pm02"] = this->pm25_1;
root["pm10"] = this->pm10_1;
if (localServer) {
root["pm003Count"] = this->pm03PCount_1;
} else {
root["pm003_count"] = this->pm03PCount_1;
}
root["atmp"] = ag->round2(this->temp_1);
root["rhum"] = this->hum_1;
root["atmp_compensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["rhum_compensated"] =
(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;
if (localServer) {
root["pm003Count"] = this->pm03PCount_2;
} else {
root["pm003_count"] = this->pm03PCount_2;
}
root["atmp"] = ag->round2(this->temp_2);
root["rhum"] = this->hum_2;
root["atmp_compensated"] =
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_2));
root["rhum_compensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
}
} else { } else {
if (config->hasSensorPMS1) { if (config->hasSensorPMS1) {
root["channels"]["1"]["pm01"] = this->pm01_1; root["channels"]["1"]["pm01"] = this->pm01_1;
@ -120,8 +153,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1)); ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
root["channels"]["1"]["rhum_compensated"] = root["channels"]["1"]["rhum_compensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1); (int)ag->pms5003t_1.humidityCompensated(this->hum_1);
} } else if (config->hasSensorPMS2) {
if (config->hasSensorPMS2) {
root["channels"]["2"]["pm01"] = this->pm01_2; root["channels"]["2"]["pm01"] = this->pm01_2;
root["channels"]["2"]["pm02"] = this->pm25_2; root["channels"]["2"]["pm02"] = this->pm25_2;
root["channels"]["2"]["pm10"] = this->pm10_2; root["channels"]["2"]["pm10"] = this->pm10_2;
@ -139,6 +171,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
}
if (config->hasSensorSGP) { if (config->hasSensorSGP) {
if (this->TVOC >= 0) { if (this->TVOC >= 0) {