Fix issue in plausibility check
This commit is contained in:
parent
43d4b7d82d
commit
3cc9c62696
@ -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() {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user