From c4a0c60b8cd929a0c6fae078ece68789ee3d56f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Paulo=20Barraca?= Date: Sun, 22 Jan 2017 23:33:30 +0000 Subject: [PATCH] HPlus: Fix bug related to steps and heart rate --- .../service/devices/hplus/HPlusDataRecordDaySlot.java | 2 +- .../service/devices/hplus/HPlusDataRecordRealtime.java | 2 ++ .../gadgetbridge/service/devices/hplus/HPlusHandlerThread.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java index c742e0461..997ad3f11 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordDaySlot.java @@ -46,7 +46,7 @@ public class HPlusDataRecordDaySlot extends HPlusDataRecord { slot = a; heartRate = data[1] & 0xFF; - if(heartRate == 255) + if(heartRate == 255 || heartRate == 0) heartRate = ActivityKind.TYPE_NOT_MEASURED; steps = (data[2] & 0xFF) * 256 + data[3] & 0xFF; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java index 8b39f84f7..4a618bcaa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusDataRecordRealtime.java @@ -9,6 +9,7 @@ import java.util.GregorianCalendar; import java.util.Locale; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; +import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; class HPlusDataRecordRealtime extends HPlusDataRecord { @@ -71,6 +72,7 @@ class HPlusDataRecordRealtime extends HPlusDataRecord { if(heartRate == 255) { intensity = 0; activityKind = ActivityKind.TYPE_NOT_MEASURED; + heartRate = ActivitySample.NOT_MEASURED; } else { intensity = (int) (100 * Math.max(0, Math.min((heartRate - 60) / 120.0, 1))); // TODO: Calculate a proper value diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java index 7b05775db..54cb040eb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusHandlerThread.java @@ -391,6 +391,8 @@ class HPlusHandlerThread extends GBDeviceIoThread { sample.setRawHPlusHealthData(record.getRawData()); sample.setProvider(provider); + provider.addGBActivitySample(sample); + sample.setSteps(sample.getSteps() - prevRealTimeRecord.steps); Intent intent = new Intent(DeviceService.ACTION_REALTIME_SAMPLES) @@ -398,7 +400,6 @@ class HPlusHandlerThread extends GBDeviceIoThread { .putExtra(DeviceService.EXTRA_TIMESTAMP, System.currentTimeMillis()); LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); - provider.addGBActivitySample(sample); //TODO: Handle Active Time. With Overlay? } catch (GBException ex) {