hopefully fixed connection state bug

This commit is contained in:
Daniel Dakhno 2020-01-16 13:51:36 +01:00
parent fd8800607c
commit 7d877c9486

View File

@ -555,6 +555,11 @@ public class FossilWatchAdapter extends WatchAdapter {
} }
public void queueWrite(RequestMtuRequest request, boolean priorise) { public void queueWrite(RequestMtuRequest request, boolean priorise) {
log("is connected: " + getDeviceSupport().isConnected());
if(!getDeviceSupport().isConnected()){
log("dropping requetst " + request.getName());
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
new TransactionBuilder("requestMtu") new TransactionBuilder("requestMtu")
.requestMtu(512) .requestMtu(512)
@ -585,6 +590,11 @@ public class FossilWatchAdapter extends WatchAdapter {
} }
public void queueWrite(FossilRequest request, boolean priorise) { public void queueWrite(FossilRequest request, boolean priorise) {
log("is connected: " + getDeviceSupport().isConnected());
if(!getDeviceSupport().isConnected()){
log("dropping requetst " + request.getName());
return;
}
if (fossilRequest != null && !fossilRequest.isFinished()) { if (fossilRequest != null && !fossilRequest.isFinished()) {
log("queing request: " + request.getName()); log("queing request: " + request.getName());
if (priorise) { if (priorise) {
@ -605,12 +615,22 @@ public class FossilWatchAdapter extends WatchAdapter {
} }
public void queueWrite(Request request, boolean priorise) { public void queueWrite(Request request, boolean priorise) {
log("is connected: " + getDeviceSupport().isConnected());
if(!getDeviceSupport().isConnected()){
log("dropping requetst " + request.getName());
return;
}
new TransactionBuilder(request.getClass().getSimpleName()).write(getDeviceSupport().getCharacteristic(request.getRequestUUID()), request.getRequestData()).queue(getDeviceSupport().getQueue()); new TransactionBuilder(request.getClass().getSimpleName()).write(getDeviceSupport().getCharacteristic(request.getRequestUUID()), request.getRequestData()).queue(getDeviceSupport().getQueue());
queueNextRequest(); queueNextRequest();
} }
protected void queueWrite(Request request) { protected void queueWrite(Request request) {
log("is connected: " + getDeviceSupport().isConnected());
if(!getDeviceSupport().isConnected()){
log("dropping requetst " + request.getName());
return;
}
if (request instanceof SetDeviceStateRequest) if (request instanceof SetDeviceStateRequest)
queueWrite((SetDeviceStateRequest) request, false); queueWrite((SetDeviceStateRequest) request, false);
else if (request instanceof RequestMtuRequest) else if (request instanceof RequestMtuRequest)