1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Garmin: Improve computed timestamp parsing

timestamp16 must be applied against garmin epoch.
This commit is contained in:
José Rebelo 2024-05-01 22:17:42 +01:00 committed by Daniele Gobbetti
parent bdd698b7d3
commit 89046d0815
3 changed files with 17 additions and 3 deletions

View File

@ -165,8 +165,8 @@ public class RecordData {
tsb.append(globalFITMessage.name()); tsb.append(globalFITMessage.name());
} }
if (computedTimestamp != null) { if (getComputedTimestamp() != null) {
tsb.append(new Date(computedTimestamp * 1000L)); tsb.append(new Date(getComputedTimestamp() * 1000L));
} }
for (FieldData fieldData : fieldDataList) { for (FieldData fieldData : fieldDataList) {

View File

@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages
import androidx.annotation.Nullable; 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.RecordData;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader; import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader;
@ -77,7 +78,9 @@ public class FitMonitoring extends RecordData {
final Integer timestamp16 = getTimestamp16(); final Integer timestamp16 = getTimestamp16();
final Long computedTimestamp = super.getComputedTimestamp(); final Long computedTimestamp = super.getComputedTimestamp();
if (timestamp16 != null && computedTimestamp != null) { if (timestamp16 != null && computedTimestamp != null) {
return (computedTimestamp & ~0xFFFFL) | timestamp16; return (long) GarminTimeUtils.garminTimestampToUnixTime(
(GarminTimeUtils.unixTimeToGarminTimestamp(computedTimestamp.intValue()) & ~0xFFFF) | (timestamp16 & 0xFFFF)
);
} }
return computedTimestamp; return computedTimestamp;
} }

View File

@ -45,4 +45,15 @@ public class FitStressLevel extends RecordData {
public Long getStressLevelTime() { public Long getStressLevelTime() {
return (Long) getFieldByNumber(1); return (Long) getFieldByNumber(1);
} }
// manual changes below
@Override
public Long getComputedTimestamp() {
final Long stressTime = getStressLevelTime();
if (stressTime != null) {
return stressTime;
}
return super.getComputedTimestamp();
}
} }