[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?

+3


source to share


3 answers


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.

-1


source


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)

+7


source


I don't know if you are looking for this. but in my case I am asking a peripheral sending this message:

print("Max write value: \(peripheral.maximumWriteValueLength(for: .withResponse))")

      

0


source







All Articles