Skip to content

Commit 02d0e96

Browse files
Thalleyjhedberg
authored andcommitted
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 d4d51dc commit 02d0e96

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
@@ -1967,17 +1967,24 @@ struct bt_bap_unicast_client_cb {
19671967
/**
19681968
* @brief Register unicast client callbacks.
19691969
*
1970-
* Only one callback structure can be registered, and attempting to
1971-
* registering more than one will result in an error.
1972-
*
1973-
* @param cb Unicast client callback structure.
1970+
* @param cb Unicast client callback structure to register.
19741971
*
19751972
* @retval 0 Success
19761973
* @retval -EINVAL @p cb is NULL.
19771974
* @retval -EEXIST @p cb is already registered.
19781975
*/
19791976
int bt_bap_unicast_client_register_cb(struct bt_bap_unicast_client_cb *cb);
19801977

1978+
/**
1979+
* @brief Unregister unicast client callbacks.
1980+
*
1981+
* @param cb Unicast client callback structure to unregister.
1982+
*
1983+
* @retval 0 Success
1984+
* @retval -EINVAL @p cb is NULL or @p cb was not registered
1985+
*/
1986+
int bt_bap_unicast_client_unregister_cb(struct bt_bap_unicast_client_cb *cb);
1987+
19811988
/**
19821989
* @brief Discover remote capabilities and endpoints
19831990
*

subsys/bluetooth/audio/bap_unicast_client.c

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

46854685
return 0;
46864686
}
4687+
4688+
int bt_bap_unicast_client_unregister_cb(struct bt_bap_unicast_client_cb *cb)
4689+
{
4690+
if (cb == NULL) {
4691+
LOG_DBG("cb was NULL");
4692+
return -EINVAL;
4693+
}
4694+
4695+
if (!sys_slist_find_and_remove(&unicast_client_cbs, &cb->_node)) {
4696+
LOG_DBG("cb was not registered");
4697+
return -EALREADY;
4698+
}
4699+
4700+
return 0;
4701+
}

0 commit comments

Comments
 (0)