-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unreliable connection to my BLE device needs lots of attempts to connect #1240
Comments
A bit more info, I created a extremely simplified script which only tries to connect once. This is the btmon output for a FAILURE:
|
If it used to work better, then what has changed since then? Bleak version? BlueZ version? Other/more Bluetooth or Wi-fi devices? |
Hi dlech, By "before" I mean bleak==0.13.0. Bluez version I bumped it to 5.66 because on another thread you commented to get away from 5.55. There are 20 more BLE devices, can this be a problem because of active BLE scanning? Again, on laptop works fine. Do you think using the wi-fi (VNC to see the screen) while running my bleak-based program can be an issue? Because of coexistence or shared wi-fi/ble module in RPi? I can do some tests if someone has something in mind. |
I added a retry based on time (try to connect for 30 seconds) instead of number of retries since it can fail several times in a row very quick. It is, at least in my case, strongly related to using Wi-fi and BLE at the same time. I switched off Wi-Fi and I am using my cell connection, and works much better. Thanks for your time. |
yeah, newer bluez is .... wonky somehow. If i use bleak to connect to a string mac address, it now takes 5-6 or more attempts to get a connection. I can use nrf connect on my phone to connect every time. If I do the following steps manually in bluetoothctl, it works first time though.
It's something with the devices being removed when scanning stops, but it's wayyyy more problematic than it used to be. The scanning spam stops when it gets connected, but resumes when you disconnect. I'm on bluez 5.66 |
Closing as duplicate of #1220. |
bluetoothctl -v
) in case of Linux: 5.66Description
Connect reliably to a BLE device based on CC26X2R.
It needs a lot of attempts to connect, used to be much more stable.
What I Did
Once it connects, everything works, but some times it takes a lot of attempts to connect. More than 10.
I activated
export BLEAK_LOGGING=1
The thing is that it seems to connect, from what I can understand from logs, but just too late and is discarded?
As you can see, we have a lot of devices. I tried to isolate around important sections by including a mark such as
"----------------"
For example, I think the last part of the log can be enough:
On several spots it says connected! But it does not seem so. My connection routine for bleak is:
While not perfect, now that I recall I have not a single connection problem when using this code on the laptop.
Maybe something related to BLE service discovery? Maybe related to connection parameters? Again RPI has all these connection errors, laptop shows none.
Let's see if someone can help me, I am buying beers.
Logs
(I think the important part is at the end)
The text was updated successfully, but these errors were encountered: