esp32-snippets icon indicating copy to clipboard operation
esp32-snippets copied to clipboard

unable to set MTU on an ESP32 BLE client

Open dansoskin1 opened this issue 4 years ago • 1 comments

couldnt find a solution for my problem

im trying to communicate with 2 esp32s over BLE using notify, but unable to send data over 20 bytes long ive read that i should use BLEDevice::setMTU(500) function on the client side, right after the BLEDevice::init("") function. that doesnt seem to make a difference.

the code i use is taken straight from the BLE examples (arduino IDE), both server and client,

on the client side, the only thing i changed is the setMTU right after the init function

on the server i just changed the notification part to: String val = "abcdefghijklmnopqrstuvwxyz"; pCharacteristic->setValue((uint8_t *)val.c_str(), val.length()); pCharacteristic->notify();

weird thing is that when i connect to the server using the nrf, im able to request MTU and then able to receive the whole packet but on the esp32 client it doesnt seem to make a difference and the i only receive 20 bytes

what am i missing? what am i doing wrong? im using arduino IDE, that should work fine, right?

dansoskin1 avatar Aug 02 '21 14:08 dansoskin1

You have to send MTU request after connecting on ble client. The function is missing in this library but is implemented in arduino-esp32: https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEClient.h#L60

chegewara avatar Aug 13 '21 16:08 chegewara