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

only 20bytes are transmitted when subscribing to a charactersitic

Open max763 opened this issue 4 years ago • 8 comments

I can read from the esp32 more than 20bytes on client side but when I subscribe only the first 20bytes are shown. Is there a restriction within the library or do I have to search rather on client side? regards max

max763 avatar Jan 19 '21 12:01 max763

This is ble specific restriction which is MTU - 3 bytes.

chegewara avatar Jan 19 '21 12:01 chegewara

thanks for the fast response. But should't this apply for reading the characteristic as well? But I can get more than 20bytes except when notifying the subscriber.

I've also set MTU to 92 BLEDevice::init("ESP32_BLE"); BLEDevice::setMTU(92);

max763 avatar Jan 19 '21 12:01 max763

No, reading is MTU - 1 if i remember correctly.

setMTU is only local value set, if peer device does not support it then only default 23 bytes mtu is used.

chegewara avatar Jan 19 '21 12:01 chegewara

but I have tested to read more than 60 bytes successfully with the device. only when subscribing I get not more than 20

max763 avatar Jan 19 '21 12:01 max763

This is how ble works. When you are reading then few packets are read and merged. You dont see it, but it is how it works. You can accept the answer or try to search with google or even in this repository. There is many similar issues/questions and answer is always the same.

chegewara avatar Jan 19 '21 12:01 chegewara

ok. understood. read is merged and not bound to MTU but subscription is. thanks

max763 avatar Jan 19 '21 13:01 max763

Read also is affected by MTU, it is much slower with low MTU, just with read you will get full message.

chegewara avatar Jan 19 '21 13:01 chegewara

so I have to find the reason why MTU is not increased on both sides

max763 avatar Jan 19 '21 13:01 max763