From 38aebeb50affcc72d379676248ace487b4481923 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Thu, 6 Feb 2025 12:49:41 +0700 Subject: [PATCH 1/5] Reformat pm correction enum naming --- src/AgConfigure.cpp | 36 ++++++++++++++++++------------------ src/AgValue.cpp | 6 +++--- src/App/AppDef.h | 18 +++++++++--------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index ccf1f76..08595d3 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -22,15 +22,15 @@ const char *LED_BAR_MODE_NAMES[] = { }; const char *PM_CORRECTION_ALGORITHM_NAMES[] = { - [Unknown] = "-", // This is only to pass "non-trivial designated initializers" error - [None] = "none", - [EPA_2021] = "epa_2021", - [SLR_PMS5003_20220802] = "slr_PMS5003_20220802", - [SLR_PMS5003_20220803] = "slr_PMS5003_20220803", - [SLR_PMS5003_20220824] = "slr_PMS5003_20220824", - [SLR_PMS5003_20231030] = "slr_PMS5003_20231030", - [SLR_PMS5003_20231218] = "slr_PMS5003_20231218", - [SLR_PMS5003_20240104] = "slr_PMS5003_20240104", + [COR_ALGO_PM_UNKNOWN] = "-", // This is only to pass "non-trivial designated initializers" error + [COR_ALGO_PM_NONE] = "none", + [COR_ALGO_PM_EPA_2021] = "epa_2021", + [COR_ALGO_PM_PMS5003_20220802] = "slr_PMS5003_20220802", + [COR_ALGO_PM_PMS5003_20220803] = "slr_PMS5003_20220803", + [COR_ALGO_PM_PMS5003_20220824] = "slr_PMS5003_20220824", + [COR_ALGO_PM_PMS5003_20231030] = "slr_PMS5003_20231030", + [COR_ALGO_PM_PMS5003_20231218] = "slr_PMS5003_20231218", + [COR_ALGO_PM_PMS5003_20240104] = "slr_PMS5003_20240104", }; const char *TEMP_HUM_CORRECTION_ALGORITHM_NAMES[] = { @@ -115,8 +115,8 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) { // If the input string matches an algorithm name, return the corresponding enum value // Else return Unknown - const size_t enumSize = SLR_PMS5003_20240104 + 1; // Get the actual size of the enum - PMCorrectionAlgorithm result = PMCorrectionAlgorithm::Unknown; + const size_t enumSize = COR_ALGO_PM_PMS5003_20240104 + 1; // Get the actual size of the enum + PMCorrectionAlgorithm result = COR_ALGO_PM_UNKNOWN;; // Loop through enum values for (size_t enumVal = 0; enumVal < enumSize; enumVal++) { @@ -166,7 +166,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) { // Check algorithm String algorithm = pm02["correctionAlgorithm"]; PMCorrectionAlgorithm algo = matchPmAlgorithm(algorithm); - if (algo == Unknown) { + if (algo == COR_ALGO_PM_UNKNOWN) { logInfo("Unknown algorithm"); return false; } @@ -174,7 +174,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) { // If algo is None or EPA_2021, no need to check slr // But first check if pmCorrection different from algo - if (algo == None || algo == EPA_2021) { + if (algo == COR_ALGO_PM_NONE || algo == COR_ALGO_PM_EPA_2021) { if (pmCorrection.algorithm != algo) { // Deep copy corrections from root to jconfig, so it will be saved later jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm; @@ -397,8 +397,8 @@ void Configuration::defaultConfig(void) { jconfig[jprop_offlineMode] = jprop_offlineMode_default; jconfig[jprop_monitorDisplayCompensatedValues] = jprop_monitorDisplayCompensatedValues_default; - // PM2.5 correction - pmCorrection.algorithm = None; + // PM2.5 default correction + pmCorrection.algorithm = COR_ALGO_PM_NONE; pmCorrection.changed = false; pmCorrection.intercept = 0; pmCorrection.scalingFactor = 1; @@ -1380,7 +1380,7 @@ void Configuration::toConfig(const char *buf) { // PM2.5 correction /// Set default first before parsing local config - pmCorrection.algorithm = PMCorrectionAlgorithm::None; + pmCorrection.algorithm = COR_ALGO_PM_NONE; pmCorrection.intercept = 0; pmCorrection.scalingFactor = 0; pmCorrection.useEPA = false; @@ -1526,8 +1526,8 @@ bool Configuration::isPMCorrectionChanged(void) { */ bool Configuration::isPMCorrectionEnabled(void) { PMCorrection pmCorrection = getPMCorrection(); - if (pmCorrection.algorithm == PMCorrectionAlgorithm::None || - pmCorrection.algorithm == PMCorrectionAlgorithm::Unknown) { + if (pmCorrection.algorithm == COR_ALGO_PM_NONE || + pmCorrection.algorithm == COR_ALGO_PM_UNKNOWN) { return false; } diff --git a/src/AgValue.cpp b/src/AgValue.cpp index fac0802..35e21d5 100644 --- a/src/AgValue.cpp +++ b/src/AgValue.cpp @@ -658,12 +658,12 @@ float Measurements::getCorrectedPM25(bool useAvg, int ch) { Configuration::PMCorrection pmCorrection = config.getPMCorrection(); switch (pmCorrection.algorithm) { - case PMCorrectionAlgorithm::Unknown: - case PMCorrectionAlgorithm::None: + case PMCorrectionAlgorithm::COR_ALGO_PM_UNKNOWN: + case PMCorrectionAlgorithm::COR_ALGO_PM_NONE: // If correction is Unknown, then default is None corrected = pm25; break; - case PMCorrectionAlgorithm::EPA_2021: + case PMCorrectionAlgorithm::COR_ALGO_PM_EPA_2021: corrected = ag->pms5003.compensate(pm25, humidity); break; default: { diff --git a/src/App/AppDef.h b/src/App/AppDef.h index 20b8b01..f18970e 100644 --- a/src/App/AppDef.h +++ b/src/App/AppDef.h @@ -95,15 +95,15 @@ enum ConfigurationControl { }; enum PMCorrectionAlgorithm { - Unknown, // Unknown algorithm - None, // No PM correction - EPA_2021, - SLR_PMS5003_20220802, - SLR_PMS5003_20220803, - SLR_PMS5003_20220824, - SLR_PMS5003_20231030, - SLR_PMS5003_20231218, - SLR_PMS5003_20240104, + COR_ALGO_PM_UNKNOWN, // Unknown algorithm + COR_ALGO_PM_NONE, // No PM correction + COR_ALGO_PM_EPA_2021, + COR_ALGO_PM_PMS5003_20220802, + COR_ALGO_PM_PMS5003_20220803, + COR_ALGO_PM_PMS5003_20220824, + COR_ALGO_PM_PMS5003_20231030, + COR_ALGO_PM_PMS5003_20231218, + COR_ALGO_PM_PMS5003_20240104, }; // Don't change the order of the enum From 17d2e62b1538de9f9e03c6765d23df5da89dd79a Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Thu, 6 Feb 2025 15:38:36 +0700 Subject: [PATCH 2/5] Remove delayed oled display --- examples/OneOpenAir/OneOpenAir.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/OneOpenAir/OneOpenAir.ino b/examples/OneOpenAir/OneOpenAir.ino index 2296c52..f88c441 100644 --- a/examples/OneOpenAir/OneOpenAir.ino +++ b/examples/OneOpenAir/OneOpenAir.ino @@ -613,7 +613,7 @@ static void sendDataToAg() { } stateMachine.handleLeds(AgStateMachineWiFiOkServerConnectFailed); } - delay(DISPLAY_DELAY_SHOW_CONTENT_MS); + stateMachine.handleLeds(AgStateMachineNormal); } From 1c42ff083dd724e7bed4c159a00446daafdcdb7b Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Thu, 6 Feb 2025 15:58:15 +0700 Subject: [PATCH 3/5] Make PM correction applied for all model --- src/AgConfigure.cpp | 1 - src/AgValue.cpp | 112 +++++++++++++++++++++----------------------- src/AgValue.h | 3 +- 3 files changed, 55 insertions(+), 61 deletions(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 08595d3..6e0f724 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -238,7 +238,6 @@ bool Configuration::updateTempHumCorrection(JSONVar &json, TempHumCorrection &ta JSONVar corrections = json[jprop_corrections]; if (!corrections.hasOwnProperty(correctionName)) { - Serial.println("pm02 not found"); logWarning(String(correctionName) + " correction field not found on configuration"); return false; } diff --git a/src/AgValue.cpp b/src/AgValue.cpp index 35e21d5..0bed140 100644 --- a/src/AgValue.cpp +++ b/src/AgValue.cpp @@ -639,7 +639,7 @@ float Measurements::getCorrectedTempHum(MeasurementType type, int ch, bool force return corrected; } -float Measurements::getCorrectedPM25(bool useAvg, int ch) { +float Measurements::getCorrectedPM25(bool useAvg, int ch, bool forceCorrection) { float pm25; float corrected; float humidity; @@ -659,10 +659,16 @@ float Measurements::getCorrectedPM25(bool useAvg, int ch) { Configuration::PMCorrection pmCorrection = config.getPMCorrection(); switch (pmCorrection.algorithm) { case PMCorrectionAlgorithm::COR_ALGO_PM_UNKNOWN: - case PMCorrectionAlgorithm::COR_ALGO_PM_NONE: - // If correction is Unknown, then default is None - corrected = pm25; + case PMCorrectionAlgorithm::COR_ALGO_PM_NONE: { + // If correction is Unknown or None, then default is None + // Unless forceCorrection enabled + if (forceCorrection) { + corrected = ag->pms5003.compensate(pm25, humidity); + } else { + corrected = pm25; + } break; + } case PMCorrectionAlgorithm::COR_ALGO_PM_EPA_2021: corrected = ag->pms5003.compensate(pm25, humidity); break; @@ -780,8 +786,8 @@ JSONVar Measurements::buildIndoor(bool localServer) { // buildPMS params: /// PMS channel 1 (indoor only have 1 PMS; hence allCh false) /// Not include temperature and humidity from PMS sensor - /// Not include compensated calculation - indoor = buildPMS(1, false, false, false); + /// Include compensated calculation + indoor = buildPMS(1, false, false, true); if (!localServer) { // Indoor is using PMS5003 indoor[json_prop_pmFirmware] = this->pms5003FirmwareVersion(ag->pms5003.getFirmwareVersion()); @@ -805,15 +811,6 @@ JSONVar Measurements::buildIndoor(bool localServer) { } } - // Add pm25 compensated value only if PM2.5 and humidity value is valid - if (config.hasSensorPMS1 && utils::isValidPm(_pm_25[0].update.avg)) { - if (config.hasSensorSHT && utils::isValidHumidity(_humidity[0].update.avg)) { - // Correction using moving average value - float tmp = getCorrectedPM25(true); - indoor[json_prop_pm25Compensated] = ag->round2(tmp); - } - } - return indoor; } @@ -826,58 +823,58 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen validateChannel(ch); // Follow array indexing just for get address of the value type - ch = ch - 1; + int chIndex = ch - 1; - if (utils::isValidPm(_pm_01[ch].update.avg)) { - pms[json_prop_pm01Ae] = ag->round2(_pm_01[ch].update.avg); + if (utils::isValidPm(_pm_01[chIndex].update.avg)) { + pms[json_prop_pm01Ae] = ag->round2(_pm_01[chIndex].update.avg); } - if (utils::isValidPm(_pm_25[ch].update.avg)) { - pms[json_prop_pm25Ae] = ag->round2(_pm_25[ch].update.avg); + if (utils::isValidPm(_pm_25[chIndex].update.avg)) { + pms[json_prop_pm25Ae] = ag->round2(_pm_25[chIndex].update.avg); } - if (utils::isValidPm(_pm_10[ch].update.avg)) { - pms[json_prop_pm10Ae] = ag->round2(_pm_10[ch].update.avg); + if (utils::isValidPm(_pm_10[chIndex].update.avg)) { + pms[json_prop_pm10Ae] = ag->round2(_pm_10[chIndex].update.avg); } - if (utils::isValidPm(_pm_01_sp[ch].update.avg)) { - pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[ch].update.avg); + if (utils::isValidPm(_pm_01_sp[chIndex].update.avg)) { + pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[chIndex].update.avg); } - if (utils::isValidPm(_pm_25_sp[ch].update.avg)) { - pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[ch].update.avg); + if (utils::isValidPm(_pm_25_sp[chIndex].update.avg)) { + pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[chIndex].update.avg); } - if (utils::isValidPm(_pm_10_sp[ch].update.avg)) { - pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[ch].update.avg); + if (utils::isValidPm(_pm_10_sp[chIndex].update.avg)) { + pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[chIndex].update.avg); } - if (utils::isValidPm03Count(_pm_03_pc[ch].update.avg)) { - pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[ch].update.avg); + if (utils::isValidPm03Count(_pm_03_pc[chIndex].update.avg)) { + pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[chIndex].update.avg); } - if (utils::isValidPm03Count(_pm_05_pc[ch].update.avg)) { - pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[ch].update.avg); + if (utils::isValidPm03Count(_pm_05_pc[chIndex].update.avg)) { + pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[chIndex].update.avg); } - if (utils::isValidPm03Count(_pm_01_pc[ch].update.avg)) { - pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[ch].update.avg); + if (utils::isValidPm03Count(_pm_01_pc[chIndex].update.avg)) { + pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[chIndex].update.avg); } - if (utils::isValidPm03Count(_pm_25_pc[ch].update.avg)) { - pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[ch].update.avg); + if (utils::isValidPm03Count(_pm_25_pc[chIndex].update.avg)) { + pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[chIndex].update.avg); } - if (_pm_5_pc[ch].listValues.empty() == false) { + if (_pm_5_pc[chIndex].listValues.empty() == false) { // Only include pm5.0 count when values available on its list // If not, means no pm5_pc available from the sensor - if (utils::isValidPm03Count(_pm_5_pc[ch].update.avg)) { - pms[json_prop_pm5Count] = ag->round2(_pm_5_pc[ch].update.avg); + if (utils::isValidPm03Count(_pm_5_pc[chIndex].update.avg)) { + pms[json_prop_pm5Count] = ag->round2(_pm_5_pc[chIndex].update.avg); } } - if (_pm_10_pc[ch].listValues.empty() == false) { + if (_pm_10_pc[chIndex].listValues.empty() == false) { // Only include pm10 count when values available on its list // If not, means no pm10_pc available from the sensor - if (utils::isValidPm03Count(_pm_10_pc[ch].update.avg)) { - pms[json_prop_pm10Count] = ag->round2(_pm_10_pc[ch].update.avg); + if (utils::isValidPm03Count(_pm_10_pc[chIndex].update.avg)) { + pms[json_prop_pm10Count] = ag->round2(_pm_10_pc[chIndex].update.avg); } } if (withTempHum) { float _vc; // Set temperature if valid - if (utils::isValidTemperature(_temperature[ch].update.avg)) { - pms[json_prop_temp] = ag->round2(_temperature[ch].update.avg); + if (utils::isValidTemperature(_temperature[chIndex].update.avg)) { + pms[json_prop_temp] = ag->round2(_temperature[chIndex].update.avg); // Compensate temperature when flag is set if (compensate) { _vc = getCorrectedTempHum(Temperature, ch, true); @@ -887,8 +884,8 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen } } // Set humidity if valid - if (utils::isValidHumidity(_humidity[ch].update.avg)) { - pms[json_prop_rhum] = ag->round2(_humidity[ch].update.avg); + if (utils::isValidHumidity(_humidity[chIndex].update.avg)) { + pms[json_prop_rhum] = ag->round2(_humidity[chIndex].update.avg); // Compensate relative humidity when flag is set if (compensate) { _vc = getCorrectedTempHum(Humidity, ch, true); @@ -898,17 +895,14 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen } } - // Add pm25 compensated value only if PM2.5 and humidity value is valid - if (compensate) { - if (utils::isValidPm(_pm_25[ch].update.avg) && - utils::isValidHumidity(_humidity[ch].update.avg)) { - // Note: the pms5003t object is not matter either for channel 1 or 2, compensate points to - // the same base function - float pm25 = ag->pms5003t_1.compensate(_pm_25[ch].update.avg, _humidity[ch].update.avg); - if (utils::isValidPm(pm25)) { - pms[json_prop_pm25Compensated] = ag->round2(pm25); - } - } + } + + // Add pm25 compensated value only if PM2.5 and humidity value is valid + if (compensate) { + if (utils::isValidPm(_pm_25[chIndex].update.avg) && + utils::isValidHumidity(_humidity[chIndex].update.avg)) { + float pm25 = getCorrectedPM25(true, ch, true); + pms[json_prop_pm25Compensated] = ag->round2(pm25); } } @@ -1156,12 +1150,12 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen float pm25_comp2 = utils::getInvalidPmValue(); if (utils::isValidPm(_pm_25[0].update.avg) && utils::isValidHumidity(_humidity[0].update.avg)) { - pm25_comp1 = ag->pms5003t_1.compensate(_pm_25[0].update.avg, _humidity[0].update.avg); + pm25_comp1 = getCorrectedPM25(true, 1, true); pms["channels"]["1"][json_prop_pm25Compensated] = ag->round2(pm25_comp1); } if (utils::isValidPm(_pm_25[1].update.avg) && utils::isValidHumidity(_humidity[1].update.avg)) { - pm25_comp2 = ag->pms5003t_2.compensate(_pm_25[1].update.avg, _humidity[1].update.avg); + pm25_comp2 = getCorrectedPM25(true, 2, true); pms["channels"]["2"][json_prop_pm25Compensated] = ag->round2(pm25_comp2); } diff --git a/src/AgValue.h b/src/AgValue.h index db5508e..9a3c446 100644 --- a/src/AgValue.h +++ b/src/AgValue.h @@ -144,9 +144,10 @@ public: * * @param useAvg Use moving average value if true, otherwise use latest value * @param ch MeasurementType channel + * @param forceCorrection force using correction even though config correction is not applied, default to EPA * @return float Corrected PM2.5 value */ - float getCorrectedPM25(bool useAvg = false, int ch = 1); + float getCorrectedPM25(bool useAvg = false, int ch = 1, bool forceCorrection = false); /** * build json payload for every measurements From d4b4f51c3cd7b5639eef9c669a64cd9cd64e99f4 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Thu, 6 Feb 2025 17:35:01 +0700 Subject: [PATCH 4/5] Map batch PM correction as custom enum --- src/AgConfigure.cpp | 32 +++++++++++++++++--------------- src/App/AppDef.h | 7 +------ 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 6e0f724..d2b6e81 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -25,12 +25,7 @@ const char *PM_CORRECTION_ALGORITHM_NAMES[] = { [COR_ALGO_PM_UNKNOWN] = "-", // This is only to pass "non-trivial designated initializers" error [COR_ALGO_PM_NONE] = "none", [COR_ALGO_PM_EPA_2021] = "epa_2021", - [COR_ALGO_PM_PMS5003_20220802] = "slr_PMS5003_20220802", - [COR_ALGO_PM_PMS5003_20220803] = "slr_PMS5003_20220803", - [COR_ALGO_PM_PMS5003_20220824] = "slr_PMS5003_20220824", - [COR_ALGO_PM_PMS5003_20231030] = "slr_PMS5003_20231030", - [COR_ALGO_PM_PMS5003_20231218] = "slr_PMS5003_20231218", - [COR_ALGO_PM_PMS5003_20240104] = "slr_PMS5003_20240104", + [COR_ALGO_PM_SLR_CUSTOM] = "custom", }; const char *TEMP_HUM_CORRECTION_ALGORITHM_NAMES[] = { @@ -115,7 +110,7 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) { // If the input string matches an algorithm name, return the corresponding enum value // Else return Unknown - const size_t enumSize = COR_ALGO_PM_PMS5003_20240104 + 1; // Get the actual size of the enum + const size_t enumSize = COR_ALGO_PM_SLR_CUSTOM + 1; // Get the actual size of the enum PMCorrectionAlgorithm result = COR_ALGO_PM_UNKNOWN;; // Loop through enum values @@ -125,6 +120,15 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) { } } + // If string not match from enum, check if correctionAlgorithm is one of the PM batch corrections + if (result == COR_ALGO_PM_UNKNOWN) { + // Check the substring "slr_PMS5003_xxxxxxxx" + if (algorithm.substring(0, 11) == "slr_PMS5003") { + // If it is, then its a custom correction + result = COR_ALGO_PM_SLR_CUSTOM; + } + } + return result; } @@ -145,29 +149,27 @@ TempHumCorrectionAlgorithm Configuration::matchTempHumAlgorithm(String algorithm bool Configuration::updatePmCorrection(JSONVar &json) { if (!json.hasOwnProperty("corrections")) { - Serial.println("corrections not found"); + logInfo("corrections not found"); return false; } JSONVar corrections = json["corrections"]; if (!corrections.hasOwnProperty("pm02")) { - Serial.println("pm02 not found"); + logWarning("pm02 not found"); return false; } JSONVar pm02 = corrections["pm02"]; if (!pm02.hasOwnProperty("correctionAlgorithm")) { - Serial.println("correctionAlgorithm not found"); + logWarning("pm02 correctionAlgorithm not found"); return false; } - // TODO: Need to have data type check, with error message response if invalid - // Check algorithm String algorithm = pm02["correctionAlgorithm"]; PMCorrectionAlgorithm algo = matchPmAlgorithm(algorithm); if (algo == COR_ALGO_PM_UNKNOWN) { - logInfo("Unknown algorithm"); + logWarning("Unknown algorithm"); return false; } logInfo("Correction algorithm: " + algorithm); @@ -191,7 +193,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) { // Check if pm02 has slr object if (!pm02.hasOwnProperty("slr")) { - Serial.println("slr not found"); + logWarning("slr not found"); return false; } @@ -200,7 +202,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) { // Validate required slr properties exist if (!slr.hasOwnProperty("intercept") || !slr.hasOwnProperty("scalingFactor") || !slr.hasOwnProperty("useEpa2021")) { - Serial.println("Missing required slr properties"); + logWarning("Missing required slr properties"); return false; } diff --git a/src/App/AppDef.h b/src/App/AppDef.h index f18970e..a80032b 100644 --- a/src/App/AppDef.h +++ b/src/App/AppDef.h @@ -98,12 +98,7 @@ enum PMCorrectionAlgorithm { COR_ALGO_PM_UNKNOWN, // Unknown algorithm COR_ALGO_PM_NONE, // No PM correction COR_ALGO_PM_EPA_2021, - COR_ALGO_PM_PMS5003_20220802, - COR_ALGO_PM_PMS5003_20220803, - COR_ALGO_PM_PMS5003_20220824, - COR_ALGO_PM_PMS5003_20231030, - COR_ALGO_PM_PMS5003_20231218, - COR_ALGO_PM_PMS5003_20240104, + COR_ALGO_PM_SLR_CUSTOM, }; // Don't change the order of the enum From 4c7e72b8e788397af8cc5a2f624886a9926293ab Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Fri, 7 Feb 2025 10:45:14 +0700 Subject: [PATCH 5/5] Better logging Fix notif when wifi not connect --- examples/OneOpenAir/OneOpenAir.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/OneOpenAir/OneOpenAir.ino b/examples/OneOpenAir/OneOpenAir.ino index f88c441..3202f12 100644 --- a/examples/OneOpenAir/OneOpenAir.ino +++ b/examples/OneOpenAir/OneOpenAir.ino @@ -908,6 +908,11 @@ static void configurationUpdateSchedule(void) { return; } + if (wifiConnector.isConnected() == false) { + Serial.println(" WiFi not connected, skipping fetch configuration from AG server"); + return; + } + if (apiClient.fetchServerConfiguration()) { configUpdateHandle(); } @@ -1008,6 +1013,7 @@ static void updateDisplayAndLedBar(void) { if (wifiConnector.isConnected() == false) { stateMachine.displayHandle(AgStateMachineWiFiLost); stateMachine.handleLeds(AgStateMachineWiFiLost); + return; } if (configuration.isCloudConnectionDisabled()) {