From f68bbe453b966a0d76d1d739c658109bd015cb63 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 10 Nov 2016 11:05:32 +0100 Subject: [PATCH] Pebble: bump flags and version we report Plus some small preparations for P2 support which do not hurt in master --- .../service/devices/pebble/PebbleIoThread.java | 16 ++++++---------- .../service/devices/pebble/PebbleProtocol.java | 8 ++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index 89f45c95..84b977e1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -181,9 +181,9 @@ class PebbleIoThread extends GBDeviceIoThread { BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(btDeviceAddress); if (btDevice.getType() == BluetoothDevice.DEVICE_TYPE_LE) { LOG.info("Ok this seems to be a LE Pebble, will try something that does not work :P"); - mInStream = new PipedInputStream(new PipedOutputStream()); // fake so that io blocks - mOutStream = new PipedOutputStream(new PipedInputStream()); // fake so that io blocks - //new PebbleLESupport(this.getContext(),btDeviceAddress); // secret branch :P + mInStream = new PipedInputStream(); // fake so that io blocks + mOutStream = new PipedOutputStream(); // fake so that io blocks + //new PebbleLESupport(this.getContext(),btDeviceAddress,(PipedInputStream)mInStream,(PipedOutputStream)mOutStream); // secret branch :P } else { ParcelUuid uuids[] = btDevice.getUuids(); @@ -323,9 +323,10 @@ class PebbleIoThread extends GBDeviceIoThread { } int bytes = mInStream.read(buffer, 0, 4); - if (bytes < 4) { - continue; + while (bytes < 4) { + bytes += mInStream.read(buffer, bytes, 4 - bytes); } + ByteBuffer buf = ByteBuffer.wrap(buffer); buf.order(ByteOrder.BIG_ENDIAN); short length = buf.getShort(); @@ -340,11 +341,6 @@ class PebbleIoThread extends GBDeviceIoThread { bytes = mInStream.read(buffer, 4, length); while (bytes < length) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } bytes += mInStream.read(buffer, bytes + 4, length - bytes); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 57c58b70..eca9afa9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -1297,11 +1297,11 @@ public class PebbleProtocol extends GBDeviceProtocol { buf.putInt(os); buf.put(PHONEVERSION_APPVERSION_MAGIC); - buf.put((byte) 3); // major - buf.put((byte) 12); // minor - buf.put((byte) 0); // patch + buf.put((byte) 4); // major + buf.put((byte) 1); // minor + buf.put((byte) 1); // patch buf.order(ByteOrder.LITTLE_ENDIAN); - buf.putLong(0x00000000000001af); //flags + buf.putLong(0x00000000000029af); //flags return buf.array(); }