Page 1 of 1

Change BLE default MTU for iOS application

Posted: Thu Sep 05, 2019 2:13 pm
by newsettler_AI
Hi,

I need to change BLE MTU from default 23 value to some higher.

My ESP32 act as peripheral (server). Phone with Android / iOS act as central (client) and connect to ESP32, using custom application.

With Android everything wokrs fine by next routine:
1. Phone connects
2. Phone request MTU change
3. MTU successfully changed
This can be easily tested with any dev app, for example NRF Connect.

Problem is that iOS doesnt support MTU change requests. From iOS specs, it says that maximum MTU is 185 bytes.
I want to achieve it or at least get about 150-160 bytes.

But without ablitity to change it after connect, I have to set some higher default MTU value.

Right now I want to test that MTU value is changed, so testing with Android and NRF Connect.

What I've tried:

1) change

Code: Select all

ESP_GATT_DEF_BLE_MTU_SIZE
at esp-idf\components\bt\bluedroid\api\include\api but not affect on MTU (still default 23 bytes left)

2) change

Code: Select all

GATT_DEF_BLE_MTU_SIZE
at esp-idf\components\bt\bluedroid\stack\include\stack but got error (in NRF Connect log says "Error 129 (0x81) GATT INTERNAL ERROR ") and not able even discover services.

3) during bt initialisation call

Code: Select all

esp_ble_gatt_set_local_mtu(180)
but still no changes in MTU


Any assistance would be appreciated :)

Re: Change BLE default MTU for iOS application

Posted: Thu Sep 05, 2019 3:39 pm
by chegewara
Use only this option to change MTU:

Code: Select all

esp_ble_gatt_set_local_mtu(180)
If nRF shows some error when you are trying to discover services then it has to be something else but that.

Re: Change BLE default MTU for iOS application

Posted: Thu Sep 05, 2019 3:44 pm
by ukrsms
I noticed this issue as well
The difference is I use cpp_utils by Kolban:

Code: Select all

    BLEDevice::init("MY BLE");
    BLEDevice::setMTU(100);
But the masseges are still limited to about 20symbols

Re: Change BLE default MTU for iOS application

Posted: Fri Sep 06, 2019 11:58 am
by newsettler_AI
chegewara wrote:
Thu Sep 05, 2019 3:39 pm
Use only this option to change MTU:

Code: Select all

esp_ble_gatt_set_local_mtu(180)
If nRF shows some error when you are trying to discover services then it has to be something else but that.
After this I'm receiving tons of warnings

Code: Select all

W (26806) BT_GATT: attribute value too long, to be truncated to 179
When I tried to set 179, I'm getting error

Code: Select all

W (26806) BT_GATT: attribute value too long, to be truncated to 178
and so on... Dont understand what value to set...

Re: Change BLE default MTU for iOS application

Posted: Fri Sep 06, 2019 12:44 pm
by chegewara
newsettler_AI, 180 was just example value. You are getting those warnings because your message is longer and can't be sent in notifications/indications. Also you have to remember that notifications/indications max length is MTU - 3.