Garmin: Improve computed timestamp parsing

timestamp16 must be applied against garmin epoch.
This commit is contained in:
José Rebelo
2024-05-24 22:24:08 +02:00
committed by Daniele Gobbetti
parent bdd698b7d3
commit 89046d0815
3 changed files with 17 additions and 3 deletions
@@ -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) {
@@ -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;
}
@@ -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();
}
}