Negotiate Ble Mtu on iOS

Change iOS BLE MTU size to 512 (SWIFT)

No, MTU on iOS is set automatically, maximum value is 185. This is a good answer to your question: https://stackoverflow.com/a/42336001/10380092

Note: you can get MTU value this way (it will be 3 bytes less than the ATT MTU):

connectedPeripheral.maximumWriteValueLength(for: .withoutResponse)

It's important to use parameter .withoutResponse, because .withResponse will always return 512 (when writing with response, iOS automatically chooses the approach: single write if data is shorter than MTU, or queued write if data is larger than MTU).

Negotiate BLE MTU on iOS

I will answer for people with same issue.

Right now (February 2017) the MTU of iPhone in Peripheral role is always 158.
So what I have found in short solution (just to make some test) is to compare the Central MTU to 158 and take the smaller one.
For a solution more stable peripheral will write the MTU size inside a specific characteristic that I will read after the connection.

Core Bluetooth: Reduced BLE MTU size when upgrading from iOS 15 to iOS 16

So it turns out that this was a bug/regression with iOS 16 and 16.0.2. It has since been fixed on iOS 16.1 and we have tested the fix and it is working here.

Can we Change BLE MTU and characteristic sizes on iOS central and peripheral devices

IOS always asks for an MTU of 185. So make sure your peripheral accepts that.

If you want to check using maximumWriteValueLength(), make sure you pass the withoutResponse type. Otherwise you always get 512 which is the max characteristic length.

iOS - MTU Size for BLE data transfer between iOS device and External Accessory(BluetoothWatch)

You can use whatever MTU size you want (up to 512).

The value that the connection will use is always the minimum between yours and theirs.

So, if for example they want to use MTU equal to, let's say, 50, then if your MTU is lower than 50, that one will be used; otherwise, whichever value you select above 50 is meaningless, as 50 gets picked.

How can an iOS BLE central receive more than 182 bytes from a peripheral in notify mode?

iOS devices have a maximum ATT_MTU of 185 bytes, which means you can send a maximum of 182 data bytes per packet (the other 3 bytes are overhead for L2CAP). In the beginning iOS devices only supported 158 bytes and then this was increased to 185.

The way ATT_MTU works is that there's a negotiation upon connection where the central sends its maximum ATT_MTU (i.e. for iPhones it is 185) and the peripheral replies with its own ATT_MTU (i.e. in your case it is 237), and then the connection's ATT_MTU will be the minimum between the two (i.e. 185). So to answer your question, no there isn't a way to configure your iOS device to send the full length of data because this is a low level configuration that Apple don't allow access to.

Have a look at the following links for more information:-

  • iOS BLE Get Negotiate MTU
  • Maximizing BLE Throughput Part 2: Use Larger ATT_MTU
  • A Practical Guide to BLE Throughput


Related Topics



Leave a reply



Submit