Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d11e59ec authored by Phil Burk's avatar Phil Burk Committed by Glenn Kasten
Browse files

BluetoothMidiDevice: change write type to support JamStik



Temporarily use a Request instead of a Command so that the JamStik
will be properly enabled.

Bug: 24207964
Change-Id: I3d11732958c46e6039405b5969d5af0db8032fb9
Signed-off-by: default avatarPhil Burk <philburk@google.com>
(cherry picked from commit 95129f50)
parent ff23e1b4
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -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