From 647b67cfcafc0716f59ada70ab59b29922932018 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 21 Nov 2016 15:16:30 +0100 Subject: [PATCH] Pebble 2: call both requestMTU and use the characteristic write --- .../service/devices/pebble/ble/PebbleGATTClient.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java index 37b9dcea..a9a2acd0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java @@ -60,7 +60,7 @@ class PebbleGATTClient extends BluetoothGattCallback { } if (characteristic.getUuid().equals(MTU_CHARACTERISTIC)) { int newMTU = characteristic.getIntValue(FORMAT_UINT16, 0); - LOG.info("Pebble requested MTU = " + newMTU); + LOG.info("Pebble requested MTU: " + newMTU); } else { LOG.info("onCharacteristicChanged()" + characteristic.getUuid().toString() + " " + GB.hexdump(characteristic.getValue(), 0, -1)); } @@ -92,8 +92,7 @@ class PebbleGATTClient extends BluetoothGattCallback { if (newState == BluetoothGatt.STATE_CONNECTED) { LOG.info("calling discoverServices()"); gatt.discoverServices(); - } - else if (newState == BluetoothGatt.STATE_DISCONNECTED){ + } else if (newState == BluetoothGatt.STATE_DISCONNECTED) { mPebbleLESupport.close(); } } @@ -112,6 +111,10 @@ class PebbleGATTClient extends BluetoothGattCallback { } else { subscribeToConnectionParams(gatt); } + } else if (characteristic.getUuid().equals(MTU_CHARACTERISTIC)) { + if (GBApplication.isRunningLollipopOrLater()) { + gatt.requestMtu(339); + } } }