Fixed connection issues by reading the date from the band #249

This commit is contained in:
cpfeiffer 2016-03-24 22:10:23 +01:00
parent e5b0afb916
commit 89eddb13b0
1 changed files with 6 additions and 0 deletions

View File

@ -98,6 +98,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
builder.add(new SetDeviceStateAction(getDevice(), State.INITIALIZING, getContext())); builder.add(new SetDeviceStateAction(getDevice(), State.INITIALIZING, getContext()));
enableNotifications(builder, true) enableNotifications(builder, true)
.setLowLatency(builder) .setLowLatency(builder)
.readDate(builder) // without reading the data, we get sporadic connection problems, especially directly after turning on BT
.pair(builder) .pair(builder)
.requestDeviceInfo(builder) .requestDeviceInfo(builder)
.sendUserInfo(builder) .sendUserInfo(builder)
@ -112,6 +113,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
return builder; return builder;
} }
private MiBandSupport readDate(TransactionBuilder builder) {
builder.read(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_DATE_TIME));
return this;
}
public MiBandSupport setLowLatency(TransactionBuilder builder) { public MiBandSupport setLowLatency(TransactionBuilder builder) {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_LE_PARAMS), getLowLatency()); builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_LE_PARAMS), getLowLatency());
return this; return this;