diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java index d85308099..fd758aa86 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java @@ -403,4 +403,164 @@ public class Weather { return -1; } } + + public static String getConditionString(int openWeatherMapCondition) { + switch (openWeatherMapCondition) { + case 200: + return "thunderstorm with light rain"; + case 201: + return "thunderstorm with rain"; + case 202: + return "thunderstorm with heavy rain"; + case 210: + return "light thunderstorm:"; + case 211: + return "thunderstorm"; + case 230: + return "thunderstorm with light drizzle"; + case 231: + return "thunderstorm with drizzle"; + case 232: + return "thunderstorm with heavy drizzle"; + case 212: + return "heavy thunderstorm"; + case 221: + return "ragged thunderstorm"; + //Group 3xx: Drizzle + case 300: + return "light intensity drizzle"; + case 301: + return "drizzle"; + case 302: + return "heavy intensity drizzle"; + case 310: + return "light intensity drizzle rain"; + case 311: + return "drizzle rain"; + case 312: + return "heavy intensity drizzle rain"; + case 313: + return "shower rain and drizzle"; + case 314: + return "heavy shower rain and drizzle"; + case 321: + return "shower drizzle"; + //Group 5xx: Rain + case 500: + return "light rain"; + case 501: + return "moderate rain"; + case 502: + return "heavy intensity rain"; + case 503: + return "very heavy rain"; + case 504: + return "extreme rain"; + case 511: + return "freezing rain"; + case 520: + return "light intensity shower rain"; + case 521: + return "shower rain"; + case 522: + return "heavy intensity shower rain"; + case 531: + return "ragged shower rain"; + //Group 6xx: Snow + case 600: + return "light snow"; + case 601: + return "snow"; + case 620: + return "light shower snow"; + case 602: + return "heavy snow"; + case 611: + return "sleet"; + case 612: + return "shower sleet"; + case 621: + return "shower snow"; + case 622: + return "heavy shower snow"; + case 615: + return "light rain and snow"; + case 616: + return "rain and snow"; + //Group 7xx: Atmosphere + case 701: + return "mist"; + case 711: + return "smoke"; + case 721: + return "haze"; + case 731: + return "sandcase dust whirls"; + case 741: + return "fog"; + case 751: + return "sand"; + case 761: + return "dust"; + case 762: + return "volcanic ash"; + case 771: + return "squalls"; + case 781: + return "tornado"; + case 900: + return "tornado"; + case 800: + return "clear sky"; + //Group 80x: Clouds + case 801: + return "few clouds"; + case 802: + return "scattered clouds"; + case 803: + return "broken clouds"; + case 804: + return "overcast clouds"; + //Group 90x: Extreme + case 901: + return "tropical storm"; + case 903: + return "cold"; + case 904: + return "hot"; + case 905: + return "windy"; + case 906: + return "hail"; + //Group 9xx: Additional + case 951: + return "calm"; + case 952: + return "light breeze"; + case 953: + return "gentle breeze"; + case 954: + return "moderate breeze"; + case 955: + return "fresh breeze"; + case 956: + return "strong breeze"; + case 957: + return "high windcase near gale"; + case 958: + return "gale"; + case 959: + return "severe gale"; + case 960: + return "storm"; + case 961: + return "violent storm"; + case 902: + return "hurricane"; + case 962: + return "hurricane"; + default: + return ""; + } + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java index 0fe9486e3..bbaf76791 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java @@ -40,6 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationType; +import nodomain.freeyourgadget.gadgetbridge.model.Weather; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory; @@ -139,11 +140,16 @@ public class AmazfitBipSupport extends MiBand2Support { final byte NR_DAYS = (byte) (1 + weatherSpec.forecasts.size()); int bytesPerDay = 4; + int conditionsLength = 0; if (supportsConditionString) { bytesPerDay = 5; conditionsLength = weatherSpec.currentCondition.getBytes().length; + for (WeatherSpec.Forecast forecast : weatherSpec.forecasts) { + conditionsLength += Weather.getConditionString(forecast.conditionCode).getBytes().length; + } } + int length = 7 + bytesPerDay * NR_DAYS + conditionsLength; ByteBuffer buf = ByteBuffer.allocate(length); @@ -162,7 +168,7 @@ public class AmazfitBipSupport extends MiBand2Support { buf.put((byte) (weatherSpec.todayMinTemp - 273)); if (supportsConditionString) { buf.put(weatherSpec.currentCondition.getBytes()); - buf.put((byte) 0); // + buf.put((byte) 0); } for (WeatherSpec.Forecast forecast : weatherSpec.forecasts) { @@ -173,7 +179,8 @@ public class AmazfitBipSupport extends MiBand2Support { buf.put((byte) (forecast.maxTemp - 273)); buf.put((byte) (forecast.minTemp - 273)); if (supportsConditionString) { - buf.put((byte) 0); // not yet in weatherspec + buf.put(Weather.getConditionString(forecast.conditionCode).getBytes()); + buf.put((byte) 0); } }