nordic: fix BLE MTU negotation #9441
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #9440 for test programs.
Debugged by looking at packet traces with nRF sniffer and printing out SD BLE events. The symptoms were that the connection and discovery seemed fine, but the notification events,
BLE_GATTC_EVT_HVX
, never arrived at the event handler inCharacteristic.c
. After a few seconds the connection was broken.MTU negotiation seemed fine, but someone reported something slightly similar in Nordic DevZone, and the suggested problem was that some negotiation had failed between the peers. I added
nrf_check_error()
to a few calls, and found they were failing. The details have to do with the permitted MTU values, and are in the code comments.Tested on nRF central <-> ESP32-S3 peripheral, and also vetted that nrRF<-> nRF still works.
The original failures occurred because nRF preferred an MTU of size 512, and ESP preferred 256. There was no problem nRF-to-nRF because there, both sides chose 512.
I encountered at least one other issue I'll look at as well, which is not related to this particular problem.
I added debug code to print the
evt
names, which were otherwise painful to look up.