-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setMTU function to BLEClient.cpp/.h #4999
Conversation
Instead of duplicating all the code, why not just call |
the setMTU function in BLEDevice specifically says it only sets the local copy. I didn't think modifying it to also set the remote copy would be a good idea as there may be code out there dependent upon it only setting the local copy. |
The MTU is determined based on the lowest value between the connecting devices. In this library all you need to do is set the local MTU once before connecting to a peer device and the MTU gets negotiated after the connection is established, this happens automatically (you can see the code that does this in the client on connected event handler). After that there is nothing to be done. The local preferred MTU is a global setting for all connections so you could simple set it once to the max (517) and the actual used MTU will be determined at connection. |
You can set local MTU from BLEDevice, then after connecting to peripheral just call |
I tried setting the MTU value before connection and it didn't set it on the device, the device refused to respond with data...once I added the call to esp_ble_gattc_send_mtu_req the device would respond with packets. |
I must apologize, I was not looking at this repos code and instead basing it on cpp_utils that this came from. In this code base the call to exchange MTU is not automatic on connection so I withdraw my previous comment. Considering this fact I would think it better to change the code in this PR to just call the BLEDevice method then call the MTU exchange function save a few bytes instead. Alternatively, pulling the code from cpp_utils would be more seamless. |
Pull request espressif#4999 added setMTU function to BLEClient.cpp/.h, this line provides implementation of this added functionality to the BLE client example to resolve cases in which data from notifyCallback exceeds 20 characters (3 bytes for command type and attribute ID, 20 bytes for attribute data (char*)pData).
Pull request #4999 added setMTU function to BLEClient.cpp/.h, this line provides implementation of this added functionality to the BLE client example to resolve cases in which data from notifyCallback exceeds 20 characters (3 bytes for command type and attribute ID, 20 bytes for attribute data (char*)pData).
The current implementation has a getMTU function which returns the mtu sent in a message.
This function allows you to set the MTU value on the connected device, it first sets the MTU locally by calling esp_ble_gatt_set_local_mtu. It then calls esp_ble_gattc_send_mtu_req to have the connected device also change its MTU size.