Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negotiate BLE MTU on iOS

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?

like image 329
anté75 Avatar asked Feb 01 '17 10:02

anté75


2 Answers

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)

like image 91
chrisc11 Avatar answered Oct 08 '22 13:10

chrisc11


I don't know if you are looking for this. but in my case I ask to the peripheral sending this message:

print("Max write value: \(peripheral.maximumWriteValueLength(for: .withResponse))")
like image 38
Juan Gil Avatar answered Oct 08 '22 13:10

Juan Gil