From decdecdf228fea2ee85bf2e3c48cb9619c413a67 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Mon, 31 Mar 2025 14:01:49 +0700 Subject: [PATCH 1/4] Don't start mqtt when network option is cellular Even when mqtt host is set --- examples/OneOpenAir/OneOpenAir.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/OneOpenAir/OneOpenAir.ino b/examples/OneOpenAir/OneOpenAir.ino index 82123fe..602bbd6 100644 --- a/examples/OneOpenAir/OneOpenAir.ino +++ b/examples/OneOpenAir/OneOpenAir.ino @@ -423,6 +423,11 @@ static void initMqtt(void) { return; } + if (networkOption == UseCellular) { + Serial.println("MQTT not available for cellular options"); + return; + } + if (mqttClient.begin(mqttUri)) { Serial.println("Successfully connected to MQTT broker"); createMqttTask(); From 7fbab82088f47bbedeb94d50c22678b0fbc94b9e Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Mon, 31 Mar 2025 14:07:30 +0700 Subject: [PATCH 2/4] Change log level when correction not found --- src/AgConfigure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index d2b6e81..37645d6 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -240,7 +240,7 @@ bool Configuration::updateTempHumCorrection(JSONVar &json, TempHumCorrection &ta JSONVar corrections = json[jprop_corrections]; if (!corrections.hasOwnProperty(correctionName)) { - logWarning(String(correctionName) + " correction field not found on configuration"); + logInfo(String(correctionName) + " correction field not found on configuration"); return false; } From e9be9dcc83ef3a405be26247e75393db822d8140 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Mon, 31 Mar 2025 14:51:53 +0700 Subject: [PATCH 3/4] Fix mqtt host still exist on local when on server is disabled --- src/AgConfigure.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 37645d6..9f931c0 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -739,7 +739,13 @@ bool Configuration::parse(String data, bool isLocal) { jsonInvalid(); return false; } - } else { + } + else if (JSON.typeof_(root[jprop_mqttBrokerUrl]) == "null" and !isLocal) { + // So if its not available on the json and json comes from aigradient server + // then set its value to default (empty) + jconfig[jprop_mqttBrokerUrl] = jprop_mqttBrokerUrl_default; + } + else { if (jsonTypeInvalid(root[jprop_mqttBrokerUrl], "string")) { failedMessage = jsonTypeInvalidMessage(String(jprop_mqttBrokerUrl), "string"); From 958ed0bd80e9701b612d70cefb4ecf0af34fbba7 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Mon, 31 Mar 2025 15:26:34 +0700 Subject: [PATCH 4/4] Fix TVOC and NOx payload position --- src/AgValue.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/AgValue.cpp b/src/AgValue.cpp index 4fe2af6..408a700 100644 --- a/src/AgValue.cpp +++ b/src/AgValue.cpp @@ -804,16 +804,16 @@ std::string Measurements::buildMeasuresPayload(Measures &mc) { oss << ","; - // NOx - if (utils::isValidNOx(mc.nox)) { - oss << std::round(mc.nox); + // TVOC + if (utils::isValidVOC(mc.tvoc)) { + oss << std::round(mc.tvoc); } oss << ","; - // TVOC - if (utils::isValidVOC(mc.tvoc)) { - oss << std::round(mc.tvoc); + // NOx + if (utils::isValidNOx(mc.nox)) { + oss << std::round(mc.nox); } oss << ","; @@ -827,10 +827,6 @@ std::string Measurements::buildMeasuresPayload(Measures &mc) { oss << std::round(mc.pm_03_pc[1]); } - // char datapoint[128] = {0}; - // snprintf(datapoint, 128, "%d,%.0f,%.0f,%.0f,%.0f,%.0f,%d,%d,%d", co2, temp * 10, - // hum * 10, pm01 * 10, pm25 * 10, pm10 * 10, tvoc, nox, pm003Count); - return oss.str(); }