mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-07-17 19:04:03 +02:00
Fix timestamps of activities, cause the watch reports them with 6 hours offset.
This commit is contained in:
parent
e54930788b
commit
18202bffbd
|
@ -53,6 +53,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||
private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo();
|
||||
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
||||
private final GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
|
||||
private final int sixHourOffset = 21600;
|
||||
private byte[] lastMsg;
|
||||
private byte msgPart;
|
||||
private int availableSleepData;
|
||||
|
@ -879,7 +880,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||
private void handleStepsData(byte[] msg)
|
||||
{
|
||||
ZeTimeActivitySample sample = new ZeTimeActivitySample();
|
||||
sample.setTimestamp((msg[10] << 24)&0xff000000 | (msg[9] << 16)&0xff0000 | (msg[8] << 8)&0xff00 | (msg[7]&0xff));
|
||||
int timestamp = (msg[10] << 24)&0xff000000 | (msg[9] << 16)&0xff0000 | (msg[8] << 8)&0xff00 | (msg[7]&0xff);
|
||||
timestamp += sixHourOffset; // the timestamp from the watch has an offset of six hours, do not know why...
|
||||
sample.setTimestamp(timestamp);
|
||||
sample.setSteps((msg[14] << 24)&0xff000000 | (msg[13] << 16)&0xff0000 | (msg[12] << 8)&0xff00 | (msg[11]&0xff));
|
||||
sample.setCaloriesBurnt((msg[18] << 24)&0xff000000 | (msg[17] << 16)&0xff0000 | (msg[16] << 8)&0xff00 | (msg[15]&0xff));
|
||||
sample.setDistanceMeters((msg[22] << 24)&0xff000000 | (msg[21] << 16)&0xff0000 | (msg[20] << 8)&0xff00 | (msg[19]&0xff));
|
||||
|
@ -919,7 +922,9 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||
private void handleSleepData(byte[] msg)
|
||||
{
|
||||
ZeTimeActivitySample sample = new ZeTimeActivitySample();
|
||||
sample.setTimestamp((msg[10] << 24)&0xff000000 | (msg[9] << 16)&0xff0000 | (msg[8] << 8)&0xff00 | (msg[7]&0xff));
|
||||
int timestamp = (msg[10] << 24)&0xff000000 | (msg[9] << 16)&0xff0000 | (msg[8] << 8)&0xff00 | (msg[7]&0xff);
|
||||
timestamp += sixHourOffset; // the timestamp from the watch has an offset of six hours, do not know why...
|
||||
sample.setTimestamp(timestamp);
|
||||
if(msg[11] == 0) {
|
||||
sample.setRawKind(ActivityKind.TYPE_DEEP_SLEEP);
|
||||
} else if(msg[11] == 1)
|
||||
|
@ -956,8 +961,10 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||
private void handleHeartRateData(byte[] msg)
|
||||
{
|
||||
ZeTimeActivitySample sample = new ZeTimeActivitySample();
|
||||
int timestamp = (msg[10] << 24)&0xff000000 | (msg[9] << 16)&0xff0000 | (msg[8] << 8)&0xff00 | (msg[7]&0xff);
|
||||
timestamp += sixHourOffset; // the timestamp from the watch has an offset of six hours, do not know why...
|
||||
sample.setHeartRate(msg[11]);
|
||||
sample.setTimestamp((msg[10] << 24)&0xff000000 | (msg[9] << 16)&0xff0000 | (msg[8] << 8)&0xff00 | (msg[7]&0xff));
|
||||
sample.setTimestamp(timestamp);
|
||||
|
||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||
sample.setUserId(DBHelper.getUser(dbHandler.getDaoSession()).getId());
|
||||
|
|
Loading…
Reference in New Issue
Block a user