BLE MTU Exchange
-
Hi,
I have been trying to read over BLE a 64 byte message characteristic value. I know that my problem is the MTU exchange between devices. What I can not figure out is why Qt won't update my QLowEnergyController with the correct MTU.
Upon connection, the MTU is set to the default value of 23. I read it off using m_control->mtu(); to see this. Then once I connect to a service, the MTU is 256 which is what the BLE device wants it to be at. When I go to read the characteristic value that has 64 bytes, only 24 bytes come over. I am unsure what I am doing incorrectly.
I have tried using the m_control->requestConnectionUpdate(params); function to request the new MTU value to be set but I receive this error "qt.bluetooth.darwin: Connection update not implemented on your platform". I honestly do not understand what this means and can not find anything where it talks about this.
Does anyone have any advice on how to exchange the MTU size properly?
-
Hi and welcome to devnet,
You can read the message literally: the underlying OS does not allow to change the MTU.
This seems to be confirmed by this thread on Apple's developer forum.
-
Hi @TyChapin,
Upon connection, the MTU is set to the default value of 23.
That's only a "we don't know yet" default, which is, frankly, pretty meaningless. As per the docs:
Before the connection setup and MTU negotiation, the default value of 23 will be returned.
@TyChapin said in BLE MTU Exchange:
Then once I connect to a service, the MTU is 256 which is what the BLE device wants it to be at.
Yep, that (256) would be the real, negotiated, MTU.
@TyChapin said in BLE MTU Exchange:
When I go to read the characteristic value that has 64 bytes, only 24 bytes come over.
Does anyone have any advice on how to exchange the MTU size properly?I suspect the problem is not MTU related. In most cases, the MTU should not affect the characteristic data size (just performance), because the BLE stack will use as many MTU's as needed to transfer the characteristic's data.
How are you checking the characteristic value's length? ie how do you know that the "value has 64 bytes", and "only 24 bytes come over"?
(Also, if its a publicly documented characteristic, and you're able to share the UUID, that might help, but no worries if not).
Cheers.