Bluetooth: CSIS: Expose bt_csis to client via bt_csis_client_set_member
Use the bt_csis_client_set_member struct to store the individual bt_csis client struct. This way they are exposed to the client application. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
60181a183f
commit
2bf89990ee
4 changed files with 17 additions and 11 deletions
|
@ -202,6 +202,7 @@ struct bt_csis_client_set {
|
||||||
struct bt_csis_set_sirk set_sirk;
|
struct bt_csis_set_sirk set_sirk;
|
||||||
uint8_t set_size;
|
uint8_t set_size;
|
||||||
uint8_t rank;
|
uint8_t rank;
|
||||||
|
struct bt_csis *csis;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bt_csis_client_set_member {
|
struct bt_csis_client_set_member {
|
||||||
|
@ -210,8 +211,8 @@ struct bt_csis_client_set_member {
|
||||||
struct bt_csis_client_set sets[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES];
|
struct bt_csis_client_set sets[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*bt_csis_client_discover_cb)(struct bt_conn *conn, int err,
|
typedef void (*bt_csis_client_discover_cb)(struct bt_csis_client_set_member *member,
|
||||||
uint8_t set_count);
|
int err, uint8_t set_count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise the csis_client instance for a connection. This will do a
|
* @brief Initialise the csis_client instance for a connection. This will do a
|
||||||
|
@ -221,8 +222,7 @@ typedef void (*bt_csis_client_discover_cb)(struct bt_conn *conn, int err,
|
||||||
*
|
*
|
||||||
* @return int Return 0 on success, or an errno value on error.
|
* @return int Return 0 on success, or an errno value on error.
|
||||||
*/
|
*/
|
||||||
int bt_csis_client_discover(struct bt_csis_client_set_member *member,
|
int bt_csis_client_discover(struct bt_csis_client_set_member *member);
|
||||||
struct bt_csis *csis[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES]);
|
|
||||||
|
|
||||||
typedef void (*bt_csis_client_discover_sets_cb)(struct bt_conn *conn,
|
typedef void (*bt_csis_client_discover_sets_cb)(struct bt_conn *conn,
|
||||||
int err, uint8_t set_count,
|
int err, uint8_t set_count,
|
||||||
|
|
|
@ -476,7 +476,7 @@ static uint8_t discover_func(struct bt_conn *conn,
|
||||||
busy = false;
|
busy = false;
|
||||||
if (csis_client_cbs != NULL &&
|
if (csis_client_cbs != NULL &&
|
||||||
csis_client_cbs->discover != NULL) {
|
csis_client_cbs->discover != NULL) {
|
||||||
csis_client_cbs->discover(conn, err,
|
csis_client_cbs->discover(client->set_member, err,
|
||||||
client->inst_count);
|
client->inst_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ static uint8_t discover_func(struct bt_conn *conn,
|
||||||
cur_inst = NULL;
|
cur_inst = NULL;
|
||||||
busy = false;
|
busy = false;
|
||||||
if (csis_client_cbs != NULL && csis_client_cbs->discover != NULL) {
|
if (csis_client_cbs != NULL && csis_client_cbs->discover != NULL) {
|
||||||
csis_client_cbs->discover(conn, 0,
|
csis_client_cbs->discover(client->set_member, 0,
|
||||||
client->inst_count);
|
client->inst_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,8 @@ static uint8_t primary_discover_func(struct bt_conn *conn,
|
||||||
cur_inst = NULL;
|
cur_inst = NULL;
|
||||||
if (csis_client_cbs != NULL &&
|
if (csis_client_cbs != NULL &&
|
||||||
csis_client_cbs->discover != 0) {
|
csis_client_cbs->discover != 0) {
|
||||||
csis_client_cbs->discover(conn, err,
|
csis_client_cbs->discover(client->set_member,
|
||||||
|
err,
|
||||||
client->inst_count);
|
client->inst_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +582,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn,
|
||||||
cur_inst = NULL;
|
cur_inst = NULL;
|
||||||
if (csis_client_cbs != NULL &&
|
if (csis_client_cbs != NULL &&
|
||||||
csis_client_cbs->discover != NULL) {
|
csis_client_cbs->discover != NULL) {
|
||||||
csis_client_cbs->discover(conn, 0, 0);
|
csis_client_cbs->discover(client->set_member, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,6 +1168,9 @@ int bt_csis_client_discover(struct bt_csis_client_set_member *member)
|
||||||
|
|
||||||
err = bt_gatt_discover(member->conn, &discover_params);
|
err = bt_gatt_discover(member->conn, &discover_params);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(member->sets); i++) {
|
||||||
|
member->sets[i].csis = &client->csis_insts[i];
|
||||||
|
}
|
||||||
busy = true;
|
busy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,8 @@ static struct bt_conn_cb conn_callbacks = {
|
||||||
.connected = connected_cb,
|
.connected = connected_cb,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void csis_discover_cb(struct bt_conn *conn, int err, uint8_t set_count)
|
static void csis_discover_cb(struct bt_csis_client_set_member *member, int err,
|
||||||
|
uint8_t set_count)
|
||||||
{
|
{
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
shell_error(ctx_shell, "discover failed (%d)", err);
|
shell_error(ctx_shell, "discover failed (%d)", err);
|
||||||
|
@ -92,7 +93,7 @@ static void csis_discover_cb(struct bt_conn *conn, int err, uint8_t set_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(set_members); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(set_members); i++) {
|
||||||
if (set_members[i].conn == conn) {
|
if (&set_members[i] == member) {
|
||||||
shell_print(ctx_shell, "Found %u sets on member[%u]",
|
shell_print(ctx_shell, "Found %u sets on member[%u]",
|
||||||
set_count, i);
|
set_count, i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,8 @@ static void csis_client_discover_sets_cb(struct bt_conn *conn, int err,
|
||||||
sets_discovered = true;
|
sets_discovered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void csis_discover_cb(struct bt_conn *conn, int err, uint8_t set_count)
|
static void csis_discover_cb(struct bt_csis_client_set_member *member, int err,
|
||||||
|
uint8_t set_count)
|
||||||
{
|
{
|
||||||
printk("%s\n", __func__);
|
printk("%s\n", __func__);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue