bluetooth: CSIP: Add API to get service handles
This is needed for upper tester. Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
This commit is contained in:
parent
4c9d644680
commit
43d830082c
2 changed files with 34 additions and 30 deletions
|
@ -21,5 +21,30 @@ struct bt_csip_set_sirk {
|
||||||
uint8_t value[BT_CSIP_SET_SIRK_SIZE];
|
uint8_t value[BT_CSIP_SET_SIRK_SIZE];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
struct bt_csip_set_coordinator_svc_inst *bt_csip_set_coordinator_lookup_instance_by_index(
|
||||||
|
const struct bt_conn *conn, uint8_t idx);
|
||||||
|
|
||||||
|
struct bt_csip_set_coordinator_svc_inst {
|
||||||
|
uint8_t set_lock;
|
||||||
|
|
||||||
|
uint16_t start_handle;
|
||||||
|
uint16_t end_handle;
|
||||||
|
uint16_t set_sirk_handle;
|
||||||
|
uint16_t set_size_handle;
|
||||||
|
uint16_t set_lock_handle;
|
||||||
|
uint16_t rank_handle;
|
||||||
|
|
||||||
|
uint8_t idx;
|
||||||
|
struct bt_gatt_subscribe_params sirk_sub_params;
|
||||||
|
struct bt_gatt_discover_params sirk_sub_disc_params;
|
||||||
|
struct bt_gatt_subscribe_params size_sub_params;
|
||||||
|
struct bt_gatt_discover_params size_sub_disc_params;
|
||||||
|
struct bt_gatt_subscribe_params lock_sub_params;
|
||||||
|
struct bt_gatt_discover_params lock_sub_disc_params;
|
||||||
|
|
||||||
|
struct bt_conn *conn;
|
||||||
|
struct bt_csip_set_coordinator_set_info *set_info;
|
||||||
|
};
|
||||||
|
|
||||||
struct bt_csip_set_coordinator_csis_inst *bt_csip_set_coordinator_csis_inst_by_handle(
|
struct bt_csip_set_coordinator_csis_inst *bt_csip_set_coordinator_csis_inst_by_handle(
|
||||||
struct bt_conn *conn, uint16_t start_handle);
|
struct bt_conn *conn, uint16_t start_handle);
|
||||||
|
|
|
@ -49,28 +49,6 @@ static struct bt_gatt_discover_params discover_params;
|
||||||
static struct bt_csip_set_coordinator_svc_inst *cur_inst;
|
static struct bt_csip_set_coordinator_svc_inst *cur_inst;
|
||||||
static bool busy;
|
static bool busy;
|
||||||
|
|
||||||
struct bt_csip_set_coordinator_svc_inst {
|
|
||||||
uint8_t set_lock;
|
|
||||||
|
|
||||||
uint16_t start_handle;
|
|
||||||
uint16_t end_handle;
|
|
||||||
uint16_t set_sirk_handle;
|
|
||||||
uint16_t set_size_handle;
|
|
||||||
uint16_t set_lock_handle;
|
|
||||||
uint16_t rank_handle;
|
|
||||||
|
|
||||||
uint8_t idx;
|
|
||||||
struct bt_gatt_subscribe_params sirk_sub_params;
|
|
||||||
struct bt_gatt_discover_params sirk_sub_disc_params;
|
|
||||||
struct bt_gatt_subscribe_params size_sub_params;
|
|
||||||
struct bt_gatt_discover_params size_sub_disc_params;
|
|
||||||
struct bt_gatt_subscribe_params lock_sub_params;
|
|
||||||
struct bt_gatt_discover_params lock_sub_disc_params;
|
|
||||||
|
|
||||||
struct bt_conn *conn;
|
|
||||||
struct bt_csip_set_coordinator_set_info *set_info;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct active_members {
|
static struct active_members {
|
||||||
struct bt_csip_set_coordinator_set_member *members[CONFIG_BT_MAX_CONN];
|
struct bt_csip_set_coordinator_set_member *members[CONFIG_BT_MAX_CONN];
|
||||||
const struct bt_csip_set_coordinator_set_info *info;
|
const struct bt_csip_set_coordinator_set_info *info;
|
||||||
|
@ -133,8 +111,8 @@ static struct bt_csip_set_coordinator_svc_inst *lookup_instance_by_handle(struct
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bt_csip_set_coordinator_svc_inst *lookup_instance_by_index(const struct bt_conn *conn,
|
struct bt_csip_set_coordinator_svc_inst *bt_csip_set_coordinator_lookup_instance_by_index
|
||||||
uint8_t idx)
|
(const struct bt_conn *conn, uint8_t idx)
|
||||||
{
|
{
|
||||||
uint8_t conn_index;
|
uint8_t conn_index;
|
||||||
struct bt_csip_set_coordinator_inst *client;
|
struct bt_csip_set_coordinator_inst *client;
|
||||||
|
@ -164,7 +142,7 @@ static struct bt_csip_set_coordinator_svc_inst *lookup_instance_by_set_info(
|
||||||
memcmp(&member_set_info->set_sirk,
|
memcmp(&member_set_info->set_sirk,
|
||||||
&set_info->set_sirk,
|
&set_info->set_sirk,
|
||||||
sizeof(set_info->set_sirk)) == 0) {
|
sizeof(set_info->set_sirk)) == 0) {
|
||||||
return lookup_instance_by_index(inst->conn, i);
|
return bt_csip_set_coordinator_lookup_instance_by_index(inst->conn, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,11 +575,11 @@ static int csip_set_coordinator_read_set_size(struct bt_conn *conn,
|
||||||
if (inst_idx >= CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES) {
|
if (inst_idx >= CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else if (cur_inst != NULL) {
|
} else if (cur_inst != NULL) {
|
||||||
if (cur_inst != lookup_instance_by_index(conn, inst_idx)) {
|
if (cur_inst != bt_csip_set_coordinator_lookup_instance_by_index(conn, inst_idx)) {
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cur_inst = lookup_instance_by_index(conn, inst_idx);
|
cur_inst = bt_csip_set_coordinator_lookup_instance_by_index(conn, inst_idx);
|
||||||
if (cur_inst == NULL) {
|
if (cur_inst == NULL) {
|
||||||
LOG_DBG("Inst not found");
|
LOG_DBG("Inst not found");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -629,11 +607,11 @@ static int csip_set_coordinator_read_rank(struct bt_conn *conn,
|
||||||
if (inst_idx >= CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES) {
|
if (inst_idx >= CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else if (cur_inst != NULL) {
|
} else if (cur_inst != NULL) {
|
||||||
if (cur_inst != lookup_instance_by_index(conn, inst_idx)) {
|
if (cur_inst != bt_csip_set_coordinator_lookup_instance_by_index(conn, inst_idx)) {
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cur_inst = lookup_instance_by_index(conn, inst_idx);
|
cur_inst = bt_csip_set_coordinator_lookup_instance_by_index(conn, inst_idx);
|
||||||
if (cur_inst == NULL) {
|
if (cur_inst == NULL) {
|
||||||
LOG_DBG("Inst not found");
|
LOG_DBG("Inst not found");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1042,7 +1020,8 @@ static void discover_insts_resume(struct bt_conn *conn, uint16_t sirk_handle,
|
||||||
|
|
||||||
cur_inst = NULL;
|
cur_inst = NULL;
|
||||||
if (next_idx < client->inst_count) {
|
if (next_idx < client->inst_count) {
|
||||||
cur_inst = lookup_instance_by_index(conn, next_idx);
|
cur_inst = bt_csip_set_coordinator_lookup_instance_by_index(conn,
|
||||||
|
next_idx);
|
||||||
|
|
||||||
/* Read next */
|
/* Read next */
|
||||||
cb_err = read_set_sirk(cur_inst);
|
cb_err = read_set_sirk(cur_inst);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue