diff options
| -rw-r--r-- | media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java | 10 | 
1 files changed, 9 insertions, 1 deletions
diff --git a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java index e6d59e4fb141..444705cfc79f 100644 --- a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java +++ b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java @@ -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  |