adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
629 stars 501 forks source link

BLE MIDI split SysEx messages read problem #172

Open jardous opened 6 years ago

jardous commented 6 years ago

I am using the nRF52 Feather as peripheral device for two way MIDI communication (MIDI foot controller).

Reading messages seems to cause occasional errors:

The central device is sending packets and sometimes another message appears before the message is fully received.

For example sends three packets (one message split in 3):

-8f 8e f0 00 20 33 00 00 03 00 00 01 53 61 6c 76 61 74 69 6f -8f 6e 20 44 65 6c 75 78 65 20 50 75 73 68 65 64 20 56 33 -8f 30 00 8e f7

then it sends three other SysEx messages -8f e8 f0 00 20 33 00 00 07 00 00 00 01 00 00 58 6f 76 65 72 -8f 20 6c 69 76 65 00 e8 f7

-90 a4 f0 00 20 33 00 00 07 00 00 00 01 00 01 6d 61 69 6e 00 -90 a4 f7

-90 e0 f0 00 20 33 00 00 07 00 00 00 01 00 02 73 65 63 6f 6e -90 64 00 e0 f7

and the MIDI.read() on the peripheral device returns:

F0 00 20 33 00 00 03 00 00 01 53 61 6C 76 61 74 69 6F 6E 20 F0 00 20 33 00 00 07 00 00 00 01 00 02 73 65 63 6F 6E 64 00 F7

Some messages are somehow lost.

Did anybody else seen this behaviour?

Could that be a design problem? Should I switch the Central and Peripheral roles if the Central device sends more data to the Peripheral? For most of the communication it works well. Interesting is, that I can reproduce this. The data is sent from the Central device with response required. I log the messages before sending and they are sent correct. The problem is most probably on the receiving side (Peripheral BLEmidi read).

Nenik commented 6 years ago

Since MIDI uses BLE notifications as the delivery mechanism, it might be related to https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/173