From a62ff4eabbbac844ff68b025aaab1af05907dd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Fri, 22 Dec 2023 22:44:30 +0000 Subject: [PATCH] Xiaomi: Improve activity details parsing on some devices --- .../xiaomi/activity/impl/DailyDetailsParser.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/DailyDetailsParser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/DailyDetailsParser.java index c3912dd9b..8aed5b992 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/DailyDetailsParser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/DailyDetailsParser.java @@ -52,10 +52,13 @@ public class DailyDetailsParser extends XiaomiActivityParser { final int sampleSize; switch (version) { case 1: - case 2: headerSize = 4; sampleSize = 7; break; + case 2: + headerSize = 4; + sampleSize = 10; + break; case 3: headerSize = 5; sampleSize = 12; @@ -95,12 +98,15 @@ public class DailyDetailsParser extends XiaomiActivityParser { sample.setHeartRate(buf.get() & 0xff); - if (version == 3) { + if (version >= 2) { final byte[] unknown2 = new byte[3]; - buf.get(unknown2); // TODO intensity and kind? + buf.get(unknown2); // TODO intensity and kind? energy? - sample.setSpo2(buf.get() & 0xff); - sample.setStress(buf.get() & 0xff); + if (version == 3) { + // TODO gadgets with versions 2 also should have stress, but the values don't make sense + sample.setSpo2(buf.get() & 0xff); + sample.setStress(buf.get() & 0xff); + } } samples.add(sample);