mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Garmin: Improve computed timestamp parsing
timestamp16 must be applied against garmin epoch.
This commit is contained in:
committed by
Daniele Gobbetti
parent
bdd698b7d3
commit
89046d0815
+2
-2
@@ -165,8 +165,8 @@ public class RecordData {
|
||||
tsb.append(globalFITMessage.name());
|
||||
}
|
||||
|
||||
if (computedTimestamp != null) {
|
||||
tsb.append(new Date(computedTimestamp * 1000L));
|
||||
if (getComputedTimestamp() != null) {
|
||||
tsb.append(new Date(getComputedTimestamp() * 1000L));
|
||||
}
|
||||
|
||||
for (FieldData fieldData : fieldDataList) {
|
||||
|
||||
+4
-1
@@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.GarminTimeUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader;
|
||||
@@ -77,7 +78,9 @@ public class FitMonitoring extends RecordData {
|
||||
final Integer timestamp16 = getTimestamp16();
|
||||
final Long computedTimestamp = super.getComputedTimestamp();
|
||||
if (timestamp16 != null && computedTimestamp != null) {
|
||||
return (computedTimestamp & ~0xFFFFL) | timestamp16;
|
||||
return (long) GarminTimeUtils.garminTimestampToUnixTime(
|
||||
(GarminTimeUtils.unixTimeToGarminTimestamp(computedTimestamp.intValue()) & ~0xFFFF) | (timestamp16 & 0xFFFF)
|
||||
);
|
||||
}
|
||||
return computedTimestamp;
|
||||
}
|
||||
|
||||
+11
@@ -45,4 +45,15 @@ public class FitStressLevel extends RecordData {
|
||||
public Long getStressLevelTime() {
|
||||
return (Long) getFieldByNumber(1);
|
||||
}
|
||||
|
||||
// manual changes below
|
||||
|
||||
@Override
|
||||
public Long getComputedTimestamp() {
|
||||
final Long stressTime = getStressLevelTime();
|
||||
if (stressTime != null) {
|
||||
return stressTime;
|
||||
}
|
||||
return super.getComputedTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user