mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 10:56:50 +01:00
Zepp OS: Allow activity fetch timestamps sent in seconds
Re-applies #2959 after b51328e4f
This commit is contained in:
parent
b51328e4f2
commit
fe9648dea3
@ -72,6 +72,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||||
@ -908,6 +909,18 @@ public abstract class Huami2021Support extends HuamiSupport {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getTimeBytes(final Calendar calendar, final TimeUnit precision) {
|
||||||
|
final byte[] bytes = BLETypeConversions.shortCalendarToRawBytes(calendar);
|
||||||
|
|
||||||
|
if (precision != TimeUnit.MINUTES && precision != TimeUnit.SECONDS) {
|
||||||
|
throw new IllegalArgumentException("Unsupported precision, only MINUTES and SECONDS are supported");
|
||||||
|
}
|
||||||
|
final byte seconds = precision == TimeUnit.SECONDS ? fromUint8(calendar.get(Calendar.SECOND)) : 0;
|
||||||
|
final byte tz = BLETypeConversions.mapTimeZone(calendar, BLETypeConversions.TZ_FLAG_INCLUDE_DST_IN_TZ);
|
||||||
|
return BLETypeConversions.join(bytes, new byte[]{seconds, tz});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Huami2021Support setCurrentTimeWithService(TransactionBuilder builder) {
|
public Huami2021Support setCurrentTimeWithService(TransactionBuilder builder) {
|
||||||
// It seems that the format sent to the Current Time characteristic changed in newer devices
|
// It seems that the format sent to the Current Time characteristic changed in newer devices
|
||||||
|
Loading…
Reference in New Issue
Block a user