Skip to content

Commit 7db1d19

Browse files
committed
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 <[email protected]>
1 parent ed01ff4 commit 7db1d19

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

include/zephyr/bluetooth/audio/bap.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,17 +1982,24 @@ struct bt_bap_unicast_client_cb {
19821982
/**
19831983
* @brief Register unicast client callbacks.
19841984
*
1985-
* Only one callback structure can be registered, and attempting to
1986-
* registering more than one will result in an error.
1987-
*
1988-
* @param cb Unicast client callback structure.
1985+
* @param cb Unicast client callback structure to register.
19891986
*
19901987
* @retval 0 Success
19911988
* @retval -EINVAL @p cb is NULL.
19921989
* @retval -EEXIST @p cb is already registered.
19931990
*/
19941991
int bt_bap_unicast_client_register_cb(struct bt_bap_unicast_client_cb *cb);
19951992

1993+
/**
1994+
* @brief Unregister unicast client callbacks.
1995+
*
1996+
* @param cb Unicast client callback structure to unregister.
1997+
*
1998+
* @retval 0 Success
1999+
* @retval -EINVAL @p cb is NULL or @p cb was not registered
2000+
*/
2001+
int bt_bap_unicast_client_unregister_cb(struct bt_bap_unicast_client_cb *cb);
2002+
19962003
/**
19972004
* @brief Discover remote capabilities and endpoints
19982005
*

subsys/bluetooth/audio/bap_unicast_client.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,3 +4720,18 @@ int bt_bap_unicast_client_register_cb(struct bt_bap_unicast_client_cb *cb)
47204720

47214721
return 0;
47224722
}
4723+
4724+
int bt_bap_unicast_client_unregister_cb(struct bt_bap_unicast_client_cb *cb)
4725+
{
4726+
if (cb == NULL) {
4727+
LOG_DBG("cb was NULL");
4728+
return -EINVAL;
4729+
}
4730+
4731+
if (!sys_slist_find_and_remove(&unicast_client_cbs, &cb->_node)) {
4732+
LOG_DBG("cb was not registered");
4733+
return -EALREADY;
4734+
}
4735+
4736+
return 0;
4737+
}

0 commit comments

Comments
 (0)