is there any way to change the MTU value on iOS from the default to an arbitrary value?
Much like in Android it's possible to do requestMTU(512).
Thanks
is there any way to change the MTU value on iOS from the default to an arbitrary value?
Much like in Android it's possible to do requestMTU(512).
Thanks
No, MTU on iOS is set automatically, maximum value is 185. This is a good answer to your question: https://mcmap.net/q/1259640/-negotiate-ble-mtu-on-ios
Note: you can get MTU value this way (it will be 3 bytes less than the ATT MTU):
connectedPeripheral.maximumWriteValueLength(for: .withoutResponse)
It's important to use parameter .withoutResponse
, because .withResponse
will always return 512 (when writing with response, iOS automatically chooses the approach: single write if data is shorter than MTU, or queued write if data is larger than MTU).
this is not an answer but it is interesting non the less. It is a reply from apple engineer on a request I send on the problem.
Hi,
Yes, the issue you are seeing is indeed due to the timing problem/race condition I was suspecting. The reason you are getting DPLE and MTU almost simultanously is, iOS has received the MTU request too early, and as it has not been able to determine if the connection supports EDL, it responds with the minimum.
In iOS 15 this race condition is being handled differently, and the MTU response is held off until the link is ready. Technically the peripheral is not doing something wrong, as the spec allows the MTU request to be sent at any time. Just that on iOS 14, on different devices, this issue may pop-up.
I can’t tell you to not send the MTU request at that time, because spec allows it. And iOS 15 is handling it in a way to bypass these issues.
Delaying the MTU request until PHY update may make the problem less likely, but there is no guarantee that it will not happen ever. The root issue here is that HCI events like PHY Update or EDL change are issued by each controller locally and there is no way to guarantee that just because your peripheral reports EDL that the iPhone controller has also done so. And unfortunately this timing/race issue will be different from controller to controller, therefore from phone to phone.
So I hope it helps. The BLE peripheral we are developing is sending all the commands for the connection negotiation pretty much all at the same time. And this is what was causing us to not be able to get the data length extension.
© 2022 - 2024 — McMap. All rights reserved.