1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-09 22:57:54 +02:00

Update to new simple weather spec

This commit is contained in:
FintasticMan 2024-01-04 13:57:17 +01:00 committed by José Rebelo
parent 655d202512
commit ecd13b4d8e

View File

@ -979,8 +979,10 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
}
private void onSendWeatherSimple(WeatherSpec weatherSpec) {
long timestampLocal = weatherSpec.timestamp + Calendar.getInstance().getTimeZone().getOffset(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis()) / 1000L;
ByteBuffer currentPacket = ByteBuffer.allocate(49).order(ByteOrder.LITTLE_ENDIAN);
currentPacket.putLong(2, (long) weatherSpec.timestamp * 1000000000L); // 10^9, for nanoseconds
currentPacket.putLong(2, timestampLocal);
currentPacket.putShort(10, (short) ((weatherSpec.currentTemp - 273.15) * 100));
currentPacket.putShort(12, (short) ((weatherSpec.todayMinTemp - 273.15) * 100));
currentPacket.putShort(14, (short) ((weatherSpec.todayMaxTemp - 273.15) * 100));
@ -1005,7 +1007,7 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
ByteBuffer forecastPacket = ByteBuffer.allocate(36).order(ByteOrder.LITTLE_ENDIAN);
forecastPacket.put(0, (byte) 1);
forecastPacket.putLong(2, (long) weatherSpec.timestamp * 1000000000L); // 10^9, for nanoseconds
forecastPacket.putLong(2, timestampLocal);
byte nbDays = (byte) Math.min(weatherSpec.forecasts.size(), 5);
forecastPacket.put(10, nbDays);
for (int i = 0; i < nbDays; i++) {