Implement some debug outputs and fix issue with integer casting
This commit is contained in:
parent
7208a6d324
commit
3ab22b2e94
@ -109,18 +109,21 @@ long lastSent = 0;
|
||||
bool published = false;
|
||||
bool forcePublish = false;
|
||||
|
||||
bool publish (String desc, char *topic, float val, float &val_r, int diff, bool force){
|
||||
bool publish (String desc, char *topic, float val, float &lastVal, float diff, bool force){
|
||||
bool retval = false;
|
||||
if (checkVariation(val, val_r, diff) or force) {
|
||||
val_r = val;
|
||||
Serial.print("New " + desc + ": ");
|
||||
Serial.println(String(val).c_str());
|
||||
if (checkPlausibility(val, val_r, diff) or force) {
|
||||
if (checkVariation(val, lastVal, diff) or force) {
|
||||
lastVal = val;
|
||||
Serial.println("New " + 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;
|
||||
} else {
|
||||
Serial.println("** ERROR: Value out of bounds, not published **");
|
||||
Serial.print("** ERROR: Value out of bounds, not published. Last value :");
|
||||
Serial.println(String(lastVal).c_str());
|
||||
}
|
||||
} else {
|
||||
Serial.println("Not enough variation for a publication");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user