1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

HPlus: Ignore duplicated messages from band

This commit is contained in:
João Paulo Barraca 2016-12-24 00:05:51 +00:00
parent 88f2d2ee4f
commit 649e20ad04
2 changed files with 13 additions and 1 deletions

View File

@ -72,6 +72,7 @@ public final class HPlusConstants {
public static final byte DATA_STATS = 0x33;
public static final byte DATA_STEPS = 0x36;
public static final byte DATA_SLEEP = 0x1A;
public static final byte COMMAND_ACTION_INCOMING_SOCIAL = 0x31;

View File

@ -61,6 +61,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
private BluetoothGattCharacteristic ctrlCharacteristic = null;
private BluetoothGattCharacteristic measureCharacteristic = null;
private byte[] lastDataStats = null;
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@ -108,7 +110,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
setInitValues(builder);
setCurrentDate(builder);
setCurrentTime(builder);
syncPreferences(builder);
builder.notify(getCharacteristic(HPlusConstants.UUID_CHARACTERISTIC_MEASURE), true);
@ -449,6 +450,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
@Override
public void onSetTime() {
TransactionBuilder builder = new TransactionBuilder("time");
setCurrentDate(builder);
setCurrentTime(builder);
}
@ -651,6 +653,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
//builder = performInitialized("incomingCallText");
builder.queue(getQueue());
//TODO: Use WaitAction
try {
Thread.sleep(200);
} catch (InterruptedException e) {
@ -728,6 +731,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
String message = "";
//TODO: Create StringUtils.pad and StringUtils.truncate
if (title != null) {
if (title.length() > 17) {
message = title.substring(0, 17);
@ -951,6 +955,13 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
LOG.error("Invalid Stats Message Length " + data.length);
return false;
}
//Ignore duplicate packets
if(data.equals(lastDataStats))
return true;
lastDataStats = data.clone();
double distance = ((int) data[4] * 256 + data[3]) / 100.0;
int x = (int) data[6] * 256 + data[5];