diff --git a/examples/OneOpenAir/OneOpenAir.ino b/examples/OneOpenAir/OneOpenAir.ino index 8f13a6a..0424336 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(); diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index d2b6e81..9f931c0 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; } @@ -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"); 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(); }