Merge commit '5a2c1bd1d0290e5cae0b8dec02eb2a931211d1af' into feature/add-esp8266-examples

This commit is contained in:
Phat Nguyen
2024-06-25 15:19:28 +07:00

View File

@ -235,7 +235,10 @@ bool Configuration::parse(String data, bool isLocal) {
bool changed = false;
/** Get ConfigurationControl */
String lasCtrl = jconfig[jprop_configurationControl];
String lastCtrl = jconfig[jprop_configurationControl];
const char *msg = "Monitor set to accept only configuration from the "
"cloud. Use property configurationControl to change.";
if (isLocal) {
if (JSON.typeof_(root[jprop_configurationControl]) == "string") {
String ctrl = root[jprop_configurationControl];
@ -248,9 +251,19 @@ bool Configuration::parse(String data, bool isLocal) {
ctrl ==
String(CONFIGURATION_CONTROL_NAME
[ConfigurationControl::ConfigurationControlCloud])) {
if (ctrl != lasCtrl) {
if (ctrl != lastCtrl) {
jconfig[jprop_configurationControl] = ctrl;
changed = true;
saveConfig();
configLogInfo(String(jprop_configurationControl), lastCtrl,
jconfig[jprop_configurationControl]);
}
/** Check to return result if configurationControl is 'cloud' */
if (ctrl ==
String(CONFIGURATION_CONTROL_NAME
[ConfigurationControl::ConfigurationControlCloud])) {
failedMessage = String(msg);
return true;
}
} else {
failedMessage =
@ -267,18 +280,11 @@ bool Configuration::parse(String data, bool isLocal) {
}
}
if (changed) {
changed = false;
saveConfig();
configLogInfo(String(jprop_configurationControl), lasCtrl,
jconfig[jprop_configurationControl]);
}
/** Ignore all configuration value if 'configurationControl' is 'cloud' */
if (jconfig[jprop_configurationControl] ==
String(CONFIGURATION_CONTROL_NAME
[ConfigurationControl::ConfigurationControlCloud])) {
failedMessage = "Monitor set to accept only configuration from the "
"cloud. Use property configurationControl to change.";
failedMessage = String(msg);
jsonInvalid();
return false;
}