mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Garmin: use COORDINATE base field for Weather coordinate fields (untested)
Use the standard field encoding for coordinates. Untested as my watch does not show the contents of the coordinate fields, but verified that they used to be invalid in the test cases and are now properly populated. Also update test cases to match.
This commit is contained in:
+2
-2
@@ -715,8 +715,8 @@ public class GarminSupport extends AbstractBTLESingleDeviceSupport implements IC
|
||||
today.setWindSpeed(weather.getWindSpeed());
|
||||
today.setTemperatureFeelsLike(weather.getFeelsLikeTemp());
|
||||
today.setRelativeHumidity(weather.getCurrentHumidity());
|
||||
today.setObservedLocationLat((long) weather.getLatitude());
|
||||
today.setObservedLocationLong((long) weather.getLongitude());
|
||||
today.setObservedLocationLat((double) weather.getLatitude());
|
||||
today.setObservedLocationLong((double) weather.getLongitude());
|
||||
today.setAirQuality(null); //ensure the definition is added
|
||||
if (null != weather.getAirQuality()) {
|
||||
today.setAirQuality(FieldDefinitionWeatherAqi.aqiAbsoluteValueToEnum(weather.getAirQuality().getAqi()));
|
||||
|
||||
+2
-2
@@ -1010,8 +1010,8 @@ public class NativeFITMessage {
|
||||
new FieldDefinitionPrimitive(7, BaseType.UINT8, "relative_humidity"),
|
||||
new FieldDefinitionPrimitive(8, BaseType.STRING, 15, "location"),
|
||||
new FieldDefinitionPrimitive(9, BaseType.UINT32, "observed_at_time", FieldDefinitionFactory.FIELD.TIMESTAMP),
|
||||
new FieldDefinitionPrimitive(10, BaseType.SINT32, "observed_location_lat"),
|
||||
new FieldDefinitionPrimitive(11, BaseType.SINT32, "observed_location_long"),
|
||||
new FieldDefinitionPrimitive(10, BaseType.SINT32, "observed_location_lat", FieldDefinitionFactory.FIELD.COORDINATE),
|
||||
new FieldDefinitionPrimitive(11, BaseType.SINT32, "observed_location_long", FieldDefinitionFactory.FIELD.COORDINATE),
|
||||
new FieldDefinitionPrimitive(12, BaseType.ENUM, "day_of_week", FieldDefinitionFactory.FIELD.DAY_OF_WEEK),
|
||||
new FieldDefinitionPrimitive(13, BaseType.SINT8, "high_temperature", FieldDefinitionFactory.FIELD.TEMPERATURE),
|
||||
new FieldDefinitionPrimitive(14, BaseType.SINT8, "low_temperature", FieldDefinitionFactory.FIELD.TEMPERATURE),
|
||||
|
||||
+6
-6
@@ -95,13 +95,13 @@ public class FitWeather extends RecordData {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getObservedLocationLat() {
|
||||
return getFieldByNumber(10, Long.class);
|
||||
public Double getObservedLocationLat() {
|
||||
return getFieldByNumber(10, Double.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getObservedLocationLong() {
|
||||
return getFieldByNumber(11, Long.class);
|
||||
public Double getObservedLocationLong() {
|
||||
return getFieldByNumber(11, Double.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -197,12 +197,12 @@ public class FitWeather extends RecordData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setObservedLocationLat(final Long value) {
|
||||
public Builder setObservedLocationLat(final Double value) {
|
||||
setFieldByNumber(10, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setObservedLocationLong(final Long value) {
|
||||
public Builder setObservedLocationLong(final Double value) {
|
||||
setFieldByNumber(11, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
+4
-5
@@ -19,8 +19,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.Mess
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class FitWeatherTest {
|
||||
//TODO: maybe the annotation is not needed anymore?
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
|
||||
@Test
|
||||
public void testEncode() {
|
||||
final WeatherSpec weather = getWeatherSpec();
|
||||
@@ -302,7 +301,7 @@ public class FitWeatherTest {
|
||||
assertEquals("41000100800C000100FD04860101010201000302840402840501020601010701020F0101100488110100", weatherDefinitions.get(1));
|
||||
assertEquals("420001008008000100FD04860E01010D01010201000501020C0100110100", weatherDefinitions.get(2));
|
||||
Assert.assertEquals(18, weatherData.size());
|
||||
assertEquals("0000438CC424438CC4240F0A1904000C630BA40D1E00000026FFFFFF86020A477265656E2048696C6C0000000000", weatherData.get(0));
|
||||
assertEquals("0000438CC424438CC4240F0A1904000C630BA40D1E1B33399AA8F3CB06020A477265656E2048696C6C0000000000", weatherData.get(0));
|
||||
assertEquals("0101FFFFFFFF0A00001E1748320A0A7F40000000FF", weatherData.get(1));
|
||||
assertEquals("0101FFFFFFFF0B00001F1872330B0B7F40400000FF", weatherData.get(2));
|
||||
assertEquals("0101FFFFFFFF0C000020199C340C0C7F40800000FF", weatherData.get(3));
|
||||
@@ -376,8 +375,8 @@ public class FitWeatherTest {
|
||||
today.setFieldByName("wind_speed", Math.round(weather.getWindSpeed()));
|
||||
today.setFieldByName("temperature_feels_like", weather.getFeelsLikeTemp());
|
||||
today.setFieldByName("relative_humidity", weather.getCurrentHumidity());
|
||||
today.setFieldByName("observed_location_lat", weather.getLatitude());
|
||||
today.setFieldByName("observed_location_long", weather.getLongitude());
|
||||
today.setFieldByName("observed_location_lat", (double) weather.getLatitude());
|
||||
today.setFieldByName("observed_location_long", (double) weather.getLongitude());
|
||||
if (null != weather.getAirQuality()) {
|
||||
today.setFieldByName("air_quality", weather.getAirQuality().getAqi());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user