Skip to content
Commit 539bbf06 authored by Robert Wu's avatar Robert Wu
Browse files

Bluetooth MIDI: Set MTU after service discovery

ag/15888883 introduced a change to set MTUs. This change would set MTUs
once the device is connected.

We got reports that packets get dropped after ~20 bytes on some BLE
MIDI connections.

It seems like setting MTU only works after a successful service
discovery, rather simply after calling service discovery. That is,
requestMtu() must wait for the onServicesDiscovered() callback instead
of simply after calling discoverServices().

BluetoothMidiService assumed that requestMtu() would either return false
or have a callback. However, for some BLE MIDI devices, neither would
occur. This results in BluetoothMidiService using a buffer size of 512
bytes when many devices on the market only supports 23 bytes. This
results in only the first ~20 bytes getting sent for a packet.

The fix here is to call requestMtu() after onServicesDiscovered() as
well as to set default encoder and decoder sizes in case requestMtu()
fails.

Bug: 246515282
Test: Connected Yamaha UD-BT01 with Android. Sent 100 bytes of SysEx to
verify data gets sent correctly. Verifed that data gets logged correctly
on MidiScope on the other side.

Merged-In: I8f7e9bc98064b110010a9af7aea56c786ef9e374
Change-Id: I8f7e9bc98064b110010a9af7aea56c786ef9e374
(cherry picked from commit 803d71a2)
parent a84c7a7b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment