Skip to content

Commit 4b30370

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 549bc7a commit 4b30370

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
@@ -4719,3 +4719,18 @@ int bt_bap_unicast_client_register_cb(struct bt_bap_unicast_client_cb *cb)
47194719

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

0 commit comments

Comments
 (0)