Negotiate BLE MTU on iOS

anté75 picture anté75 · Feb 1, 2017 · Viewed 7.6k times · Source

I'm currently developing a BLE App for iOS. In my application I need to implement a segmentation protocol to send large quantities of data using BLE. My application need to have the Central role.

My issue is that I can't get the negotiate MTU. I can get the maximumWriteValueLength of my peripheral but it is bigger that mine and can't find the maximumWriteValueLength of my central object.

Does someone know a way to find the negotiated MTU or a way to access the CBCentral object of my CBCentralManager?

Answer

chrisc11 picture chrisc11 · Feb 20, 2017

iOS kicks off an MTU exchange automatically upon connection.

Devices running iOS < 10 will request an MTU size of 158. Newer devices running iOS 10 will request an MTU size of 185.

Assuming the device you are connected to supports these sizes, that is what you should see.

You should be able to determine the max payload size negotiated by looking at the maximumUpdateValueLength property of the CBCentral. (Note this will be 3 bytes less than the ATT MTU since that's the overhead for a ATT notification/indication)