2019-03-12 10:39:44

by Andrea

[permalink] [raw]
Subject: Help on BLE MIDI Peripheral

Hi,

I have adapted the python test files in example-gatt-server and example-advertisement to MIDI.

The code is here https://github.com/audetto/ble-midi

I can advertise it properly and in Android I can see the device.
But after it is selected and the android app create a MIDI Device, it drops after 3-4 seconds.

In Android I have used https://github.com/philburk/android-midisuite which is the reference
implementation.

I have added a lot of logging to the code and it does not print anything after the initial
advertisement phase.

Application.GetManagedObjects
GATT application registered
Advertisement.GetAll
returning props
Advertisement registered
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/org/bluez/example/advertisement0: Released!
Advertisement unregistered

I would expect the Central to Read some values as in the MIDI BLE spec

"The Central will attempt to read the MIDI I/O characteristic of the Peripheral after establishing a
connection with the accessory. The accessory shall respond to the initial MIDI I/O characteristic
read with a packet that has no payload."

And I get the exact same behaviour if I use the wrong UUID for the characteristic, or if I don't add
it at all.

I have the feeling the Characteristic is not registered properly.

Here is the key code:

class MIDICharacteristic(egs.Characteristic):
def __init__(self, bus, index, service):
flags = ['notify', 'read', 'write', 'write-without-response']
super().__init__(bus, index, MIDI_CHARACTERISTIC_UUID, flags, service)

and

class MIDIService(egs.Service):
def __init__(self, bus, index):
super().__init__(bus, index, MIDI_SERVICE_UUID, True)
self.add_characteristic(MIDICharacteristic(bus, 0, self))

Is there anything that comes to your mind with these symptoms?

Thank you