tinygo-org / bluetooth

Cross-platform Bluetooth API for Go and TinyGo. Supports Linux, macOS, Windows, and bare metal using Nordic SoftDevice or HCI
https://tinygo.org
Other
744 stars 137 forks source link

sd: MTU exchange #295

Open rdnt opened 1 month ago

rdnt commented 1 month ago

This PR adds the capability to perform an MTU Exchange procedure from the central (gatt client - usually), and the ability to configure an ATT_MTU up to 247 bytes (allowing 244 bytes of application data).

I have tested this implementation on two nicenano_v2 boards.
In my tests, I have found updating the event length can allow for increased bandwidth, so I also implemented a way to configure it.
I have made some experiments with adding Data Length Extension as well, but I reckon some initial feedback would be welcome before I delve into starting a proper implementation of DLE.

Do let me know if you would like to have a working example (maybe also in the source code?) with a 247 MTU exchange + throughput test of sorts.

Lastly, I can only test on s140v7, so I can't really verify that the peripheral-only variant (s113v7) works as expected. If someone else could lend a hand I would appreciate that.

Refs:

Relevant: https://github.com/tinygo-org/bluetooth/issues/200#issuecomment-1878675073, https://github.com/tinygo-org/bluetooth/issues/142#issuecomment-1531906280

rdnt commented 4 weeks ago

Heya folks! I'm marking this as ready-for-review, hoping for an initial review pass. I am not very familiar with BLE, so any feedback, positive or negative, is welcome.

I reckon I saw somewhere (edit: https://github.com/tinygo-org/bluetooth/issues/142#issuecomment-1531906280) that such a change requires implementation for two different platforms. I am not sure if I can commit to implementing this also for e.g. Linux, but if required I will see what I can do. Otherwise this PR can be left open as a working POC until someone contributes a relevant implementation for some other platform.