diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusHealthSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusHealthSampleProvider.java index a348f0ea..4a605809 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusHealthSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusHealthSampleProvider.java @@ -167,6 +167,8 @@ public class HPlusHealthSampleProvider extends AbstractSampleProvider= overlay.getTimestampFrom() && sample.getTimestamp() < overlay.getTimestampTo()) { if (overlay.getRawKind() == ActivityKind.TYPE_NOT_WORN || overlay.getRawKind() == ActivityKind.TYPE_LIGHT_SLEEP || overlay.getRawKind() == ActivityKind.TYPE_DEEP_SLEEP) { 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 58902f46..4f8e4f9b 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 @@ -24,6 +24,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.hplus; import java.util.GregorianCalendar; import java.util.Locale; +import nodomain.freeyourgadget.gadgetbridge.model.ActivityAmount; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; @@ -80,19 +81,24 @@ class HPlusDataRecordRealtime extends HPlusDataRecord { int y = (data[8] & 0xFF) * 256 + (data[7] & 0xFF); battery = data[9]; - calories = x + y; // KCal - - heartRate = data[11] & 0xFF; // BPM activeTime = (data[14] & 0xFF * 256) + (data[13] & 0xFF); - if(heartRate == 255) { - intensity = 0; - activityKind = ActivityKind.TYPE_NOT_MEASURED; + + if (battery == 255) { + battery = ActivitySample.NOT_MEASURED; heartRate = ActivitySample.NOT_MEASURED; - } - else { - intensity = (int) ((100*heartRate)/(208-0.7*age)); - activityKind = ActivityKind.TYPE_UNKNOWN; + intensity = 0; + activityKind = ActivityKind.TYPE_NOT_WORN; + } else { + heartRate = data[11] & 0xFF; // BPM + if (heartRate == 255) { + intensity = 0; + activityKind = ActivityKind.TYPE_NOT_MEASURED; + heartRate = ActivitySample.NOT_MEASURED; + } else { + intensity = (int) ((100 * heartRate) / (208 - 0.7 * age)); + activityKind = HPlusDataRecord.TYPE_REALTIME; + } } } 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 29dcf370..14a0e388 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 @@ -443,17 +443,6 @@ class HPlusHandlerThread extends GBDeviceIoThread { getDevice().setBatteryLevel(record.battery); - //Skip when measuring heart rate - //Calories and Distance are updated and these values will be lost. - //Because a message with a valid Heart Rate will be provided, this loss very limited - if (record.heartRate == ActivityKind.TYPE_NOT_MEASURED) { - getDevice().setFirmwareVersion2("---"); - getDevice().sendDeviceUpdateIntent(getContext()); - } else { - getDevice().setFirmwareVersion2("" + record.heartRate); - getDevice().sendDeviceUpdateIntent(getContext()); - } - try (DBHandler dbHandler = GBApplication.acquireDB()) { HPlusHealthSampleProvider provider = new HPlusHealthSampleProvider(getDevice(), dbHandler.getDaoSession());