-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Bluetooth: Host: bt_gatt_cb.att_mtu_updated only called when MTU exchange completes #67858
Bluetooth: Host: bt_gatt_cb.att_mtu_updated only called when MTU exchange completes #67858
Conversation
e82a864
to
5b28e24
Compare
samples/bluetooth/mtu_update/peripheral/src/peripheral_mtu_update.c
Outdated
Show resolved
Hide resolved
5b28e24
to
731b5d4
Compare
@Thalley thanks for your feedback! I've addressed the following changes:
Follow-up Actions:
|
I propose adding more test cases to nail down the behavior:
What do you think? |
@alwa-nordic Sounds good. I'll capture them in the tests! |
731b5d4
to
b24fe02
Compare
Per issue zephyrproject-rtos#64172, `att_mtu_updated` is expected to only notify once the MTU exchange has taken place in a Bluetooth connection, and not once connection is established. This allows each GATT profile to use this callback as a way to be signaled when higher MTU is available, which is expected to occur once per connection. There is the exception for EATT L2CAP channels, where an MTU exchange takes place at the L2CAP level, during ATT connection establishment. Signed-off-by: Luis Ubieda <[email protected]>
Now is not triggered upon connection establishment. Signed-off-by: Luis Ubieda <[email protected]>
Previously this sample verified the MTU exchange in an indirect manner by being able to send a larger notification size. Now this adjustment allows directly verifying both on the Central and the Peripheral that the expected MTU exchange takes place, and that the listeners subscribed through `bt_gatt_cb_register` are notified when this exchange takes place (once per connection). Signed-off-by: Luis Ubieda <[email protected]>
b24fe02
to
08e9a29
Compare
* The handler `att_mtu_updated` registered over the :c:func:`bt_gatt_cb_register` | ||
API is no longer triggered upon connection establishment. It is now only | ||
called when the MTU exchange has taken place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still called on EATT connection establishment though
if (info.role == BT_CONN_ROLE_CENTRAL) { | ||
(void)mtu_exchange(conn); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems superfluous to guard a function call with BT_CONN_ROLE_CENTRAL
in a central sample.
Furthermore, both the central and peripheral is allowed to do the MTU exchange
if (central_mtu_count == 1 && | ||
central_mtu_tx == expected_mtu && | ||
central_mtu_rx == expected_mtu) { | ||
PASS("MTU Update test passed [Central]\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some indentation is off here
if (peripheral_mtu_count == 1 && | ||
peripheral_mtu_tx == expected_mtu && | ||
peripheral_mtu_rx == expected_mtu) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some indentation is off here
if (peripheral_mtu_count == 1 && | |
peripheral_mtu_tx == expected_mtu && | |
peripheral_mtu_rx == expected_mtu) { | |
if (peripheral_mtu_count == 1 && | |
peripheral_mtu_tx == expected_mtu && | |
peripheral_mtu_rx == expected_mtu) { |
FAIL("MTU Update test failed [Central] - Count: %u, MTU RX: %u, MTU TX: %u\n", | ||
central_mtu_count, central_mtu_rx, central_mtu_tx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAIL("MTU Update test failed [Central] - Count: %u, MTU RX: %u, MTU TX: %u\n", | |
central_mtu_count, central_mtu_rx, central_mtu_tx); | |
FAIL("MTU Update test failed [Central] - Count: %u, MTU RX: %u, MTU TX: %u\n", | |
central_mtu_count, central_mtu_rx, central_mtu_tx); |
FAIL("MTU Update test failed [Peripheral] - Count: %u, MTU RX: %u, MTU TX: %u\n", | ||
peripheral_mtu_count, peripheral_mtu_rx, peripheral_mtu_tx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAIL("MTU Update test failed [Peripheral] - Count: %u, MTU RX: %u, MTU TX: %u\n", | |
peripheral_mtu_count, peripheral_mtu_rx, peripheral_mtu_tx); | |
FAIL("MTU Update test failed [Peripheral] - Count: %u, MTU RX: %u, MTU TX: %u\n", | |
peripheral_mtu_count, peripheral_mtu_rx, peripheral_mtu_tx); |
uint8_t notify_data[100] = {}; | ||
uint8_t is_data_equal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to remove the notification part of the test?
Wouldn't it make sense to both verify the MTU values and verify the notification length?
@ubieda sorry for the super-short notice, but do you want to join the meeting today (in an hour or so) to discuss this PR? |
@jori-nordic Yeah - I'll see y'all in a few minutes! |
Just to capture current status on this PR: It's marked as blocked on #68107. Once that is addressed, we can re-evaluate this PR and follow-up with the change-requests. |
* The handler `att_mtu_updated` registered over the :c:func:`bt_gatt_cb_register` | ||
API is no longer triggered upon connection establishment. It is now only | ||
called when the MTU exchange has taken place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to go into the migration guide for v3.7.0 instead.
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
@Thalley @jori-nordic feel free to close if, after the latest changes in the BT Stack, this work needs to be restarted / no longer a suitable approach. |
Yeah let's close it. It's linked to the RFC issue, so we can always go back and re-open it later. |
This PR attempts to address #64172, by issuing the following changes:
bt_gatt_cb.att_mtu_updated
is only called when the MTU exchange is completed (only once per connection).tests/bsim/bluetooth/host/att/mtu_update
to directly verify MTU exchange takes place both on Central and Peripheral.att_mu_updated
as it was previously also triggered upon connection establishment (before MTU exchange).NOTE:
att_mtu_updated
is not triggered if an MTU exchange results in anATT_ERROR_RSP
(e.g: Not supported). There's a comment on the issue whether that should also result in callingatt_mtu_updated
.Status on PR Actionable Items:
att_mtu_updated
callback.