1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-01 19:06:06 +02: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
parent 11850f819f
commit c8012e18d7
3 changed files with 17 additions and 3 deletions

View File

@ -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) {

View File

@ -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;
}

View File

@ -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();
}
}