1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 10:05:49 +01:00

Huawei: Add UV index support

Also adds "0.0 to 15.0" comment to the weatherSpec uvIndex.
This commit is contained in:
Martin.JM 2024-07-29 21:55:51 +02:00
parent 2e091492f5
commit fbe727644e
5 changed files with 15 additions and 4 deletions

View File

@ -423,6 +423,10 @@ public class HuaweiCoordinator {
return supportsCommandForService(0x0f, 0x0b);
}
public boolean supportsWeatherUvIndex() {
return supportsExpandCapability(0x2f);
}
public boolean supportsWorkouts() {
return supportsCommandForService(0x17, 0x01);
}

View File

@ -45,6 +45,9 @@ public class Weather {
// WeatherSunMoonSupport
public boolean sunRiseSetSupported = false;
public boolean moonPhaseSupported = false;
// ExpandCapabilityRequest
public boolean uvIndexSupported = false;
}
public enum WeatherIcon {
@ -358,6 +361,7 @@ public class Weather {
HuaweiTemperatureFormat temperatureUnit,
Short airQualityIndex,
Integer observationTime,
Float uvIndex,
String sourceName
) {
super(paramsProvider);
@ -411,7 +415,8 @@ public class Weather {
this.tlv.put(0x0c, observationTime);
if (sourceName != null && settings.sourceSupported)
this.tlv.put(0x0e, sourceName);
this.tlv.put(0x0f, (byte) 0);
if (uvIndex != null && settings.uvIndexSupported)
this.tlv.put(0x0f, uvIndex.byteValue());
this.isEncrypted = true;
this.complete = true;

View File

@ -54,7 +54,7 @@ public class WeatherSpec implements Parcelable, Serializable {
public int todayMinTemp; // kelvin
public float windSpeed; // km per hour
public int windDirection; // deg
public float uvIndex;
public float uvIndex; // 0.0 to 15.0
public int precipProbability; // %
public int dewPoint; // kelvin
public float pressure; // mb
@ -357,7 +357,7 @@ public class WeatherSpec implements Parcelable, Serializable {
public int humidity;
public float windSpeed; // km per hour
public int windDirection; // deg
public float uvIndex;
public float uvIndex; // 0.0 to 15.0
public int precipProbability; // %
public int sunRise;
public int sunSet;
@ -438,7 +438,7 @@ public class WeatherSpec implements Parcelable, Serializable {
public int humidity;
public float windSpeed; // km per hour
public int windDirection; // deg
public float uvIndex;
public float uvIndex; // 0.0 to 15.0
public int precipProbability; // %
public Hourly() {

View File

@ -1877,6 +1877,7 @@ public class HuaweiSupportProvider {
WeatherSpec weatherSpec = weatherSpecs.get(0);
Weather.Settings weatherSettings = new Weather.Settings();
weatherSettings.uvIndexSupported = getHuaweiCoordinator().supportsWeatherUvIndex();
SendWeatherStartRequest weatherStartRequest = new SendWeatherStartRequest(this, weatherSettings);
try {

View File

@ -66,6 +66,7 @@ public class SendWeatherCurrentRequest extends Request {
temperatureFormat,
aqi,
weatherSpec.timestamp,
weatherSpec.uvIndex,
"Gadgetbridge"
).serialize();
} catch (HuaweiPacket.CryptoException e) {