Bluetooth: attr->user_data is NULL when doing discovery with BT_GATT_DISCOVER_ATTRIBUTE #45172
Labels
area: Bluetooth Audio
area: Bluetooth Host
area: Bluetooth
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Describe the bug
Changing the discovery type from BT_GATT_DISCOVER_CHARACTERISTIC to BT_GATT_DISCOVER_ATTRIBUTE results in the attr->user_data for discovered characteristics being NULL in the discovery callback.
A clear and concise description of what the bug is.
I have the following code in a discovery callback:
If the discovery is called with BT_GATT_DISCOVER_CHARACTERISTIC, this gives results as follows:
If instead the discovery is called with BT_GATT_DISCOVER_ATTRIBUTE, the results are:
Note that the attr->user_data is NULL. (And de-referencing it of course gives meaningless results.)
Please also mention any information which could help others to understand
the problem you're facing:
nRF52840
The two different types of discovery have different implementations - one uses
gatt_find_info()
, the othergatt_read_type()
.Additional info from @Emil-Gydesen-Bose
The only place we use BT_GATT_DISCOVER_ATTRIBUTE is the BT shell, and that only prints attr->uuid and never casts the results.
BT_GATT_DISCOVER_ATTRIBUTE is furthermore the only place where gatt_find_info (and consequently gatt_find_info_rsp) is called
For BT_GATT_DISCOVER_CHARACTERISTIC we do
when constructing the callback data, but for BT_GATT_DISCOVER_ATTRIBUTE we only do
To Reproduce
Steps to reproduce the behavior:
Check out https://github.com/asbjornsabo/zephyr/tree/mcc_discovery_bug
(This is very close to zephyr main)
Build the bluetooth shell with the audio configuration file:
zephyrproject/zephyr/tests/bluetooth/shell$ rm -rf build && cmake -H. -Bbuild -GNinja -DBOARD=nrf52840dk_nrf52840 -DCONF_FILE=audio.conf
zephyrproject/zephyr/tests/bluetooth/shell$ cd build/ && ninja
Run on two nRF5240 kits, initialize bt, mcc and mpl, connect, run
mcc discover_mcs
command.Expected behavior
A clear and concise description of what you expected to happen.
I'd expect
To work the same regardless of the type of discovery as long as attr->uuid == BT_UUID_GATT_CHRC
Impact
What impact does this issue have on your progress (e.g., annoyance, showstopper)
Right now: Hindering my rewrite of the discovery to enqueue fewer subscriptions at a time so that it does not fail.
In principle: Inconsistent and undocumented behavior in callbacks. Not possible to discover characteristics and CCCDs in same discovery (?).
Environment (please complete the following information):
OS: (e.g. Linux, MacOS, Windows)
Linux
Toolchain (e.g Zephyr SDK, ...)
Zephyr SDK
Commit SHA or Version used
asbjornsabo@421e179
from branch given above
The text was updated successfully, but these errors were encountered: