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

* commit '1bc47a6e7020799ae7eb5ee3e91bc452144a3d64':
  BluetoothMidiDevice: change write type to support JamStik
This commit is contained in:
Phil Burk
2015-10-13 18:58:26 +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
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(
CLIENT_CHARACTERISTIC_CONFIG);
if (descriptor != null) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
boolean result = mBluetoothGatt.writeDescriptor(descriptor);
Log.d(TAG, "writeDescriptor returned " + result);
} else {
Log.e(TAG, "No CLIENT_CHARACTERISTIC_CONFIG for device " + mBluetoothDevice);
}
characteristic.setWriteType(originalWriteType);
}
@Override