Fix force publication debug output

This commit is contained in:
bzi 2019-03-08 20:23:34 +01:00
parent ac81705a29
commit c96ab157c1

View File

@ -129,17 +129,19 @@ void publish (Sensor &sensor){
} }
// force an update if the number of samples without update is exceeded // force an update if the number of samples without update is exceeded
Serial.println(" * Forcing publication if sensor value is plausible");
force = sensor.lastUpdate >= FORCE_PERIOD; force = sensor.lastUpdate >= FORCE_PERIOD;
if (force) {
Serial.println(" * Forcing publication if sensor value is plausible");
}
// update the sample counter, will be reset if sample is published // update the sample counter, will be reset if sample is published
sensor.lastUpdate += 1; sensor.lastUpdate += 1;
// check if there was sufficient variation on the signal and if the value is plausible // check if there was sufficient variation on the signal and if the value is plausible
if (checkVariation(sensor.value, sensor.lastValue, sensor.diff) or force) { if (checkVariation(sensor.value, sensor.lastValue, sensor.diff) or force) {
Serial.println(" Sufficient variation on " + sensor.desc + ": " + String(sensor.value).c_str()); Serial.println(" Sufficient variation on " + sensor.desc + ": " + String(sensor.value).c_str());
if (checkPlausibility(sensor.value, sensor.lastValue, sensor.diff)) { if (checkPlausibility(sensor.value, sensor.lastValue, sensor.diff)) {
Serial.println(" Value published"); Serial.println(" Value published");
client.publish(sensor.topic, String(sensor.value).c_str(), true); client.publish(sensor.topic, String(sensor.value).c_str(), true);
sensor.lastUpdate = 0; sensor.lastUpdate = 0;
} else { } else {