From 511fef7f6296d8b6526dafe34cb6bbe9f88f2b32 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 12 May 2018 17:18:19 +0200 Subject: [PATCH] Pebble 2: when using client only mode, no not wait for PPoGATT ACKs after each package This speeds up things up a lot. We should still somehow limit it, but not by waiting after one PPoGATT ACK after each complete PP package. This leaves the old mode untouched, so we have something to compare --- .../devices/pebble/ble/PebbleLESupport.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java index f6bfd4dea..e694cf51d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java @@ -156,10 +156,12 @@ public class PebbleLESupport { int serial = header >> 3; if (command == 0x01) { LOG.info("got ACK for serial = " + serial); - if (mPPAck != null) { - mPPAck.countDown(); - } else { - LOG.warn("mPPAck countdownlatch is not present but it probably should"); + if (!clientOnly) { + if (mPPAck != null) { + mPPAck.countDown(); + } else { + LOG.warn("mPPAck countdownlatch is not present but it probably should"); + } } } if (command == 0x02) { // some request? @@ -224,7 +226,9 @@ public class PebbleLESupport { int payloadToSend = bytesRead + 4; int srcPos = 0; - mPPAck = new CountDownLatch(1); + if (!clientOnly) { + mPPAck = new CountDownLatch(1); + } while (payloadToSend > 0) { int chunkSize = (payloadToSend < (mMTU - 4)) ? payloadToSend : mMTU - 4; byte[] outBuf = new byte[chunkSize + 1]; @@ -234,10 +238,10 @@ public class PebbleLESupport { srcPos += chunkSize; payloadToSend -= chunkSize; } - - mPPAck.await(); - mPPAck = null; - + if (!clientOnly) { + mPPAck.await(); + mPPAck = null; + } } catch (IOException | InterruptedException e) { LOG.info(e.getMessage()); Thread.currentThread().interrupt();