From a140b3ade609f26f5498f10ab5585320cf674318 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 13 Nov 2022 14:35:34 +0100 Subject: [PATCH] Do not send BMP280 data if invalid --- src/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 8283aa4..8211bc6 100644 --- a/src/main.c +++ b/src/main.c @@ -176,18 +176,18 @@ static void report_status(struct MeasurementResult *meas_data) rs485_enqueue(":"); rs485_enqueue(charge_control_is_discharge_blocked() ? "1" : "0"); - rs485_enqueue(":"); - if(bmp280_state != BMP280_NOT_PRESENT) { + if(bmp280_state != BMP280_NOT_PRESENT + && bmp280_are_measurements_valid()) { + rs485_enqueue(":"); fxp_format(bmp280_get_temperature(), number, 2); rs485_enqueue(number); rs485_enqueue(":"); fxp_format(bmp280_get_pressure(), number, 2); rs485_enqueue(number); - } else { - rs485_enqueue("-1:-1"); } + rs485_enqueue("\n"); } @@ -226,17 +226,17 @@ static void report_averaged(struct MeasurementResult *meas_data) rs485_enqueue(":"); rs485_enqueue(charge_control_is_discharge_blocked() ? "1" : "0"); - rs485_enqueue(":"); - if(bmp280_state != BMP280_NOT_PRESENT) { + if(bmp280_state != BMP280_NOT_PRESENT + && bmp280_are_measurements_valid()) { + rs485_enqueue(":"); + fxp_format(bmp280_get_temperature(), number, 2); rs485_enqueue(number); rs485_enqueue(":"); fxp_format(bmp280_get_pressure(), number, 2); rs485_enqueue(number); - } else { - rs485_enqueue("-1:-1"); } rs485_enqueue("\n");