mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 17:52:08 +02:00
Merge pull request #124 from airgradienthq/hotfix/configuration-handle
Configuration failed response message and failed condition handle.
This commit is contained in:
@ -411,6 +411,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
failedMessage =
|
||||
jsonValueInvalidMessage(String(jprop_displayMode), mode);
|
||||
jsonInvalid();
|
||||
return false;
|
||||
@ -503,10 +504,16 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
if (JSON.typeof_(root[jprop_mqttBrokerUrl]) == "string") {
|
||||
String broker = root[jprop_mqttBrokerUrl];
|
||||
String oldBroker = jconfig[jprop_mqttBrokerUrl];
|
||||
if (broker != oldBroker) {
|
||||
changed = true;
|
||||
configLogInfo(String(jprop_mqttBrokerUrl), oldBroker, broker);
|
||||
jconfig[jprop_mqttBrokerUrl] = broker;
|
||||
if (broker.length() <= 255) {
|
||||
if (broker != oldBroker) {
|
||||
changed = true;
|
||||
configLogInfo(String(jprop_mqttBrokerUrl), oldBroker, broker);
|
||||
jconfig[jprop_mqttBrokerUrl] = broker;
|
||||
}
|
||||
} else {
|
||||
failedMessage = "\"mqttBrokerUrl\" length should <= 255";
|
||||
jsonInvalid();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (jsonTypeInvalid(root[jprop_mqttBrokerUrl], "string")) {
|
||||
@ -528,7 +535,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
configLogInfo(String(jprop_temperatureUnit), oldUnit, unit);
|
||||
}
|
||||
} else {
|
||||
jsonValueInvalidMessage(String(jprop_temperatureUnit), unit);
|
||||
failedMessage = jsonValueInvalidMessage(String(jprop_temperatureUnit), unit);
|
||||
jsonInvalid();
|
||||
return false;
|
||||
}
|
||||
@ -665,6 +672,20 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
*/
|
||||
String Configuration::toString(void) { return JSON.stringify(jconfig); }
|
||||
|
||||
/**
|
||||
* @brief Get current configuration value as JSON string
|
||||
*
|
||||
* @param fwMode Firmware mode value
|
||||
* @return String
|
||||
*/
|
||||
String Configuration::toString(AgFirmwareMode fwMode) {
|
||||
String model = jconfig[jprop_model];
|
||||
jconfig[jprop_model] = AgFirmwareModeName(fwMode);
|
||||
String value = toString();
|
||||
jconfig[jprop_model] = model;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Temperature unit (F or C)
|
||||
*
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
bool begin(void);
|
||||
bool parse(String data, bool isLocal);
|
||||
String toString(void);
|
||||
String toString(AgFirmwareMode fwMode);
|
||||
bool isTemperatureUnitInF(void);
|
||||
String getCountry(void);
|
||||
bool isPmStandardInUSAQI(void);
|
||||
|
@ -394,6 +394,9 @@ StateMachine::~StateMachine() {}
|
||||
void StateMachine::displayHandle(AgStateMachineState state) {
|
||||
// Ignore handle if not ONE_INDOOR board
|
||||
if (!ag->isOne()) {
|
||||
if (state == AgStateMachineCo2Calibration) {
|
||||
co2Calibration();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user