HPlus: Ignore duplicated messages from band
This commit is contained in:
parent
88f2d2ee4f
commit
649e20ad04
|
@ -72,6 +72,7 @@ public final class HPlusConstants {
|
||||||
|
|
||||||
public static final byte DATA_STATS = 0x33;
|
public static final byte DATA_STATS = 0x33;
|
||||||
public static final byte DATA_STEPS = 0x36;
|
public static final byte DATA_STEPS = 0x36;
|
||||||
|
|
||||||
public static final byte DATA_SLEEP = 0x1A;
|
public static final byte DATA_SLEEP = 0x1A;
|
||||||
|
|
||||||
public static final byte COMMAND_ACTION_INCOMING_SOCIAL = 0x31;
|
public static final byte COMMAND_ACTION_INCOMING_SOCIAL = 0x31;
|
||||||
|
|
|
@ -61,6 +61,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
private BluetoothGattCharacteristic ctrlCharacteristic = null;
|
private BluetoothGattCharacteristic ctrlCharacteristic = null;
|
||||||
private BluetoothGattCharacteristic measureCharacteristic = null;
|
private BluetoothGattCharacteristic measureCharacteristic = null;
|
||||||
|
|
||||||
|
private byte[] lastDataStats = null;
|
||||||
|
|
||||||
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
|
@ -108,7 +110,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
setInitValues(builder);
|
setInitValues(builder);
|
||||||
setCurrentDate(builder);
|
setCurrentDate(builder);
|
||||||
setCurrentTime(builder);
|
setCurrentTime(builder);
|
||||||
|
|
||||||
syncPreferences(builder);
|
syncPreferences(builder);
|
||||||
|
|
||||||
builder.notify(getCharacteristic(HPlusConstants.UUID_CHARACTERISTIC_MEASURE), true);
|
builder.notify(getCharacteristic(HPlusConstants.UUID_CHARACTERISTIC_MEASURE), true);
|
||||||
|
@ -449,6 +450,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
@Override
|
@Override
|
||||||
public void onSetTime() {
|
public void onSetTime() {
|
||||||
TransactionBuilder builder = new TransactionBuilder("time");
|
TransactionBuilder builder = new TransactionBuilder("time");
|
||||||
|
|
||||||
setCurrentDate(builder);
|
setCurrentDate(builder);
|
||||||
setCurrentTime(builder);
|
setCurrentTime(builder);
|
||||||
}
|
}
|
||||||
|
@ -651,6 +653,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
//builder = performInitialized("incomingCallText");
|
//builder = performInitialized("incomingCallText");
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
|
|
||||||
|
//TODO: Use WaitAction
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -728,6 +731,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
String message = "";
|
String message = "";
|
||||||
|
|
||||||
|
//TODO: Create StringUtils.pad and StringUtils.truncate
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
if (title.length() > 17) {
|
if (title.length() > 17) {
|
||||||
message = title.substring(0, 17);
|
message = title.substring(0, 17);
|
||||||
|
@ -951,6 +955,13 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
LOG.error("Invalid Stats Message Length " + data.length);
|
LOG.error("Invalid Stats Message Length " + data.length);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Ignore duplicate packets
|
||||||
|
if(data.equals(lastDataStats))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
lastDataStats = data.clone();
|
||||||
|
|
||||||
double distance = ((int) data[4] * 256 + data[3]) / 100.0;
|
double distance = ((int) data[4] * 256 + data[3]) / 100.0;
|
||||||
|
|
||||||
int x = (int) data[6] * 256 + data[5];
|
int x = (int) data[6] * 256 + data[5];
|
||||||
|
|
Loading…
Reference in New Issue