esp32-snippets
esp32-snippets copied to clipboard
unable to set MTU on an ESP32 BLE client
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?
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