We are developing our own BLE cable replacement implementation using BGAPI (v1.5.0-212) and the BT121.
We are using notifications and write-w/o-reply for passing data between a client and a BT121 gatt server.
To maximize throughput, we have increased the MTU to 150 bytes.
My question is - is there a BGAPI call somewhere to read the currently negotiated MTU? Our project needs to accommodate devices using the 4.1 spec which limits BLE to 20 byte notifications. Sending 150 byte notifications from the BT121 to a 4.1 spec device, seems to clip our data, but works fine with 4.2 spec and above devices.
Thanks for any help.
No, unfortunately there is no command or event that would show the already negotiated MTU in an ongoing connection. Despite that I can describe how the MTU is being set. It is simple comparison operation which sets the highest possible value for both connected devices.
Would it be possible to use some application level handshake at the beginning of the connection? I mean that the client would tell the server (BT121) what is the MTU / block size it wants to use? This of course assumes that the client knows what is the negotiated MTU.
This handshake could happen via the SPP connection (e.g. client sends message <mtu,150> or something like that. Or then you could implement a writable characteristic in the GATT of the BT121 so that the SPP client can write the MTU while keeping the SPP connection truly transparent.
It's kind of a kludge, but I don't see any other way as the BLE stack for BT121 does not report the MTU to the application (which is not really a bug but kind of a severe limitation).
Thank you both for the replies. The handshake suggestion seems like a good possible workaround if all else fails.
Thanks Adam, could you please describe this simple comparison operation? Is it a sequence we can repeat at the application layer to calculate the MTU ourselves?
In general, the sequence would take max MTUs of your BT121 and a remote device pick up lower of the two. It is quite simple to calculate on the application layer but to be completely sure I would say that Tyler's solution is better. If the Client side is able give you the negotiated MTU you should be able also to send to the BT121 acting as Server and then it would know that.