Skip to content

Commit 5ce5940

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: CSIP: Fix issue with ordered access without lock char
Fixed issue when performing the ordered access procedure on a set of devices where none had the lock characteristics. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 65808bb commit 5ce5940

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

subsys/bluetooth/audio/csip_set_coordinator.c

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,19 +1530,40 @@ static int bt_csip_set_coordinator_get_lock_state(
15301530

15311531
active_members_store_ordered(members, count, set_info, true);
15321532

1533-
cur_inst = lookup_instance_by_set_info(active.members[0], active.info);
1534-
if (cur_inst == NULL) {
1535-
LOG_DBG("Failed to lookup instance by set_info %p", active.info);
1533+
for (uint8_t i = 0U; i < count; i++) {
1534+
cur_inst = lookup_instance_by_set_info(active.members[i], active.info);
1535+
if (cur_inst == NULL) {
1536+
LOG_DBG("Failed to lookup instance by set_info %p", active.info);
15361537

1537-
active_members_reset();
1538-
return -ENOENT;
1538+
active_members_reset();
1539+
return -ENOENT;
1540+
}
1541+
1542+
if (cur_inst->set_info->lockable) {
1543+
err = csip_set_coordinator_read_set_lock(cur_inst);
1544+
if (err == 0) {
1545+
busy = true;
1546+
} else {
1547+
cur_inst = NULL;
1548+
}
1549+
1550+
break;
1551+
}
1552+
1553+
active.members_handled++;
15391554
}
15401555

1541-
err = csip_set_coordinator_read_set_lock(cur_inst);
1542-
if (err == 0) {
1543-
busy = true;
1544-
} else {
1545-
cur_inst = NULL;
1556+
if (!busy && err == 0) {
1557+
/* We are not reading any lock states (because they are not on the remote devices),
1558+
* so we can just initiate the ordered access procedure (oap) callback directly
1559+
* here.
1560+
*/
1561+
1562+
if (!active.oap_cb(active.info, active.members, active.members_count)) {
1563+
err = -ECANCELED;
1564+
}
1565+
1566+
ordered_access_complete(active.info, err, false, NULL);
15461567
}
15471568

15481569
return err;
@@ -1556,14 +1577,16 @@ int bt_csip_set_coordinator_ordered_access(
15561577
{
15571578
int err;
15581579

1580+
/* wait for the get_lock_state to finish and then call the callback */
1581+
active.oap_cb = cb;
1582+
15591583
err = bt_csip_set_coordinator_get_lock_state(members, count, set_info);
15601584
if (err != 0) {
1585+
active.oap_cb = NULL;
1586+
15611587
return err;
15621588
}
15631589

1564-
/* wait for the get_lock_state to finish and then call the callback */
1565-
active.oap_cb = cb;
1566-
15671590
return 0;
15681591
}
15691592

0 commit comments

Comments
 (0)