am bfaa71bb: am 8e82755d: Merge "BluetoothMidiDevice: change write type to support JamStik" into mnc-dr-dev

* commit 'bfaa71bb316552236c78de87a96f0ee722133e78':
  BluetoothMidiDevice: change write type to support JamStik
This commit is contained in:
Phil Burk
2015-10-13 18:50:54 +00:00
committed by Android Git Automerger

View File

@@ -147,14 +147,22 @@ public final class BluetoothMidiDevice {
// switch to receiving notifications after initial characteristic read // switch to receiving notifications after initial characteristic read
mBluetoothGatt.setCharacteristicNotification(characteristic, true); mBluetoothGatt.setCharacteristicNotification(characteristic, true);
// Use writeType that requests acknowledgement.
// This improves compatibility with various BLE-MIDI devices.
int originalWriteType = characteristic.getWriteType();
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor( BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
CLIENT_CHARACTERISTIC_CONFIG); CLIENT_CHARACTERISTIC_CONFIG);
if (descriptor != null) { if (descriptor != null) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor); boolean result = mBluetoothGatt.writeDescriptor(descriptor);
Log.d(TAG, "writeDescriptor returned " + result);
} else { } else {
Log.e(TAG, "No CLIENT_CHARACTERISTIC_CONFIG for device " + mBluetoothDevice); Log.e(TAG, "No CLIENT_CHARACTERISTIC_CONFIG for device " + mBluetoothDevice);
} }
characteristic.setWriteType(originalWriteType);
} }
@Override @Override