Bluetooth: CSIS: Remove addr from bt_csis_client_set_member
Remove the addr struct from bt_csis_client_set_member as that was only used by the upper layers and not the CSIS client itself, and as such should only reside in the upper layers. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
f2401ecbe9
commit
f13aa0e059
3 changed files with 14 additions and 12 deletions
|
@ -201,7 +201,6 @@ struct bt_csis_client_set {
|
||||||
|
|
||||||
struct bt_csis_client_set_member {
|
struct bt_csis_client_set_member {
|
||||||
struct bt_conn *conn;
|
struct bt_conn *conn;
|
||||||
bt_addr_le_t addr;
|
|
||||||
struct bt_csis_client_set sets[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES];
|
struct bt_csis_client_set sets[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,13 @@ static uint8_t members_found;
|
||||||
static struct k_work_delayable discover_members_timer;
|
static struct k_work_delayable discover_members_timer;
|
||||||
static struct bt_csis_client_set_member set_members[CONFIG_BT_MAX_CONN];
|
static struct bt_csis_client_set_member set_members[CONFIG_BT_MAX_CONN];
|
||||||
struct bt_csis_client_set *cur_set;
|
struct bt_csis_client_set *cur_set;
|
||||||
|
static bt_addr_le_t addr_found[CONFIG_BT_MAX_CONN];
|
||||||
const struct bt_csis_client_set_member *locked_members[CONFIG_BT_MAX_CONN];
|
const struct bt_csis_client_set_member *locked_members[CONFIG_BT_MAX_CONN];
|
||||||
|
|
||||||
static bool is_discovered(const bt_addr_le_t *addr)
|
static bool is_discovered(const bt_addr_le_t *addr)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < members_found; i++) {
|
for (int i = 0; i < members_found; i++) {
|
||||||
if (bt_addr_le_cmp(addr, &set_members[i].addr) == 0) {
|
if (bt_addr_le_cmp(addr, &addr_found[i]) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,14 +59,14 @@ static void connected_cb(struct bt_conn *conn, uint8_t err)
|
||||||
if (members_found == 0) {
|
if (members_found == 0) {
|
||||||
shell_print(ctx_shell, "Assuming member[0] connected");
|
shell_print(ctx_shell, "Assuming member[0] connected");
|
||||||
set_members[0].conn = conn;
|
set_members[0].conn = conn;
|
||||||
bt_addr_le_copy(&set_members[0].addr, bt_conn_get_dst(conn));
|
bt_addr_le_copy(&addr_found[0], bt_conn_get_dst(conn));
|
||||||
members_found = 1;
|
members_found = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < members_found; i++) {
|
for (uint8_t i = 0; i < members_found; i++) {
|
||||||
if (bt_addr_le_cmp(bt_conn_get_dst(conn),
|
if (bt_addr_le_cmp(bt_conn_get_dst(conn),
|
||||||
&set_members[i].addr) == 0) {
|
&addr_found[i]) == 0) {
|
||||||
set_members[i].conn = conn;
|
set_members[i].conn = conn;
|
||||||
shell_print(ctx_shell, "Member[%u] connected", i);
|
shell_print(ctx_shell, "Member[%u] connected", i);
|
||||||
return;
|
return;
|
||||||
|
@ -173,7 +174,7 @@ static bool csis_found(struct bt_data *data, void *user_data)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_addr_le_copy(&set_members[members_found++].addr, addr);
|
bt_addr_le_copy(&addr_found[members_found++], addr);
|
||||||
|
|
||||||
shell_print(ctx_shell, "Found member (%u / %u)",
|
shell_print(ctx_shell, "Found member (%u / %u)",
|
||||||
members_found, cur_set->set_size);
|
members_found, cur_set->set_size);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_BT_CSIS_CLIENT
|
#ifdef CONFIG_BT_CSIS_CLIENT
|
||||||
|
#include <bluetooth/addr.h>
|
||||||
#include <bluetooth/audio/csis.h>
|
#include <bluetooth/audio/csis.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ static struct bt_csis_client_set *set;
|
||||||
|
|
||||||
static uint8_t members_found;
|
static uint8_t members_found;
|
||||||
static struct k_work_delayable discover_members_timer;
|
static struct k_work_delayable discover_members_timer;
|
||||||
|
static bt_addr_le_t addr_found[CONFIG_BT_MAX_CONN];
|
||||||
static struct bt_csis_client_set_member set_members[CONFIG_BT_MAX_CONN];
|
static struct bt_csis_client_set_member set_members[CONFIG_BT_MAX_CONN];
|
||||||
|
|
||||||
static void csis_client_lock_set_cb(int err);
|
static void csis_client_lock_set_cb(int err);
|
||||||
|
@ -115,7 +117,7 @@ static struct bt_csis_client_cb cbs = {
|
||||||
static bool is_discovered(const bt_addr_le_t *addr)
|
static bool is_discovered(const bt_addr_le_t *addr)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < members_found; i++) {
|
for (int i = 0; i < members_found; i++) {
|
||||||
if (bt_addr_le_cmp(addr, &set_members[i].addr) == 0) {
|
if (bt_addr_le_cmp(addr, &addr_found[i]) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +139,7 @@ static bool csis_found(struct bt_data *data, void *user_data)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_addr_le_copy(&set_members[members_found++].addr, addr);
|
bt_addr_le_copy(&addr_found[members_found++], addr);
|
||||||
|
|
||||||
printk("Found member (%u / %u)\n",
|
printk("Found member (%u / %u)\n",
|
||||||
members_found, set->set_size);
|
members_found, set->set_size);
|
||||||
|
@ -157,7 +159,7 @@ static void csis_client_scan_recv(const struct bt_le_scan_recv_info *info,
|
||||||
if (set == NULL) {
|
if (set == NULL) {
|
||||||
/* Scanning for the first device */
|
/* Scanning for the first device */
|
||||||
if (members_found == 0) {
|
if (members_found == 0) {
|
||||||
bt_addr_le_copy(&set_members[members_found++].addr,
|
bt_addr_le_copy(&addr_found[members_found++],
|
||||||
info->addr);
|
info->addr);
|
||||||
}
|
}
|
||||||
} else { /* Scanning for set members */
|
} else { /* Scanning for set members */
|
||||||
|
@ -214,8 +216,8 @@ static void test_main(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_addr_le_to_str(&set_members[0].addr, addr, sizeof(addr));
|
bt_addr_le_to_str(&addr_found[0], addr, sizeof(addr));
|
||||||
err = bt_conn_le_create(&set_members[0].addr, BT_CONN_LE_CREATE_CONN,
|
err = bt_conn_le_create(&addr_found[0], BT_CONN_LE_CREATE_CONN,
|
||||||
BT_LE_CONN_PARAM_DEFAULT, &set_members[0].conn);
|
BT_LE_CONN_PARAM_DEFAULT, &set_members[0].conn);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
FAIL("Failed to connect to %s: %d\n", err);
|
FAIL("Failed to connect to %s: %d\n", err);
|
||||||
|
@ -266,11 +268,11 @@ static void test_main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 1; i < members_found; i++) {
|
for (uint8_t i = 1; i < members_found; i++) {
|
||||||
bt_addr_le_to_str(&set_members[i].addr, addr, sizeof(addr));
|
bt_addr_le_to_str(&addr_found[i], addr, sizeof(addr));
|
||||||
|
|
||||||
is_connected = false;
|
is_connected = false;
|
||||||
printk("Connecting to member[%d] (%s)", i, addr);
|
printk("Connecting to member[%d] (%s)", i, addr);
|
||||||
err = bt_conn_le_create(&set_members[i].addr,
|
err = bt_conn_le_create(&addr_found[i],
|
||||||
BT_CONN_LE_CREATE_CONN,
|
BT_CONN_LE_CREATE_CONN,
|
||||||
BT_LE_CONN_PARAM_DEFAULT,
|
BT_LE_CONN_PARAM_DEFAULT,
|
||||||
&set_members[i].conn);
|
&set_members[i].conn);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue