From 7d877c9486aba1cc312385cbabd518bddc111e7c Mon Sep 17 00:00:00 2001 From: Daniel Dakhno Date: Thu, 16 Jan 2020 13:51:36 +0100 Subject: [PATCH] hopefully fixed connection state bug --- .../adapter/fossil/FossilWatchAdapter.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java index b5f1c54a9..ebe671098 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java @@ -555,6 +555,11 @@ public class FossilWatchAdapter extends WatchAdapter { } 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) { new TransactionBuilder("requestMtu") .requestMtu(512) @@ -585,6 +590,11 @@ public class FossilWatchAdapter extends WatchAdapter { } 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()) { log("queing request: " + request.getName()); if (priorise) { @@ -605,12 +615,22 @@ public class FossilWatchAdapter extends WatchAdapter { } 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()); queueNextRequest(); } protected void queueWrite(Request request) { + log("is connected: " + getDeviceSupport().isConnected()); + if(!getDeviceSupport().isConnected()){ + log("dropping requetst " + request.getName()); + return; + } if (request instanceof SetDeviceStateRequest) queueWrite((SetDeviceStateRequest) request, false); else if (request instanceof RequestMtuRequest)