Bluetooth: Audio: Shell: adds support for BIS index parameter

When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.

If setting BIS index which the BASE does not support, then the
command should be rejected.

This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835

Signed-off-by: Ping Wang <pinw@demant.com>
This commit is contained in:
Ping Wang 2024-04-26 08:43:40 +02:00 committed by Fabio Baltieri
commit 6a027634cd
2 changed files with 20 additions and 1 deletions

View file

@ -810,6 +810,7 @@ static inline bool add_pa_sync_base_subgroup_cb(const struct bt_bap_base_subgrou
ret = bt_bap_base_subgroup_foreach_bis(subgroup, add_pa_sync_base_subgroup_bis_cb,
subgroup_param);
if (ret < 0) {
return false;
}
@ -848,6 +849,8 @@ static int cmd_bap_broadcast_assistant_add_pa_sync(const struct shell *sh,
param.adv_sid = pa_info.sid;
param.pa_interval = pa_info.interval;
memset(&subgroup_params, 0, sizeof(subgroup_params));
param.pa_sync = shell_strtobool(argv[1], 0, &err);
if (err != 0) {
shell_error(sh, "Could not parse pa_sync: %d", err);
@ -900,6 +903,22 @@ static int cmd_bap_broadcast_assistant_add_pa_sync(const struct shell *sh,
}
}
/* use the BASE to verify the BIS indexes set by command */
for (size_t j = 0U; j < param.num_subgroups; j++) {
if (bis_bitfield_req == 0) {
/* Not set the BIS indexes by command, use BASE directly */
break;
} else if ((subgroup_params[j].bis_sync & bis_bitfield_req) != 0) {
subgroup_params[j].bis_sync &= bis_bitfield_req;
} else {
/* Command is rejected when BASE does not support BIS index in command */
shell_error(ctx_shell, "Cannot set BIS index 0x%06X when BASE subgroup %d "
"only supports %d", bis_bitfield_req, j,
subgroup_params[j].bis_sync);
return -ENOEXEC;
}
}
err = bt_bap_broadcast_assistant_add_src(default_conn, &param);
if (err != 0) {
shell_print(sh, "Fail: %d", err);