DFRobot / BlunoBasicDemo

The basic demo for bluno
GNU General Public License v3.0
166 stars 233 forks source link

Is it possible to lower the communication latency ? #19

Open josephlarralde opened 5 years ago

josephlarralde commented 5 years ago

Hello,

I've been using the Bluno board successfully with an Android app based on this demo. I'm using sensor input from the Bluno to trigger sounds in this app.

My problem is : it seems that there is a constant latency due to the BLE protocol, around a few hundreds of miliseconds, which makes the Bluno unsuitable for this particular application. I'm wondering if there is a way to increase the priority of BLE communication with the Bluno. I think it's possible because some bluetooth devices like mice and keyboards have a much lower communication latency. Does anyone know if it is even possible, and if so, where to look at to improve this behaviour ? I'd like to reach a more or less constant latency of around 20ms, maximum 50ms (this is what is needed to preserve a sensation of immersion in real-time applications involving gesture and sound feedback).

Thanks for any pointers, Joseph

josephlarralde commented 5 years ago

One of my contacts suggested me to use the le_connection_set_parameter to modify the latency (looks like there are interval and latency parameters available in the GATT characteristics). I have no idea from where and when to send this command, though. It seems that it can be sent at any moment once the connection is established, either by the slave or by the master. So I tend to think that it could happen somewhere either in the BluetoothLeService.javaor in the BlunoLibrary.java file. At least this sounds like a quick way to test. But if this is possible to do it from the Arduino code, it would be awesome because it means that it would work directly on all platforms the Bluno would connect to.

Can anyone confirm that I'm not saying bulls**t ? I don't have much experience with BLE protocol and any further help will be very appreciated.