Page 1 of 1

RPi4 used as BLE central device connection issues

Posted: Fri Aug 02, 2019 2:27 pm
by gaz_quentin
For a professional project, i have to use a RPI4 as a central device to connect to a particular peripheral device.
For testing, I developped a program to simulate a peripheral on a RPi (thanks to bleno Node.js module) and use another RPi as central with the bluepy Python library.

All worked fine but when I set the advertising interval higher than 4000ms on my peripheral, connection doesn't work anymore (even on the RPi as peripheral or with the production peripheral device).
I tried to use gatttool/hcitool on my central, same issues, it works well but only if advertising interval is less than 4000ms.
But it works when I try to connect to my peripheral with my phone with a dedicated application (LightBlue).

After some research, I found that the Linux kernel only validates values of connection interval within the range 7.5ms - 4000ms (https://lkml.org/lkml/2019/8/2/358), which match with my experimental values. But except if I don't understand something with BLE, connection interval and advertising interval are totally independent and it should not be a problem. In the Bluetooth documentation, I found that maximum advertising interval value should be 10240ms. There is something I don't understand.




I edit here with an answer that some one gave me on Stackoverflow, if it can help someone.
Bluepy uses BlueZ, and when BlueZ connects, it first scans and when it finds the wanted device, it stops scanning and initiates a connection. During this connection attempt, there is a timeout before starting scanning again. It could be that this 4000 ms advertising interval is larger than the timeout.
See https://git.kernel.org/pub/scm/linux/ke ... c1679e7571 You can increase it and recompile the kernel if you want. HCI_LE_AUTOCONN_TIMEOUT is by the way used here: https://git.kernel.org/pub/scm/linux/ke ... ci_event.c