1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-27 17:14:55 +02:00

CMF Watch Pro: Fix weather when aqi is not available

This commit is contained in:
José Rebelo 2024-07-20 20:21:21 +01:00
parent d2c6712a87
commit 9b168f2ab3

View File

@ -602,7 +602,7 @@ public class CmfWatchProSupport extends AbstractBTLEDeviceSupport implements Cmf
buf.put((byte) (weatherSpec.todayMaxTemp - 273 + 100)); // convert Kelvin to C, add 100
buf.put((byte) (weatherSpec.todayMinTemp - 273 + 100)); // convert Kelvin to C, add 100
buf.put((byte) weatherSpec.currentHumidity);
buf.putShort((short) weatherSpec.airQuality.aqi);
buf.putShort((short) (weatherSpec.airQuality != null ? weatherSpec.airQuality.aqi : 0));
buf.put((byte) weatherSpec.uvIndex); // UV index isn't shown. uvi decimal/100, so 0x07 = 700 UVI.
buf.put((byte) weatherSpec.windSpeed); // isn't shown by watch, unsure of correct units
@ -617,11 +617,7 @@ public class CmfWatchProSupport extends AbstractBTLEDeviceSupport implements Cmf
buf.put((byte) (forecastDay.maxTemp - 273 + 100)); // max temp in C, + 100
buf.put((byte) (forecastDay.minTemp - 273 + 100)); // min temp in C, + 100
buf.put((byte) forecastDay.humidity); // humidity as a %
try { // AQI data might not be available for the full 7 day forecast.
buf.putShort((short) weatherSpec.airQuality.aqi);
} catch (java.lang.NullPointerException ex) {
buf.putShort((short) 0);
}
buf.putShort((short) (forecastDay.airQuality != null ? forecastDay.airQuality.aqi : 0));
buf.put((byte) forecastDay.uvIndex); // UV index isn't shown. uvi decimal/100, so 0x07 = 700 UVI.
buf.put((byte) forecastDay.windSpeed); // isn't shown by watch, unsure of correct units
} else {