-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
mcumgr: smp_bt: wrong notify MTU calculation with CONFIG_BT_GATT_NOTIFY_MULTIPLE #26106
Comments
@de-nordic can you please take a look? |
@LeBlue Thank you for a detailed bug-report. The new GATT feature notify multiple should not break the API in this way. I have created a fix that sets it as default off, since it changes the behavior in a way that breaks existing applications. |
@joerchan The question remains if the |
@LeBlue Yes if you wish to use GATT NOTIFY MULTIPLE. But there does not appear to be a good way for the application to determine if notify multiple will be used. We need to expose this information to the application in some way. |
Hardcoding -3 is also a bad idea, because applications may actually want to set notify multiple then that would be broken anyway, so perhaps having a check fo IS_ENABLED(CONFIG_BT_GATT_NOTIFY_MULTIPLE) return mtu - 5; instead, but Im afraid we really want a runtime option if the application want to use the entire payload for doing streaming, but that would probably need an API change so the stack can avoid the grouping logic. |
When CONFIG_BT_GATT_NOTIFY_MULTIPLE is selected and the remote has enabled support for using its procedure data can sometimes not fit into the buffer since the multiple variant has a bigger header, so instead of failing immediatelly this attempts to send the data using the legacy PDU instead so those using bt_gatt_get_mtu - 3 can still be sent. Fixes zephyrproject-rtos#26106 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When CONFIG_BT_GATT_NOTIFY_MULTIPLE is selected and the remote has enabled support for using its procedure data can sometimes not fit into the buffer since the multiple variant has a bigger header, so instead of failing immediatelly this attempts to send the data using the legacy PDU instead so those using bt_gatt_get_mtu - 3 can still be sent. Fixes #26106 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
But there is an MTU per L2CAP channel. I think the best is to leave it as is, MTU - 3 would give the best throughput when the application wants to send large data. The notify multiple seems to be best suited for many small notify values. |
Describe the bug
It is probably not the source of the bug, but currently the MTU calculation for fragmentet bt_smp packets fails to calculate the correct avaliable data length. The length is calculated as
MTU - 3
zephyr/subsys/mgmt/smp_bt.c
Line 136 in 1b1d728
but
bt_gatt_notify
needs 5 additional bytes instead of 3 if CONFIG_BT_GATT_NOTIFY_MULTIPLE is set.zephyr/subsys/bluetooth/host/gatt.c
Line 1721 in 1b1d728
Discovered with the mcumgr image list command that generates a response of length 258, when both slots are used (see below for patch with additional log messages).
I assume the bug is actually using the
gatt_notify_mult
, even thoughbt_gatt_notify
is called with the conn obj inzephyr/subsys/mgmt/smp_bt.c
Line 101 in 1b1d728
Workarounds
mtu - 3
tomtu - 5
inbt_smp.c:smp_bt_get_mtu
To Reproduce
Steps to reproduce the behavior:
Expected behavior
bt_smp does not (always) fail to send notifications/command responses
Impact
None for me, as single connection only does not need notify multiple. Otherwise pretty bad.
Screenshots or console output
or
Environment (please complete the following information):
Additional context
Changes for logging:
The text was updated successfully, but these errors were encountered: