Set low latency mode during initialization #249

This appears to fix the initialization getting stuck sometimes, e.g.
after turning on bluetooth and then connecting.

The band incidentally sends 0x8 when it's stuck (won't accept the UUID_PAIR
request).
This commit is contained in:
cpfeiffer 2016-03-23 22:50:42 +01:00
parent 1348bad4d3
commit 11ac01f0e8
1 changed files with 12 additions and 0 deletions

View File

@ -97,6 +97,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
builder.add(new SetDeviceStateAction(getDevice(), State.INITIALIZING, getContext()));
enableNotifications(builder, true)
.setLowLatency(builder)
.pair(builder)
.requestDeviceInfo(builder)
.sendUserInfo(builder)
@ -106,10 +107,21 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
.enableFurtherNotifications(builder, true)
.setCurrentTime(builder)
.requestBatteryInfo(builder)
.setHighLatency(builder)
.setInitialized(builder);
return builder;
}
private MiBandSupport setLowLatency(TransactionBuilder builder) {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_LE_PARAMS), getLowLatency());
return this;
}
private MiBandSupport setHighLatency(TransactionBuilder builder) {
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_LE_PARAMS), getHighLatency());
return this;
}
private MiBandSupport checkAuthenticationNeeded(TransactionBuilder builder, GBDevice device) {
builder.add(new CheckAuthenticationNeededAction(device));
return this;