diff --git a/include/bluetooth/audio/csis.h b/include/bluetooth/audio/csis.h index 1e954bf01cc..d609ef74089 100644 --- a/include/bluetooth/audio/csis.h +++ b/include/bluetooth/audio/csis.h @@ -292,14 +292,15 @@ void bt_csis_client_register_cb(struct bt_csis_client_cb *cb); /** * @brief Read the lock value of a specific device and instance. - * - * @param conn Pointer to the connection to the device. - * @param inst_idx Index of the CSIS index of the peer device (as it may have - * multiple CSIS instances). + + * @param members Member to get the lock value from + * @param set Pointer to the specific set of the @p member to get the + * lock value from. * * @return Return 0 on success, or an errno value on error. */ -int bt_csis_client_lock_get(struct bt_conn *conn, uint8_t inst_idx); +int bt_csis_client_lock_get(struct bt_csis_client_set_member *member, + const struct bt_csis_client_set *set); /** * @brief Lock an array of set members diff --git a/subsys/bluetooth/audio/csis_client.c b/subsys/bluetooth/audio/csis_client.c index 698a4b02fcd..239cdb76ec6 100644 --- a/subsys/bluetooth/audio/csis_client.c +++ b/subsys/bluetooth/audio/csis_client.c @@ -1195,25 +1195,23 @@ int bt_csis_client_discover_sets(struct bt_csis_client_set_member *member) return err; } -int bt_csis_client_lock_get(struct bt_conn *conn, uint8_t inst_idx) +int bt_csis_client_lock_get(struct bt_csis_client_set_member *member, + const struct bt_csis_client_set *set) { int err; - if (inst_idx >= CONFIG_BT_CSIS_CLIENT_MAX_CSIS_INSTANCES) { - BT_DBG("Invalid index %u", inst_idx); - return -EINVAL; - } else if (busy) { + if (busy) { BT_DBG("csis_client busy"); return -EBUSY; } else if (cur_inst != NULL) { - if (cur_inst != lookup_instance_by_index(conn, inst_idx)) { + if (cur_inst != set->csis) { BT_DBG("csis_client busy with current instance"); return -EBUSY; } } else { - cur_inst = lookup_instance_by_index(conn, inst_idx); + cur_inst = set->csis; if (cur_inst == NULL) { - BT_DBG("Inst not found"); + BT_DBG("set->csis is NULL"); return -EINVAL; } } @@ -1229,7 +1227,7 @@ int bt_csis_client_lock_get(struct bt_conn *conn, uint8_t inst_idx) read_params.single.handle = cur_inst->cli.set_lock_handle; read_params.single.offset = 0U; - err = bt_gatt_read(conn, &read_params); + err = bt_gatt_read(member->conn, &read_params); if (err != 0) { cur_inst = NULL; diff --git a/subsys/bluetooth/shell/csis_client.c b/subsys/bluetooth/shell/csis_client.c index 17ea7d658f3..1418077c553 100644 --- a/subsys/bluetooth/shell/csis_client.c +++ b/subsys/bluetooth/shell/csis_client.c @@ -419,8 +419,8 @@ static int cmd_csis_client_lock_get(const struct shell *sh, size_t argc, } } - err = bt_csis_client_lock_get(set_members[member_index].conn, - (uint8_t)idx); + err = bt_csis_client_lock_get(&set_members[member_index], + &set_members[member_index].sets[idx]); if (err != 0) { shell_error(sh, "Fail: %d", err); }