Pebble 2: try an alternative way of setting the MTU (might revert)
This commit is contained in:
parent
e8da301da3
commit
fce86482b9
|
@ -60,7 +60,6 @@ class PebbleGATTClient extends BluetoothGattCallback {
|
||||||
}
|
}
|
||||||
if (characteristic.getUuid().equals(MTU_CHARACTERISTIC)) {
|
if (characteristic.getUuid().equals(MTU_CHARACTERISTIC)) {
|
||||||
int newMTU = characteristic.getIntValue(FORMAT_UINT16, 0);
|
int newMTU = characteristic.getIntValue(FORMAT_UINT16, 0);
|
||||||
mPebbleLESupport.setMTU(newMTU);
|
|
||||||
LOG.info("Pebble requested MTU = " + newMTU);
|
LOG.info("Pebble requested MTU = " + newMTU);
|
||||||
} else {
|
} else {
|
||||||
LOG.info("onCharacteristicChanged()" + characteristic.getUuid().toString() + " " + GB.hexdump(characteristic.getValue(), 0, -1));
|
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) {
|
private void setMTU(BluetoothGatt gatt) {
|
||||||
LOG.info("setting MTU");
|
LOG.info("setting MTU");
|
||||||
if (GBApplication.isRunningLollipopOrLater()) {
|
BluetoothGattCharacteristic characteristic = gatt.getService(SERVICE_UUID).getCharacteristic(MTU_CHARACTERISTIC);
|
||||||
gatt.requestMtu(339);
|
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CHARACTERISTIC_CONFIGURATION_DESCRIPTOR);
|
||||||
} else {
|
descriptor.setValue(new byte[]{0x0b, 0x01}); // unknown
|
||||||
BluetoothGattCharacteristic characteristic = gatt.getService(SERVICE_UUID).getCharacteristic(MTU_CHARACTERISTIC);
|
gatt.writeCharacteristic(characteristic);
|
||||||
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CHARACTERISTIC_CONFIGURATION_DESCRIPTOR);
|
|
||||||
descriptor.setValue(new byte[]{0x0b, 0x01}); // unknown
|
|
||||||
gatt.writeCharacteristic(characteristic);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
|
@ -59,7 +59,6 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
|
||||||
|
|
||||||
|
|
||||||
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
|
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100); // FIXME: bad bad, I mean BAAAD
|
Thread.sleep(100); // FIXME: bad bad, I mean BAAAD
|
||||||
} catch (InterruptedException ignore) {
|
} 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) {
|
public void onNotificationSent(BluetoothDevice bluetoothDevice, int status) {
|
||||||
//LOG.info("onNotificationSent() status = " + status + " to device " + mmBtDevice.getAddress());
|
//LOG.info("onNotificationSent() status = " + status + " to device " + mmBtDevice.getAddress());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue