Can't seem to properly disconnect a BTLE MIDI Device.

497 views
Skip to first unread message

Allen Heidorn

unread,
Dec 6, 2015, 9:27:27 PM12/6/15
to android-midi
Hi Phil,

Sorry for so many posts, but we are testing the completeness and other scenarios of our BTLE connection app for Android Marshmallow.

On a Nexus 9 device, I am able to scan for BTLE addresses, connect to a device using MidiManager's openBluetoothDevice(), get a MidiDevice object from onDeviceOpened, open the MidiInputPort and MidiOutputPort, and send/receive MIDI data.
I would now like to disconnect the peripheral properly, and here is what I tried/found:

Call MidiInputPort and MidiOutputPort's close(), followed by MidiDevice's close(), but nothing seems to happen. The peripheral's connect light stays lit, and MIDI in/out no longer works. If I turn off the peripheral, I get the following in logcat:


12-04 16:58:33.495  2109  2257 W bt_btif : bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0008

12-04 16:58:33.495  2109  2257 W bt_btif : bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0008

12-04 16:58:33.495  2109  2257 W bt_btif : bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0008

12-04 16:58:33.495  2109  2257 I   bt_btm_sec: btm_sec_disconnected clearing pending flag handle:64 reason:8

12-04 16:58:33.496  2109  2151 D BtGatt.GattService: onDisconnected() - clientIf=5, connId=5, address=FF:73:6A:10:29:37

12-04 16:58:33.496  2109  2151 E BluetoothRemoteDevices: aclStateChangeCallback: Device is NULL

12-04 16:58:33.496  3080  3091 D BluetoothGatt: onClientConnectionState() - status=8 clientIf=5 device=FF:73:6A:10:29:37

12-04 16:58:33.496  3080  3091 I BluetoothMidiDevice: Disconnected from GATT server.

12-04 16:58:33.497  3080  3093 D BluetoothMidiDevice: BluetoothMidiDevice thread exit

12-04 16:58:33.499  3080  3091 D BluetoothGatt: close()

12-04 16:58:33.499  3080  3091 D BluetoothGatt: unregisterApp() - mClientIf=5

12-04 16:58:33.499  2109  2121 D BtGatt.GattService: unregisterClient() - clientIf=5

12-04 16:58:33.500  2952  2952 I MIDIPortBridge: MyDeviceCallback::onDeviceRemoved


At this point, I can no longer re-connect to my peripheral unless I reboot the Nexus 9 (restarting the app/peripheral doesn't work).


I also tried just using MidiDevice's close() (without closing the MidiInputPort and MidiOutputPort first) with the same result.


The only way I can disconnect (and re-connect without rebooting the Nexus) is to quit the app when connected.

BTW, I also noticed that the MidiBlePairing sample exhibits the same behavior - I can connect, but not disconnect.


Am I doing something incorrectly, or should I try something else? Perhaps I uncovered a bug with Android (or maybe just on Nexus 9)?


I would appreciate any help or guidance you can give. 


Thanks,

Allen

Phil Burk

unread,
Dec 7, 2015, 12:29:29 AM12/7/15
to android-midi
Hello Allen,

That sounds like this bug:
The title is misleading. But read note #4.
We have a fix but it was too late to get that into the first M release. It will appear in a future release.
The fix has gone to AOSP so some OEMs may have incorporated the fix.
Sorry for the trouble. If you think you are seeing something different, please let me know.

Phil Burk


--
You received this message because you are subscribed to the Google Groups "android-midi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-midi...@googlegroups.com.
To post to this group, send email to androi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-midi/d07cc1cb-5384-40da-9a3b-19e399a90197%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages