mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-04 11:46:32 +02:00
[update message log and fix some bug] add miss
This commit is contained in:
@ -90,6 +90,7 @@ void Configuration::loadConfig(void) {
|
|||||||
logError("Configure validate invalid");
|
logError("Configure validate invalid");
|
||||||
defaultConfig();
|
defaultConfig();
|
||||||
} else {
|
} else {
|
||||||
|
/** Correct configuration parameter value. */
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if ((config.temperatureUnit != 'c') && (config.temperatureUnit != 'f')) {
|
if ((config.temperatureUnit != 'c') && (config.temperatureUnit != 'f')) {
|
||||||
config.temperatureUnit = 'c';
|
config.temperatureUnit = 'c';
|
||||||
@ -194,32 +195,37 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
|
|
||||||
/** Get ConfigurationControl */
|
/** Get ConfigurationControl */
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
|
uint8_t configurationControl = config.configurationControl;
|
||||||
if (JSON.typeof_(root["configurationControl"]) == "string") {
|
if (JSON.typeof_(root["configurationControl"]) == "string") {
|
||||||
String configurationControl = root["configurationControl"];
|
String configurationControl = root["configurationControl"];
|
||||||
if (configurationControl ==
|
if (configurationControl !=
|
||||||
String(CONFIGURATION_CONTROL_NAME
|
String(CONFIGURATION_CONTROL_NAME[config.configurationControl])) {
|
||||||
[ConfigurationControl::ConfigurationControlLocal])) {
|
if (configurationControl ==
|
||||||
config.configurationControl =
|
String(CONFIGURATION_CONTROL_NAME
|
||||||
(uint8_t)ConfigurationControl::ConfigurationControlLocal;
|
[ConfigurationControl::ConfigurationControlLocal])) {
|
||||||
changed = true;
|
config.configurationControl =
|
||||||
} else if (configurationControl ==
|
(uint8_t)ConfigurationControl::ConfigurationControlLocal;
|
||||||
String(
|
changed = true;
|
||||||
CONFIGURATION_CONTROL_NAME
|
} else if (configurationControl ==
|
||||||
[ConfigurationControl::ConfigurationControlCloud])) {
|
String(
|
||||||
config.configurationControl =
|
CONFIGURATION_CONTROL_NAME
|
||||||
(uint8_t)ConfigurationControl::ConfigurationControlCloud;
|
[ConfigurationControl::ConfigurationControlCloud])) {
|
||||||
changed = true;
|
config.configurationControl =
|
||||||
} else if (configurationControl ==
|
(uint8_t)ConfigurationControl::ConfigurationControlCloud;
|
||||||
String(CONFIGURATION_CONTROL_NAME
|
changed = true;
|
||||||
[ConfigurationControl::ConfigurationControlBoth])) {
|
} else if (configurationControl ==
|
||||||
config.configurationControl =
|
String(
|
||||||
(uint8_t)ConfigurationControl::ConfigurationControlBoth;
|
CONFIGURATION_CONTROL_NAME
|
||||||
changed = true;
|
[ConfigurationControl::ConfigurationControlBoth])) {
|
||||||
} else {
|
config.configurationControl =
|
||||||
failedMessage = jsonValueInvalidMessage("configurationControl",
|
(uint8_t)ConfigurationControl::ConfigurationControlBoth;
|
||||||
configurationControl);
|
changed = true;
|
||||||
jsonInvalid();
|
} else {
|
||||||
return false;
|
failedMessage = jsonValueInvalidMessage("configurationControl",
|
||||||
|
configurationControl);
|
||||||
|
jsonInvalid();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["configurationControl"], "string")) {
|
if (jsonTypeInvalid(root["configurationControl"], "string")) {
|
||||||
@ -230,6 +236,15 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
changed = false;
|
||||||
|
saveConfig();
|
||||||
|
configLogInfo(
|
||||||
|
"configurationControl",
|
||||||
|
String(CONFIGURATION_CONTROL_NAME[configurationControl]),
|
||||||
|
String(CONFIGURATION_CONTROL_NAME[config.configurationControl]));
|
||||||
|
}
|
||||||
|
|
||||||
if ((config.configurationControl ==
|
if ((config.configurationControl ==
|
||||||
(byte)ConfigurationControl::ConfigurationControlCloud)) {
|
(byte)ConfigurationControl::ConfigurationControlCloud)) {
|
||||||
failedMessage = "Local configure ignored";
|
failedMessage = "Local configure ignored";
|
||||||
@ -251,17 +266,8 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (country.length() == 2) {
|
if (country.length() == 2) {
|
||||||
if (country != String(config.country)) {
|
if (country != String(config.country)) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
configLogInfo("country", String(config.country), country);
|
||||||
snprintf(config.country, sizeof(config.country), country.c_str());
|
snprintf(config.country, sizeof(config.country), country.c_str());
|
||||||
logInfo(String("Set country: " + country).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update temperature unit if get configuration from server
|
|
||||||
if (isLocal == false) {
|
|
||||||
if (country == "US") {
|
|
||||||
temperatureUnit = 'f';
|
|
||||||
} else {
|
|
||||||
temperatureUnit = 'c';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
failedMessage = "Country name " + country +
|
failedMessage = "Country name " + country +
|
||||||
@ -281,9 +287,9 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (JSON.typeof_(root["pmStandard"]) == "string") {
|
if (JSON.typeof_(root["pmStandard"]) == "string") {
|
||||||
String pmStandard = root["pmStandard"];
|
String pmStandard = root["pmStandard"];
|
||||||
bool inUSAQI = true;
|
bool inUSAQI = true;
|
||||||
if (pmStandard == "ugm3") {
|
if (pmStandard == getPMStandardString(false)) {
|
||||||
inUSAQI = false;
|
inUSAQI = false;
|
||||||
} else if (pmStandard == "us-aqi") {
|
} else if (pmStandard == getPMStandardString(true)) {
|
||||||
inUSAQI = true;
|
inUSAQI = true;
|
||||||
} else {
|
} else {
|
||||||
failedMessage = jsonValueInvalidMessage("pmStandard", pmStandard);
|
failedMessage = jsonValueInvalidMessage("pmStandard", pmStandard);
|
||||||
@ -292,9 +298,9 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inUSAQI != config.inUSAQI) {
|
if (inUSAQI != config.inUSAQI) {
|
||||||
|
configLogInfo("pmStandard", getPMStandardString(config.inUSAQI), pmStandard);
|
||||||
config.inUSAQI = inUSAQI;
|
config.inUSAQI = inUSAQI;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("Set PM standard: " + pmStandard);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["pmStandard"], "string")) {
|
if (jsonTypeInvalid(root["pmStandard"], "string")) {
|
||||||
@ -306,7 +312,10 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
|
|
||||||
if (JSON.typeof_(root["co2CalibrationRequested"]) == "boolean") {
|
if (JSON.typeof_(root["co2CalibrationRequested"]) == "boolean") {
|
||||||
co2CalibrationRequested = root["co2CalibrationRequested"];
|
co2CalibrationRequested = root["co2CalibrationRequested"];
|
||||||
logInfo("Set co2CalibrationRequested: " + String(co2CalibrationRequested));
|
if(co2CalibrationRequested) {
|
||||||
|
logInfo("co2CalibrationRequested: " +
|
||||||
|
String(co2CalibrationRequested ? "True" : "False"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["co2CalibrationRequested"], "boolean")) {
|
if (jsonTypeInvalid(root["co2CalibrationRequested"], "boolean")) {
|
||||||
failedMessage =
|
failedMessage =
|
||||||
@ -318,7 +327,10 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
|
|
||||||
if (JSON.typeof_(root["ledBarTestRequested"]) == "boolean") {
|
if (JSON.typeof_(root["ledBarTestRequested"]) == "boolean") {
|
||||||
ledBarTestRequested = root["ledBarTestRequested"];
|
ledBarTestRequested = root["ledBarTestRequested"];
|
||||||
logInfo("Set ledBarTestRequested: " + String(ledBarTestRequested));
|
if(ledBarTestRequested){
|
||||||
|
logInfo("ledBarTestRequested: " +
|
||||||
|
String(ledBarTestRequested ? "True" : "False"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["ledBarTestRequested"], "boolean")) {
|
if (jsonTypeInvalid(root["ledBarTestRequested"], "boolean")) {
|
||||||
failedMessage = jsonTypeInvalidMessage("ledBarTestRequested", "boolean");
|
failedMessage = jsonTypeInvalidMessage("ledBarTestRequested", "boolean");
|
||||||
@ -343,9 +355,11 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ledBarMode != config.useRGBLedBar) {
|
if (ledBarMode != config.useRGBLedBar) {
|
||||||
|
configLogInfo("useRGBLedBar",
|
||||||
|
String(LED_BAR_MODE_NAMES[config.useRGBLedBar]),
|
||||||
|
String(LED_BAR_MODE_NAMES[ledBarMode]));
|
||||||
config.useRGBLedBar = ledBarMode;
|
config.useRGBLedBar = ledBarMode;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("Set ledBarMode: " + mode);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["ledBarMode"], "string")) {
|
if (jsonTypeInvalid(root["ledBarMode"], "string")) {
|
||||||
@ -358,9 +372,9 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (JSON.typeof_(root["displayMode"]) == "string") {
|
if (JSON.typeof_(root["displayMode"]) == "string") {
|
||||||
String mode = root["displayMode"];
|
String mode = root["displayMode"];
|
||||||
bool displayMode = false;
|
bool displayMode = false;
|
||||||
if (mode == "on") {
|
if (mode == getDisplayModeString(true)) {
|
||||||
displayMode = true;
|
displayMode = true;
|
||||||
} else if (mode == "off") {
|
} else if (mode == getDisplayModeString(false)) {
|
||||||
displayMode = false;
|
displayMode = false;
|
||||||
} else {
|
} else {
|
||||||
failedMessage = jsonTypeInvalidMessage("displayMode", mode);
|
failedMessage = jsonTypeInvalidMessage("displayMode", mode);
|
||||||
@ -370,8 +384,8 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
|
|
||||||
if (displayMode != config.displayMode) {
|
if (displayMode != config.displayMode) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
configLogInfo("displayMode", getDisplayModeString(config.displayMode), mode);
|
||||||
config.displayMode = displayMode;
|
config.displayMode = displayMode;
|
||||||
logInfo("Set displayMode: " + mode);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["displayMode"], "string")) {
|
if (jsonTypeInvalid(root["displayMode"], "string")) {
|
||||||
@ -387,9 +401,11 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
abcDays = 0;
|
abcDays = 0;
|
||||||
}
|
}
|
||||||
if (abcDays != config.abcDays) {
|
if (abcDays != config.abcDays) {
|
||||||
|
logInfo("Set abcDays: " + String(abcDays));
|
||||||
|
configLogInfo("abcDays", getAbcDayString(config.abcDays),
|
||||||
|
String(getAbcDayString(abcDays)));
|
||||||
config.abcDays = abcDays;
|
config.abcDays = abcDays;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("Set abcDays: " + String(abcDays));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["abcDays"], "number")) {
|
if (jsonTypeInvalid(root["abcDays"], "number")) {
|
||||||
@ -399,13 +415,15 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tvocLearningOffsetChanged = false;
|
||||||
if (JSON.typeof_(root["tvocLearningOffset"]) == "number") {
|
if (JSON.typeof_(root["tvocLearningOffset"]) == "number") {
|
||||||
int tvocLearningOffset = root["tvocLearningOffset"];
|
int tvocLearningOffset = root["tvocLearningOffset"];
|
||||||
if (tvocLearningOffset != config.tvocLearningOffset) {
|
if (tvocLearningOffset != config.tvocLearningOffset) {
|
||||||
changed = true;
|
changed = true;
|
||||||
_tvocLearningOffsetChanged = true;
|
_tvocLearningOffsetChanged = true;
|
||||||
|
configLogInfo("tvocLearningOffset", String(config.tvocLearningOffset),
|
||||||
|
String(tvocLearningOffset));
|
||||||
config.tvocLearningOffset = tvocLearningOffset;
|
config.tvocLearningOffset = tvocLearningOffset;
|
||||||
logInfo("Set tvocLearningOffset: " + String(tvocLearningOffset));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["tvocLearningOffset"], "number")) {
|
if (jsonTypeInvalid(root["tvocLearningOffset"], "number")) {
|
||||||
@ -415,13 +433,15 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_noxLearnOffsetChanged = false;
|
||||||
if (JSON.typeof_(root["noxLearningOffset"]) == "number") {
|
if (JSON.typeof_(root["noxLearningOffset"]) == "number") {
|
||||||
int noxLearningOffset = root["noxLearningOffset"];
|
int noxLearningOffset = root["noxLearningOffset"];
|
||||||
if (noxLearningOffset != config.noxLearningOffset) {
|
if (noxLearningOffset != config.noxLearningOffset) {
|
||||||
changed = true;
|
changed = true;
|
||||||
_noxLearnOffsetChanged = true;
|
_noxLearnOffsetChanged = true;
|
||||||
|
configLogInfo("noxLearningOffset", String(config.noxLearningOffset),
|
||||||
|
String(noxLearningOffset));
|
||||||
config.noxLearningOffset = noxLearningOffset;
|
config.noxLearningOffset = noxLearningOffset;
|
||||||
logInfo("Set noxLearningOffset: " + String(noxLearningOffset));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["noxLearningOffset"], "number")) {
|
if (jsonTypeInvalid(root["noxLearningOffset"], "number")) {
|
||||||
@ -436,8 +456,8 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (broker.length() < sizeof(config.mqttBroker)) {
|
if (broker.length() < sizeof(config.mqttBroker)) {
|
||||||
if (broker != String(config.mqttBroker)) {
|
if (broker != String(config.mqttBroker)) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
configLogInfo("mqttBrokerUrl", String(config.mqttBroker), broker);
|
||||||
snprintf(config.mqttBroker, sizeof(config.mqttBroker), broker.c_str());
|
snprintf(config.mqttBroker, sizeof(config.mqttBroker), broker.c_str());
|
||||||
logInfo("Set mqttBrokerUrl: " + broker);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
failedMessage =
|
failedMessage =
|
||||||
@ -456,9 +476,9 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (JSON.typeof_(root["temperatureUnit"]) == "string") {
|
if (JSON.typeof_(root["temperatureUnit"]) == "string") {
|
||||||
String unit = root["temperatureUnit"];
|
String unit = root["temperatureUnit"];
|
||||||
unit.toLowerCase();
|
unit.toLowerCase();
|
||||||
if (unit == "c") {
|
if ((unit == "c") || (unit == "celsius")) {
|
||||||
temperatureUnit = 'c';
|
temperatureUnit = 'c';
|
||||||
} else if (unit == "f") {
|
} else if ((unit == "f") || (unit == "fahrenheit")) {
|
||||||
temperatureUnit = 'f';
|
temperatureUnit = 'f';
|
||||||
} else {
|
} else {
|
||||||
failedMessage = "'temperatureUnit' value '" + unit + "' invalid";
|
failedMessage = "'temperatureUnit' value '" + unit + "' invalid";
|
||||||
@ -475,8 +495,9 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
|
|
||||||
if (temperatureUnit != 0 && temperatureUnit != config.temperatureUnit) {
|
if (temperatureUnit != 0 && temperatureUnit != config.temperatureUnit) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
configLogInfo("temperatureUnit", String(config.temperatureUnit),
|
||||||
|
String(temperatureUnit));
|
||||||
config.temperatureUnit = temperatureUnit;
|
config.temperatureUnit = temperatureUnit;
|
||||||
logInfo("set temperatureUnit: " + String(temperatureUnit));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
@ -484,8 +505,10 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
bool post = root["postDataToAirGradient"];
|
bool post = root["postDataToAirGradient"];
|
||||||
if (post != config.postDataToAirGradient) {
|
if (post != config.postDataToAirGradient) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
configLogInfo("postDataToAirGradient",
|
||||||
|
String(config.postDataToAirGradient ? "true" : "false"),
|
||||||
|
String(post ? "true" : "false"));
|
||||||
config.postDataToAirGradient = post;
|
config.postDataToAirGradient = post;
|
||||||
logInfo("Set postDataToAirGradient: " + String(post));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (jsonTypeInvalid(root["postDataToAirGradient"], "boolean")) {
|
if (jsonTypeInvalid(root["postDataToAirGradient"], "boolean")) {
|
||||||
@ -504,6 +527,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (model.length() < sizeof(config.model)) {
|
if (model.length() < sizeof(config.model)) {
|
||||||
if (model != String(config.model)) {
|
if (model != String(config.model)) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
configLogInfo("model", String(config.model), model);
|
||||||
snprintf(config.model, sizeof(config.model), model.c_str());
|
snprintf(config.model, sizeof(config.model), model.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -524,12 +548,13 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
if (changed) {
|
if (changed) {
|
||||||
udpated = true;
|
udpated = true;
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
printConfig();
|
||||||
} else {
|
} else {
|
||||||
|
logInfo("Nothing changed ignore udpate");
|
||||||
if (ledBarTestRequested || co2CalibrationRequested) {
|
if (ledBarTestRequested || co2CalibrationRequested) {
|
||||||
udpated = true;
|
udpated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printConfig();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,11 +570,7 @@ String Configuration::toString(void) {
|
|||||||
root["country"] = String(config.country);
|
root["country"] = String(config.country);
|
||||||
|
|
||||||
/** "pmStandard" */
|
/** "pmStandard" */
|
||||||
if (config.inUSAQI) {
|
root["pmStandard"] = getPMStandardString(config.inUSAQI);
|
||||||
root["pmStandard"] = "us-aqi";
|
|
||||||
} else {
|
|
||||||
root["pmStandard"] = "ugm3";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** co2CalibrationRequested */
|
/** co2CalibrationRequested */
|
||||||
/** ledBarTestRequested */
|
/** ledBarTestRequested */
|
||||||
@ -736,6 +757,33 @@ void Configuration::jsonInvalid(void) {
|
|||||||
logError(failedMessage);
|
logError(failedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Configuration::configLogInfo(String name, String fromValue,
|
||||||
|
String toValue) {
|
||||||
|
logInfo(String("Setting '") + name + String("' from '") + fromValue +
|
||||||
|
String("' to '") + toValue + String("'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
String Configuration::getPMStandardString(bool usaqi) {
|
||||||
|
if (usaqi) {
|
||||||
|
return "us-aqi";
|
||||||
|
}
|
||||||
|
return "ugm3";
|
||||||
|
}
|
||||||
|
|
||||||
|
String Configuration::getDisplayModeString(bool dispMode) {
|
||||||
|
if(dispMode){
|
||||||
|
return String("on");
|
||||||
|
}
|
||||||
|
return String("off");
|
||||||
|
}
|
||||||
|
|
||||||
|
String Configuration::getAbcDayString(int value) {
|
||||||
|
if(value <= 0){
|
||||||
|
return String("off");
|
||||||
|
}
|
||||||
|
return String(value);
|
||||||
|
}
|
||||||
|
|
||||||
String Configuration::getFailedMesage(void) { return failedMessage; }
|
String Configuration::getFailedMesage(void) { return failedMessage; }
|
||||||
|
|
||||||
void Configuration::setPostToAirGradient(bool enable) {
|
void Configuration::setPostToAirGradient(bool enable) {
|
||||||
|
@ -44,6 +44,10 @@ private:
|
|||||||
String jsonTypeInvalidMessage(String name, String type);
|
String jsonTypeInvalidMessage(String name, String type);
|
||||||
String jsonValueInvalidMessage(String name, String value);
|
String jsonValueInvalidMessage(String name, String value);
|
||||||
void jsonInvalid(void);
|
void jsonInvalid(void);
|
||||||
|
void configLogInfo(String name, String fromValue, String toValue);
|
||||||
|
String getPMStandardString(bool usaqi);
|
||||||
|
String getDisplayModeString(bool dispMode);
|
||||||
|
String getAbcDayString(int value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Configuration(Stream &debugLog);
|
Configuration(Stream &debugLog);
|
||||||
|
@ -278,20 +278,22 @@ void StateMachine::co2Calibration(void) {
|
|||||||
|
|
||||||
if (config.getCO2CalibrationAbcDays() >= 0 && config.hasSensorS8) {
|
if (config.getCO2CalibrationAbcDays() >= 0 && config.hasSensorS8) {
|
||||||
int newHour = config.getCO2CalibrationAbcDays() * 24;
|
int newHour = config.getCO2CalibrationAbcDays() * 24;
|
||||||
logInfo("Requested abcDays setting: " +
|
|
||||||
String(config.getCO2CalibrationAbcDays()) + "days (" +
|
|
||||||
String(newHour) + "hours)");
|
|
||||||
int curHour = ag->s8.getAbcPeriod();
|
int curHour = ag->s8.getAbcPeriod();
|
||||||
logInfo("Current S8 abcDays setting: " + String(curHour) + "(hours)");
|
if (curHour != newHour) {
|
||||||
if (curHour == newHour) {
|
String resultStr = "failure";
|
||||||
logInfo("'abcDays' unchanged");
|
if (ag->s8.setAbcPeriod(config.getCO2CalibrationAbcDays() * 24)) {
|
||||||
} else {
|
resultStr = "successful";
|
||||||
if (ag->s8.setAbcPeriod(config.getCO2CalibrationAbcDays() * 24) ==
|
|
||||||
false) {
|
|
||||||
logError("Set S8 abcDays period failed");
|
|
||||||
} else {
|
|
||||||
logInfo("Set S8 abcDays period success");
|
|
||||||
}
|
}
|
||||||
|
String fromStr = String(curHour/24) + " days";
|
||||||
|
if(curHour == 0){
|
||||||
|
fromStr = "off";
|
||||||
|
}
|
||||||
|
String toStr = String(config.getCO2CalibrationAbcDays()) + " days";
|
||||||
|
if(config.getCO2CalibrationAbcDays() == 0) {
|
||||||
|
toStr = "off";
|
||||||
|
}
|
||||||
|
String msg = "Setting S8 from " + fromStr + " to " + toStr + " " + resultStr;
|
||||||
|
logInfo(msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logWarning("CO2 S8 not available, set 'abcDays' ignored");
|
logWarning("CO2 S8 not available, set 'abcDays' ignored");
|
||||||
|
Reference in New Issue
Block a user