Mylab6/PiBluetoothMidSetup

Cannot reconnect after the connection is forgotten

Closed this issue · 7 comments

EFeru commented

Hi thank you for your work.

I run your scripts on both Raspberry Pi Zero version 1 and version 2. At the first try I was able to connect my laptop to the RPi0 Midi server and connection was stable.
Then decided to do more testing, and I deleted/forgot the connection on the PC and try to reconnect. Then the PC has a hard time reconnectiong. Sometimes it connects shortly, then disconnects, also the raspberry py bluetooth appears dissapears often from the list when I search for it.
Below you see the messages:
2022-01-21 21_19_51-pi@raspberrypi_ _home_Piano-LED-Visualizer

I believe the issue could be in the fork of https://github.com/oxesoft/bluez which is using a very old version (2017) of the official bluez https://github.com/bluez/bluez

Any suggestions how to approach it? Do you experiece similar situation?

Hi, do you have an iPhone or IOS device to test this against ?

I find iOS to be the most stable Bluetooth midi host.
I haven't encountered any issues.

How far are you from your PC ?
Maybe it's the Bluez version, but if they don't want to merge the changes upstream theirs nothing we can do.

Technically you could fork the latest Bluez and re add the Bluetooth midi stack, but I don't know how hard that would be .

EFeru commented

Hi,

Thank you for your fast reply.

How far are you from your PC ?

1.5 meters away. I think distance should be ok.

do you have an iPhone or IOS device to test this against ?

Yes I just tested with an IPhone 6S. First of all the iPhone was not able to see the Raspberry Pi bluetooth, then I tryied with sudo bluetoothctl to pair from the Raspberry pi to iPhone. I could see the iPhone from Raspberry pi and pair, then lost connection very quickly:
image

I really think there is something not ok with the bluez implementation because it is not robust/stable at all. I am using this version (the one from the fork of https://github.com/oxesoft/bluez)
image

EFeru commented

I also updated to the latest official bluez version:

sudo apt-get install bluez

image

Then same issue, very quickly it disconnects:
image

Edit: I have tryied also with my Android phone OnePlus 8T, exactly the same issue as above.

Wait is the pi showing up as a Bluetooth Midi LE device ?

It has to be paired differently.

Try using the connect BLE Midi app on iOS.

EFeru commented

When using the midi bluetooth is true it has to be paired differently. However the issue happens also when trying to connect as a classic Bluetooth. So it is independent on midi stuff. People from bluez (if you check the linked issue above) mentioned it could be the Bluetooth module firmware that keeps disconnecting.

This project only supports Bluetooth Midi , I simply haven't looked into other use cases, like wanting to use a PI as both a Bluetooth midi device and as a classic BT device.

I'm going to close out this issue, since I don't really know how to fix it. But feel free to submit a PR if you find a solution. You'd probably have to fork Bluez again though.

I personally have a dedicated PI Zero that only acts as a Bluetooth MIDI hub, I don't use it for any other purpose.

EFeru commented

The test with classic bluetooth was only to pin point where the problem is: if it is a bluetooth problem or something related to Midi stack in bluez. Apparently, is the bluetooth module or RPi0 causing issues.