Fix issue in plausibility check

This commit is contained in:
bzi 2019-03-01 09:17:30 +01:00
parent 43d4b7d82d
commit 3cc9c62696
2 changed files with 8 additions and 8 deletions

View File

@ -114,21 +114,21 @@ bool published = false;
bool forcePublish = false;
bool publish (String desc, char *topic, float val, float &lastVal, float diff, bool force){
bool retval = false;
bool ret = false;
Serial.println("Sample " + desc + ": " + String(val).c_str());
if (checkVariation(val, lastVal, diff) or force) {
lastVal = val;
Serial.println("Sufficient variation on " + desc + ": " + String(val).c_str());
if (checkPlausibility(val, lastVal, diff) or force) {
Serial.println("Value published");
client.publish(topic, String(val).c_str(), true);
retval = true;
ret = true;
} else {
Serial.print("** ERROR: Value out of bounds, not published. Last value :");
Serial.println(String(lastVal).c_str());
}
lastVal = val;
}
return retval;
return ret;
}
void loop() {

View File

@ -111,21 +111,21 @@ bool published = false;
bool forcePublish = false;
bool publish (String desc, char *topic, float val, float &lastVal, float diff, bool force){
bool retval = false;
bool ret = false;
Serial.println("Sample " + desc + ": " + String(val).c_str());
if (checkVariation(val, lastVal, diff) or force) {
lastVal = val;
Serial.println("Sufficient variation on " + desc + ": " + String(val).c_str());
if (checkPlausibility(val, lastVal, diff) or force) {
Serial.println("Value published");
client.publish(topic, String(val).c_str(), true);
retval = true;
ret = true;
} else {
Serial.print("** ERROR: Value out of bounds, not published. Last value :");
Serial.println(String(lastVal).c_str());
}
lastVal = val;
}
return retval;
return ret;
}
void loop() {