From b73ff49681f278d441b7f0fd7ccc2d44ab94636e Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Thu, 17 Sep 2015 15:39:44 +0200 Subject: [PATCH] Use data type constant instead of hardcoded value --- .../gadgetbridge/devices/miband/MiBandService.java | 11 ++++++----- .../miband/operations/FetchActivityOperation.java | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java index 3d34b4397..e436a2901 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java @@ -178,13 +178,14 @@ public class MiBandService { */ - /* MODES: unknown - - public static final MODE_REGULAR_DATA_LEN_BYTE = 0x0t; - - public static final MODE_REGULAR_DATA_LEN_MINITE = 0x1t + /* MODES: probably related to the sample data structure */ + public static final byte MODE_REGULAR_DATA_LEN_BYTE = 0x0; + + // was MODE_REGULAR_DATA_LEN_MINITE + public static final byte MODE_REGULAR_DATA_LEN_MINUTE = 0x1; + /* PROFILE: unknown public static final PROFILE_STATE_UNKNOWN:I = 0x0 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java index 8f57d02e2..90ac55c24 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java @@ -111,14 +111,14 @@ public class FetchActivityOperation extends AbstractBTLEOperation // counter of all data held by the band int totalDataToRead = (value[7] & 0xff) | ((value[8] & 0xff) << 8); - totalDataToRead *= (dataType == 1) ? 3 : 1; + totalDataToRead *= (dataType == MiBandService.MODE_REGULAR_DATA_LEN_MINUTE) ? 3 : 1; // counter of this data block int dataUntilNextHeader = (value[9] & 0xff) | ((value[10] & 0xff) << 8); - dataUntilNextHeader *= (dataType == 1) ? 3 : 1; + dataUntilNextHeader *= (dataType == MiBandService.MODE_REGULAR_DATA_LEN_MINUTE) ? 3 : 1; - // there is a total of totalDataToRead that will come in chunks (3 bytes per minute if dataType == 1), + // there is a total of totalDataToRead that will come in chunks (3 bytes per minute if dataType == 1 (MiBandService.MODE_REGULAR_DATA_LEN_MINUTE)), // these chunks are usually 20 bytes long and grouped in blocks // after dataUntilNextHeader bytes we will get a new packet of 11 bytes that should be parsed // as we just did