From 5b5787fa54d4e52ff96dd3a6815c6529b9be78e0 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Tue, 30 Sep 2025 15:31:26 +0200 Subject: [PATCH 1/2] Bluetooth: BAP: Add bt_bap_unicast_client_unregister_cb Add bt_bap_unicast_client_unregister_cb to unregister BAP unicast client callbacks. This is required for unittests to clean up between runs. Signed-off-by: Emil Gydesen --- include/zephyr/bluetooth/audio/bap.h | 15 +++++++++++---- subsys/bluetooth/audio/bap_unicast_client.c | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/zephyr/bluetooth/audio/bap.h b/include/zephyr/bluetooth/audio/bap.h index d480837c97138..ef994cc050189 100644 --- a/include/zephyr/bluetooth/audio/bap.h +++ b/include/zephyr/bluetooth/audio/bap.h @@ -1967,10 +1967,7 @@ struct bt_bap_unicast_client_cb { /** * @brief Register unicast client callbacks. * - * Only one callback structure can be registered, and attempting to - * registering more than one will result in an error. - * - * @param cb Unicast client callback structure. + * @param cb Unicast client callback structure to register. * * @retval 0 Success * @retval -EINVAL @p cb is NULL. @@ -1978,6 +1975,16 @@ struct bt_bap_unicast_client_cb { */ int bt_bap_unicast_client_register_cb(struct bt_bap_unicast_client_cb *cb); +/** + * @brief Unregister unicast client callbacks. + * + * @param cb Unicast client callback structure to unregister. + * + * @retval 0 Success + * @retval -EINVAL @p cb is NULL or @p cb was not registered + */ +int bt_bap_unicast_client_unregister_cb(struct bt_bap_unicast_client_cb *cb); + /** * @brief Discover remote capabilities and endpoints * diff --git a/subsys/bluetooth/audio/bap_unicast_client.c b/subsys/bluetooth/audio/bap_unicast_client.c index cbbc56088740b..05aa9ca08f218 100644 --- a/subsys/bluetooth/audio/bap_unicast_client.c +++ b/subsys/bluetooth/audio/bap_unicast_client.c @@ -4684,3 +4684,18 @@ int bt_bap_unicast_client_register_cb(struct bt_bap_unicast_client_cb *cb) return 0; } + +int bt_bap_unicast_client_unregister_cb(struct bt_bap_unicast_client_cb *cb) +{ + if (cb == NULL) { + LOG_DBG("cb was NULL"); + return -EINVAL; + } + + if (!sys_slist_find_and_remove(&unicast_client_cbs, &cb->_node)) { + LOG_DBG("cb was not registered"); + return -EALREADY; + } + + return 0; +} From 25178bada65e636a63bf873267212f89283030a5 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Tue, 30 Sep 2025 16:11:29 +0200 Subject: [PATCH 2/2] doc: releases: Add entry for bt_bap_unicast_client_unregister_cb Add entry for new function bt_bap_unicast_client_unregister_cb. Signed-off-by: Emil Gydesen --- doc/releases/release-notes-4.3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/releases/release-notes-4.3.rst b/doc/releases/release-notes-4.3.rst index b7a137c68cf84..79b096069b054 100644 --- a/doc/releases/release-notes-4.3.rst +++ b/doc/releases/release-notes-4.3.rst @@ -118,6 +118,7 @@ New APIs and options * :c:struct:`bt_bap_stream` now contains an ``iso`` field as a reference to the ISO channel * :c:func:`bt_bap_unicast_group_get_info` * :c:func:`bt_cap_unicast_group_get_info` + * :c:func:`bt_bap_unicast_client_unregister_cb` * Host