Bluetooth: Audio: VCS register return if already registered

Change how bt_vcs_register works if VCS has already been
registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-05-31 15:07:13 +02:00 committed by Carles Cufí
parent 0043c741a5
commit 946013e25f
2 changed files with 8 additions and 0 deletions

View File

@ -81,6 +81,7 @@ struct bt_vcs_included {
*
* @param param Volume Control Service register parameters.
* @param[out] vcs Pointer to the registered Volume Control Service.
* This will still be valid if the return value is -EALREADY.
*
* @return 0 if success, errno on failure.
*/

View File

@ -359,8 +359,14 @@ static int prepare_aics_inst(struct bt_vcs_register_param *param)
/****************************** PUBLIC API ******************************/
int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs)
{
static bool registered;
int err;
if (registered) {
*vcs = &vcs_inst;
return -EALREADY;
}
vcs_svc = (struct bt_gatt_service)BT_GATT_SERVICE(vcs_attrs);
if (CONFIG_BT_VCS_VOCS_INSTANCE_COUNT > 0) {
@ -392,6 +398,7 @@ int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs)
vcs_inst.srv.cb = param->cb;
*vcs = &vcs_inst;
registered = true;
return err;
}