mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-30 17:07:16 +02:00
Merge pull request #175 from airgradienthq/fix/local-configuration-response-result
[Fix] Local `configurationControl` return failed if set `cloud`
This commit is contained in:
@ -235,7 +235,10 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
/** Get ConfigurationControl */
|
/** 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 (isLocal) {
|
||||||
if (JSON.typeof_(root[jprop_configurationControl]) == "string") {
|
if (JSON.typeof_(root[jprop_configurationControl]) == "string") {
|
||||||
String ctrl = root[jprop_configurationControl];
|
String ctrl = root[jprop_configurationControl];
|
||||||
@ -248,9 +251,19 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
ctrl ==
|
ctrl ==
|
||||||
String(CONFIGURATION_CONTROL_NAME
|
String(CONFIGURATION_CONTROL_NAME
|
||||||
[ConfigurationControl::ConfigurationControlCloud])) {
|
[ConfigurationControl::ConfigurationControlCloud])) {
|
||||||
if (ctrl != lasCtrl) {
|
if (ctrl != lastCtrl) {
|
||||||
jconfig[jprop_configurationControl] = ctrl;
|
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 {
|
} else {
|
||||||
failedMessage =
|
failedMessage =
|
||||||
@ -267,18 +280,11 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
/** Ignore all configuration value if 'configurationControl' is 'cloud' */
|
||||||
changed = false;
|
|
||||||
saveConfig();
|
|
||||||
configLogInfo(String(jprop_configurationControl), lasCtrl,
|
|
||||||
jconfig[jprop_configurationControl]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jconfig[jprop_configurationControl] ==
|
if (jconfig[jprop_configurationControl] ==
|
||||||
String(CONFIGURATION_CONTROL_NAME
|
String(CONFIGURATION_CONTROL_NAME
|
||||||
[ConfigurationControl::ConfigurationControlCloud])) {
|
[ConfigurationControl::ConfigurationControlCloud])) {
|
||||||
failedMessage = "Monitor set to accept only configuration from the "
|
failedMessage = String(msg);
|
||||||
"cloud. Use property configurationControl to change.";
|
|
||||||
jsonInvalid();
|
jsonInvalid();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user