From bcd35b02da36be4923bf3f66f9c45eb26675143f Mon Sep 17 00:00:00 2001 From: "Martin.JM" Date: Mon, 29 Apr 2024 10:58:24 +0200 Subject: [PATCH] [Huawei] Add HR and SpO support for two watches - Huawei Watch GT4 - Huawei Watch Ultimate --- .../HuaweiWatchGT4Coordinator.java | 19 +++++++++++++++++++ .../HuaweiWatchUltimateCoordinator.java | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchgt4/HuaweiWatchGT4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchgt4/HuaweiWatchGT4Coordinator.java index df11792db..846463b63 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchgt4/HuaweiWatchGT4Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchgt4/HuaweiWatchGT4Coordinator.java @@ -22,11 +22,15 @@ import org.slf4j.LoggerFactory; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiBRCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiSpo2SampleProvider; +import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample; public class HuaweiWatchGT4Coordinator extends HuaweiBRCoordinator { private static final Logger LOG = LoggerFactory.getLogger(HuaweiWatchGT4Coordinator.class); @@ -46,6 +50,21 @@ public class HuaweiWatchGT4Coordinator extends HuaweiBRCoordinator { return Pattern.compile("(" + HuaweiConstants.HU_WATCHGT4_NAME + ").*", Pattern.CASE_INSENSITIVE); } + @Override + public boolean supportsHeartRateMeasurement(GBDevice device) { + return true; + } + + @Override + public boolean supportsSpo2() { + return true; + } + + @Override + public TimeSampleProvider getSpo2SampleProvider(GBDevice device, DaoSession session) { + return new HuaweiSpo2SampleProvider(device, session); + } + @Override public int getDeviceNameResource() { return R.string.devicetype_huawei_watchgt4; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchultimate/HuaweiWatchUltimateCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchultimate/HuaweiWatchUltimateCoordinator.java index 97497327d..8f4f3a40b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchultimate/HuaweiWatchUltimateCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchultimate/HuaweiWatchUltimateCoordinator.java @@ -22,10 +22,14 @@ import org.slf4j.LoggerFactory; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiBRCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiSpo2SampleProvider; +import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample; public class HuaweiWatchUltimateCoordinator extends HuaweiBRCoordinator { private static final Logger LOG = LoggerFactory.getLogger(HuaweiWatchUltimateCoordinator.class); @@ -45,6 +49,21 @@ public class HuaweiWatchUltimateCoordinator extends HuaweiBRCoordinator { return Pattern.compile("(" + HuaweiConstants.HU_WATCHULTIMATE_NAME + ").*", Pattern.CASE_INSENSITIVE); } + @Override + public boolean supportsHeartRateMeasurement(GBDevice device) { + return true; + } + + @Override + public boolean supportsSpo2() { + return true; + } + + @Override + public TimeSampleProvider getSpo2SampleProvider(GBDevice device, DaoSession session) { + return new HuaweiSpo2SampleProvider(device, session); + } + @Override public int getDeviceNameResource() { return R.string.devicetype_huawei_watchultimate;