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 published = false;
|
||||||
bool forcePublish = 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;
|
bool retval = false;
|
||||||
if (checkVariation(val, val_r, diff) or force) {
|
if (checkVariation(val, lastVal, diff) or force) {
|
||||||
val_r = val;
|
lastVal = val;
|
||||||
Serial.print("New " + desc + ": ");
|
Serial.println("New " + desc + ": " + String(val).c_str());
|
||||||
Serial.println(String(val).c_str());
|
if (checkPlausibility(val, lastVal, diff) or force) {
|
||||||
if (checkPlausibility(val, val_r, diff) or force) {
|
Serial.println("Value published");
|
||||||
client.publish(topic, String(val).c_str(), true);
|
client.publish(topic, String(val).c_str(), true);
|
||||||
retval = true;
|
retval = true;
|
||||||
} else {
|
} 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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user