micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

aioble: Pass additional connection arguments to gap_connect.

Open Joris-van-der-Wel opened this issue 1 year ago • 0 comments

In my project I am connecting using aioble to a human input device. There is noticeable input lag. Turns out the RTT latency is a little over 200ms (I test this by timing await char.write(b'foo', response=1)). I suspect this is because the BLE connection interval is being set to 100ms. The gap_connect function allows setting min_conn_interval_us and max_conn_interval_us, however there is no way to do so using aioble.

This PR allows the following additional arguments to be passed to device.connect():

  • scan_duration_ms
  • min_conn_interval_us
  • max_conn_interval_us

These are passed as-is to gap_connect(). The default value for all of these is None, which causes gap_connect to use its own defaults.

With this change I managed to get the RTT latency down to ~60ms, this feels a lot better in my project.

Package: https://joris-van-der-wel.github.io/micropython-lib/mip/gap_connect_params/

Joris-van-der-Wel avatar Aug 02 '24 20:08 Joris-van-der-Wel