Do not send BMP280 data if invalid

This commit is contained in:
Thomas Kolb 2022-11-13 14:35:34 +01:00
parent 5090b7de4a
commit a140b3ade6

View file

@ -176,18 +176,18 @@ static void report_status(struct MeasurementResult *meas_data)
rs485_enqueue(":"); rs485_enqueue(":");
rs485_enqueue(charge_control_is_discharge_blocked() ? "1" : "0"); 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); fxp_format(bmp280_get_temperature(), number, 2);
rs485_enqueue(number); rs485_enqueue(number);
rs485_enqueue(":"); rs485_enqueue(":");
fxp_format(bmp280_get_pressure(), number, 2); fxp_format(bmp280_get_pressure(), number, 2);
rs485_enqueue(number); rs485_enqueue(number);
} else {
rs485_enqueue("-1:-1");
} }
rs485_enqueue("\n"); rs485_enqueue("\n");
} }
@ -226,17 +226,17 @@ static void report_averaged(struct MeasurementResult *meas_data)
rs485_enqueue(":"); rs485_enqueue(":");
rs485_enqueue(charge_control_is_discharge_blocked() ? "1" : "0"); rs485_enqueue(charge_control_is_discharge_blocked() ? "1" : "0");
if(bmp280_state != BMP280_NOT_PRESENT
&& bmp280_are_measurements_valid()) {
rs485_enqueue(":"); rs485_enqueue(":");
if(bmp280_state != BMP280_NOT_PRESENT) {
fxp_format(bmp280_get_temperature(), number, 2); fxp_format(bmp280_get_temperature(), number, 2);
rs485_enqueue(number); rs485_enqueue(number);
rs485_enqueue(":"); rs485_enqueue(":");
fxp_format(bmp280_get_pressure(), number, 2); fxp_format(bmp280_get_pressure(), number, 2);
rs485_enqueue(number); rs485_enqueue(number);
} else {
rs485_enqueue("-1:-1");
} }
rs485_enqueue("\n"); rs485_enqueue("\n");