From a1ff9aab215b810dbcf3770762048f635939642f Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Thu, 4 Jun 2015 18:56:35 +0200 Subject: [PATCH] Do not iterate over the whole buffer, but only on the effectively used part. This should fix the "data in the future" issue --- .../freeyourgadget/gadgetbridge/miband/MiBandSupport.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java index c2f2dda9..08b461cb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java @@ -462,10 +462,8 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport { LOG.info("data to read until next header: "+ dataUntilNextHeader +" len: " + (dataUntilNextHeader / 3) + " minute(s)"); LOG.info("TIMESTAMP: " + DateFormat.getDateTimeInstance().format(timestamp.getTime()).toString() + " magic byte: " + dataUntilNextHeader); - if (dataUntilNextHeader > 0 ) { //tentative fix for data in the future - this.activityDataRemainingBytes = this.activityDataUntilNextHeader = dataUntilNextHeader; - this.activityDataTimestampProgress = this.activityDataTimestampToAck = timestamp; - } + this.activityDataRemainingBytes = this.activityDataUntilNextHeader = dataUntilNextHeader; + this.activityDataTimestampProgress = this.activityDataTimestampToAck = timestamp; } else { bufferActivityData(value); @@ -502,7 +500,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport { GregorianCalendar timestamp = this.activityDataTimestampProgress; byte category, intensity, steps; - for (int i=0; i