[iOS] [BLE] Get MTU protocol
I am currently developing a BLE app on iOS. In my application, I need to implement a segmentation protocol for sending big data using BLE. My application should have a central role.
My problem is that I cannot get MTU to negotiate. I can get the maximumWriteValueLength of my peripheral, but it is larger than mine and cannot find the maximumWriteValueLength of my central object.
Does anyone know a way to find the MTU to negotiate, or a way to access the CBCentral object of my CBCentralManager?
source to share
I will answer for people with the same problem.
Right now (Feb 2017) iPhone MTU in Peripheral role is always 158. So what I found in the short solution (just to do some test) is to compare the Central MTU with 158 and take the smaller one. For a solution, a more stable peripheral will write the MTU size within a certain characteristic, which I will read after connecting.
source to share
iOS automatically starts MTU exchange when connected.
Devices running iOS <10 will request an MTU size of 158. New devices running iOS 10 will request an MTU size of 185.
Assuming the device you are connected to supports these dimensions, this is what you should see.
You should determine the maximum payload size negotiated by looking at the property maximumUpdateValueLength
CBCentral
. (Note that this will be 3 bytes less than ATT MTU as it is overhead for ATT notification / indication)
source to share