From 7561017b3d641177900752c90ccb4031d24b008c Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Mon, 22 Apr 2024 06:27:57 +0700 Subject: [PATCH] update log message and fix `ledBarTestRequested`, `co2CalibrationRequested` not execute --- src/AgConfigure.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 4469006..7bd551c 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -178,6 +178,8 @@ bool Configuration::begin(void) { * @return false Failure */ bool Configuration::parse(String data, bool isLocal) { + logInfo("Parse configure: " + data); + JSONVar root = JSON.parse(data); failedMessage = ""; if (JSON.typeof_(root) == "undefined") { @@ -477,19 +479,21 @@ bool Configuration::parse(String data, bool isLocal) { logInfo("set temperatureUnit: " + String(temperatureUnit)); } - if (JSON.typeof_(root["postDataToAirGradient"]) == "boolean") { - bool post = root["postDataToAirGradient"]; - if (post != config.postDataToAirGradient) { - changed = true; - config.postDataToAirGradient = post; - logInfo("Set postDataToAirGradient: " + String(post)); - } - } else { - if (jsonTypeInvalid(root["postDataToAirGradient"], "boolean")) { - failedMessage = - jsonTypeInvalidMessage("postDataToAirGradient", "boolean"); - jsonInvalid(); - return false; + if (isLocal) { + if (JSON.typeof_(root["postDataToAirGradient"]) == "boolean") { + bool post = root["postDataToAirGradient"]; + if (post != config.postDataToAirGradient) { + changed = true; + config.postDataToAirGradient = post; + logInfo("Set postDataToAirGradient: " + String(post)); + } + } else { + if (jsonTypeInvalid(root["postDataToAirGradient"], "boolean")) { + failedMessage = + jsonTypeInvalidMessage("postDataToAirGradient", "boolean"); + jsonInvalid(); + return false; + } } } @@ -520,6 +524,10 @@ bool Configuration::parse(String data, bool isLocal) { if (changed) { udpated = true; saveConfig(); + } else { + if (ledBarTestRequested || co2CalibrationRequested) { + udpated = true; + } } printConfig(); return true;