update log message and fix ledBarTestRequested, co2CalibrationRequested not execute

This commit is contained in:
Phat Nguyen
2024-04-22 06:27:57 +07:00
parent 2b891c0194
commit 7561017b3d

View File

@ -178,6 +178,8 @@ bool Configuration::begin(void) {
* @return false Failure * @return false Failure
*/ */
bool Configuration::parse(String data, bool isLocal) { bool Configuration::parse(String data, bool isLocal) {
logInfo("Parse configure: " + data);
JSONVar root = JSON.parse(data); JSONVar root = JSON.parse(data);
failedMessage = ""; failedMessage = "";
if (JSON.typeof_(root) == "undefined") { if (JSON.typeof_(root) == "undefined") {
@ -477,19 +479,21 @@ bool Configuration::parse(String data, bool isLocal) {
logInfo("set temperatureUnit: " + String(temperatureUnit)); logInfo("set temperatureUnit: " + String(temperatureUnit));
} }
if (JSON.typeof_(root["postDataToAirGradient"]) == "boolean") { if (isLocal) {
bool post = root["postDataToAirGradient"]; if (JSON.typeof_(root["postDataToAirGradient"]) == "boolean") {
if (post != config.postDataToAirGradient) { bool post = root["postDataToAirGradient"];
changed = true; if (post != config.postDataToAirGradient) {
config.postDataToAirGradient = post; changed = true;
logInfo("Set postDataToAirGradient: " + String(post)); config.postDataToAirGradient = post;
} logInfo("Set postDataToAirGradient: " + String(post));
} else { }
if (jsonTypeInvalid(root["postDataToAirGradient"], "boolean")) { } else {
failedMessage = if (jsonTypeInvalid(root["postDataToAirGradient"], "boolean")) {
jsonTypeInvalidMessage("postDataToAirGradient", "boolean"); failedMessage =
jsonInvalid(); jsonTypeInvalidMessage("postDataToAirGradient", "boolean");
return false; jsonInvalid();
return false;
}
} }
} }
@ -520,6 +524,10 @@ bool Configuration::parse(String data, bool isLocal) {
if (changed) { if (changed) {
udpated = true; udpated = true;
saveConfig(); saveConfig();
} else {
if (ledBarTestRequested || co2CalibrationRequested) {
udpated = true;
}
} }
printConfig(); printConfig();
return true; return true;