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:
Emil Gydesen 2021-11-24 11:59:01 +01:00 committed by Anas Nashif
parent f2401ecbe9
commit f13aa0e059
3 changed files with 14 additions and 12 deletions

View file

@ -201,7 +201,6 @@ struct bt_csis_client_set {
struct bt_csis_client_set_member {
struct bt_conn *conn;
bt_addr_le_t addr;
struct bt_csis_client_set sets[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES];
};

View file

@ -26,12 +26,13 @@ static uint8_t members_found;
static struct k_work_delayable discover_members_timer;
static struct bt_csis_client_set_member set_members[CONFIG_BT_MAX_CONN];
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];
static bool is_discovered(const bt_addr_le_t *addr)
{
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;
}
}
@ -58,14 +59,14 @@ static void connected_cb(struct bt_conn *conn, uint8_t err)
if (members_found == 0) {
shell_print(ctx_shell, "Assuming member[0] connected");
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;
return;
}
for (uint8_t i = 0; i < members_found; i++) {
if (bt_addr_le_cmp(bt_conn_get_dst(conn),
&set_members[i].addr) == 0) {
&addr_found[i]) == 0) {
set_members[i].conn = conn;
shell_print(ctx_shell, "Member[%u] connected", i);
return;
@ -173,7 +174,7 @@ static bool csis_found(struct bt_data *data, void *user_data)
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)",
members_found, cur_set->set_size);

View file

@ -5,6 +5,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_BT_CSIS_CLIENT
#include <bluetooth/addr.h>
#include <bluetooth/audio/csis.h>
#include "common.h"
@ -19,6 +20,7 @@ static struct bt_csis_client_set *set;
static uint8_t members_found;
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 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)
{
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;
}
}
@ -137,7 +139,7 @@ static bool csis_found(struct bt_data *data, void *user_data)
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",
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) {
/* Scanning for the first device */
if (members_found == 0) {
bt_addr_le_copy(&set_members[members_found++].addr,
bt_addr_le_copy(&addr_found[members_found++],
info->addr);
}
} else { /* Scanning for set members */
@ -214,8 +216,8 @@ static void test_main(void)
return;
}
bt_addr_le_to_str(&set_members[0].addr, addr, sizeof(addr));
err = bt_conn_le_create(&set_members[0].addr, BT_CONN_LE_CREATE_CONN,
bt_addr_le_to_str(&addr_found[0], addr, sizeof(addr));
err = bt_conn_le_create(&addr_found[0], BT_CONN_LE_CREATE_CONN,
BT_LE_CONN_PARAM_DEFAULT, &set_members[0].conn);
if (err != 0) {
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++) {
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;
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_LE_CONN_PARAM_DEFAULT,
&set_members[i].conn);