Pebble 2: try an alternative way of setting the MTU (might revert)

here
Andreas Shimokawa 2016-11-21 14:54:01 +01:00
parent e8da301da3
commit fce86482b9
2 changed files with 10 additions and 10 deletions

View File

@ -60,7 +60,6 @@ class PebbleGATTClient extends BluetoothGattCallback {
}
if (characteristic.getUuid().equals(MTU_CHARACTERISTIC)) {
int newMTU = characteristic.getIntValue(FORMAT_UINT16, 0);
mPebbleLESupport.setMTU(newMTU);
LOG.info("Pebble requested MTU = " + newMTU);
} else {
LOG.info("onCharacteristicChanged()" + characteristic.getUuid().toString() + " " + GB.hexdump(characteristic.getValue(), 0, -1));
@ -214,14 +213,10 @@ class PebbleGATTClient extends BluetoothGattCallback {
private void setMTU(BluetoothGatt gatt) {
LOG.info("setting MTU");
if (GBApplication.isRunningLollipopOrLater()) {
gatt.requestMtu(339);
} else {
BluetoothGattCharacteristic characteristic = gatt.getService(SERVICE_UUID).getCharacteristic(MTU_CHARACTERISTIC);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CHARACTERISTIC_CONFIGURATION_DESCRIPTOR);
descriptor.setValue(new byte[]{0x0b, 0x01}); // unknown
gatt.writeCharacteristic(characteristic);
}
BluetoothGattCharacteristic characteristic = gatt.getService(SERVICE_UUID).getCharacteristic(MTU_CHARACTERISTIC);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CHARACTERISTIC_CONFIGURATION_DESCRIPTOR);
descriptor.setValue(new byte[]{0x0b, 0x01}); // unknown
gatt.writeCharacteristic(characteristic);
}
public void close() {

View File

@ -59,7 +59,6 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
try {
Thread.sleep(100); // FIXME: bad bad, I mean BAAAD
} catch (InterruptedException ignore) {
@ -152,6 +151,12 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
}
}
@Override
public void onMtuChanged(BluetoothDevice device, int mtu) {
LOG.info("Pebble requested mtu for server: " + mtu);
mPebbleLESupport.setMTU(mtu);
}
public void onNotificationSent(BluetoothDevice bluetoothDevice, int status) {
//LOG.info("onNotificationSent() status = " + status + " to device " + mmBtDevice.getAddress());
}