Change BLE default MTU for iOS application

newsettler_AI
Posts: 121
Joined: Wed Apr 05, 2017 12:49 pm

Change BLE default MTU for iOS application

Postby newsettler_AI » Thu Sep 05, 2019 2:13 pm

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 :)

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Change BLE default MTU for iOS application

Postby chegewara » 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.

ukrsms
Posts: 24
Joined: Tue Aug 20, 2019 11:30 am

Re: Change BLE default MTU for iOS application

Postby ukrsms » Thu Sep 05, 2019 3:44 pm

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

newsettler_AI
Posts: 121
Joined: Wed Apr 05, 2017 12:49 pm

Re: Change BLE default MTU for iOS application

Postby newsettler_AI » Fri Sep 06, 2019 11:58 am

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...

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Change BLE default MTU for iOS application

Postby chegewara » Fri Sep 06, 2019 12:44 pm

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.

Who is online

Users browsing this forum: No registered users and 121 guests