I am experiencing an issue with writing to a BLE characteristic from Android. I have an ESP-WROOM-32 dev board and am using esp-idf version 3.1. After negotiating an MTU higher than the default value a write operation with more than 20 bytes fails. From the Android client side the write succeeds, however from the esp32 side there is no event received. Instead a disconnect event occurs with reason code 0x13: Timeout. This only effects specific Android models. Pixel 3, and Pixel 4 both work as expected. Samsung s9 and Samsung s10 running Android 10 fail as described. Its worth noting that writes of 18 bytes or fewer will succeed (this is the default MTU minus some overhead). Also, IOS is able to negotiate an MTU and write larger packets without issue.
The gatt server demo included with esp-idf can be used to reproduce the issue. I have so far made two modifications.
When starting bluetooth I call a method to change the local mtu which allows the client (Android Phone) to negotiate a higher mtu.
Code: Select all
esp_ble_gatt_set_local_mtu(500);
Code: Select all
esp_ble_conn_update_params_t conn_params = {0};
memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
conn_params.latency = 0;
conn_params.max_int = 0x20; // max_int = 0x20*1.25ms = 40ms
conn_params.min_int = 0x10; // min_int = 0x10*1.25ms = 20ms
conn_params.timeout = 400; // timeout = 400*10ms = 4000ms
esp_ble_gap_update_conn_params(&conn_params);
I will try updating to esp-idf v4 to see if that resolves the issue. I'm wondering if anyone else has experienced a similar issue and been able to resolve it.
Edit:
Since originally positing I have updated to esp-idf v4.0. I still experience the same behavior with Samsung devices.