Bluetooth: CSIS: Refactor bt_csis_client_lock_get to use member
Refactor the bt_csis_client_lock_get function to use a pointer to a member and a set instead of a bt_conn pointer and an index. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
bb5b1901fd
commit
170d094ca8
3 changed files with 15 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue