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
?
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)
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))")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With