Skip to content

Commit f58ac34

Browse files
Thalleyjhedberg
authored andcommitted
Bluetooth: CAP: Add reference to the set member for CAP discover
Since the CSIP API expects a set member struct for nearly all functionality, the reference to the full set member (along with the CAS specific CSIS) should be given to the application. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent cc1894b commit f58ac34

File tree

17 files changed

+59
-15
lines changed

17 files changed

+59
-15
lines changed

doc/releases/migration-guide-3.7.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ Bluetooth Audio
312312
:kconfig:option:`CONFIG_BT_ISO_PERIPHERAL` are not longer `select`ed automatically when
313313
enabling :kconfig:option:`CONFIG_BT_BAP_UNICAST_SERVER`, and these must now be set explicitly
314314
in the project configuration file. (:github:`71993`)
315+
* The discover callback functions :code:`bt_cap_initiator_cb.unicast_discovery_complete`` and
316+
:code:`bt_cap_commander_cb.discovery_complete`` for CAP now contain an additional parameter for
317+
the set member.
318+
This needs to be added to all instances of CAP discovery callback functions defined.
319+
(:github:`72797`)
315320

316321
Bluetooth Classic
317322
=================

include/zephyr/bluetooth/audio/cap.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ struct bt_cap_initiator_cb {
6363
* @param conn The connection pointer supplied to
6464
* bt_cap_initiator_unicast_discover().
6565
* @param err 0 if Common Audio Service was found else -ENODATA.
66+
* @param member Pointer to the set member. NULL if err != 0.
6667
* @param csis_inst The Coordinated Set Identification Service if
6768
* Common Audio Service was found and includes a
6869
* Coordinated Set Identification Service.
6970
* NULL on error or if remote device does not include
70-
* Coordinated Set Identification Service.
71+
* Coordinated Set Identification Service. NULL if err != 0.
7172
*/
7273
void (*unicast_discovery_complete)(
7374
struct bt_conn *conn, int err,
75+
const struct bt_csip_set_coordinator_set_member *member,
7476
const struct bt_csip_set_coordinator_csis_inst *csis_inst);
7577

7678
/**
@@ -676,13 +678,15 @@ struct bt_cap_commander_cb {
676678
* @param conn The connection pointer supplied to
677679
* bt_cap_initiator_unicast_discover().
678680
* @param err 0 if Common Audio Service was found else -ENODATA.
681+
* @param member Pointer to the set member. NULL if err != 0.
679682
* @param csis_inst The Coordinated Set Identification Service if
680683
* Common Audio Service was found and includes a
681684
* Coordinated Set Identification Service.
682685
* NULL on error or if remote device does not include
683-
* Coordinated Set Identification Service.
686+
* Coordinated Set Identification Service. NULL if err != 0.
684687
*/
685688
void (*discovery_complete)(struct bt_conn *conn, int err,
689+
const struct bt_csip_set_coordinator_set_member *member,
686690
const struct bt_csip_set_coordinator_csis_inst *csis_inst);
687691

688692
#if defined(CONFIG_BT_VCP_VOL_CTLR)

samples/bluetooth/tmap_central/src/cap_initiator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static struct bt_bap_lc3_preset unicast_preset_48_2_1 =
9898
BT_AUDIO_CONTEXT_TYPE_MEDIA);
9999

100100
static void cap_discovery_complete_cb(struct bt_conn *conn, int err,
101+
const struct bt_csip_set_coordinator_set_member *member,
101102
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
102103
{
103104
if (err != 0) {

subsys/bluetooth/audio/cap_commander.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ int bt_cap_commander_unregister_cb(const struct bt_cap_commander_cb *cb)
6565

6666
static void
6767
cap_commander_discover_complete(struct bt_conn *conn, int err,
68+
const struct bt_csip_set_coordinator_set_member *member,
6869
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
6970
{
7071
if (cap_cb && cap_cb->discovery_complete) {
71-
cap_cb->discovery_complete(conn, err, csis_inst);
72+
cap_cb->discovery_complete(conn, err, member, csis_inst);
7273
}
7374
}
7475

subsys/bluetooth/audio/cap_common.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ struct bt_cap_common_client *bt_cap_common_get_client(enum bt_cap_set_type type,
256256
}
257257

258258
static void cap_common_discover_complete(struct bt_conn *conn, int err,
259+
const struct bt_csip_set_coordinator_set_member *member,
259260
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
260261
{
261262
struct bt_cap_common_client *client;
@@ -265,7 +266,7 @@ static void cap_common_discover_complete(struct bt_conn *conn, int err,
265266
const bt_cap_common_discover_func_t cb_func = client->discover_cb_func;
266267

267268
client->discover_cb_func = NULL;
268-
cb_func(conn, err, csis_inst);
269+
cb_func(conn, err, member, csis_inst);
269270
}
270271
}
271272

@@ -278,7 +279,7 @@ static void csis_client_discover_cb(struct bt_conn *conn,
278279
if (err != 0) {
279280
LOG_DBG("CSIS client discover failed: %d", err);
280281

281-
cap_common_discover_complete(conn, err, NULL);
282+
cap_common_discover_complete(conn, err, NULL, NULL);
282283

283284
return;
284285
}
@@ -290,10 +291,10 @@ static void csis_client_discover_cb(struct bt_conn *conn,
290291
if (member == NULL || set_count == 0 || client->csis_inst == NULL) {
291292
LOG_ERR("Unable to find CSIS for CAS");
292293

293-
cap_common_discover_complete(conn, -ENODATA, NULL);
294+
cap_common_discover_complete(conn, -ENODATA, NULL, NULL);
294295
} else {
295296
LOG_DBG("Found CAS with CSIS");
296-
cap_common_discover_complete(conn, 0, client->csis_inst);
297+
cap_common_discover_complete(conn, 0, member, client->csis_inst);
297298
}
298299
}
299300

@@ -304,7 +305,7 @@ static uint8_t bt_cap_common_discover_included_cb(struct bt_conn *conn,
304305
if (attr == NULL) {
305306
LOG_DBG("CAS CSIS include not found");
306307

307-
cap_common_discover_complete(conn, 0, NULL);
308+
cap_common_discover_complete(conn, 0, NULL, NULL);
308309
} else {
309310
const struct bt_gatt_include *included_service = attr->user_data;
310311
struct bt_cap_common_client *client =
@@ -335,11 +336,15 @@ static uint8_t bt_cap_common_discover_included_cb(struct bt_conn *conn,
335336
err = bt_csip_set_coordinator_discover(conn);
336337
if (err != 0) {
337338
LOG_DBG("Discover failed (err %d)", err);
338-
cap_common_discover_complete(conn, err, NULL);
339+
cap_common_discover_complete(conn, err, NULL, NULL);
339340
}
340341
} else {
342+
const struct bt_csip_set_coordinator_set_member *member =
343+
bt_csip_set_coordinator_csis_member_by_conn(conn);
344+
341345
LOG_DBG("Found CAS with CSIS");
342-
cap_common_discover_complete(conn, 0, client->csis_inst);
346+
347+
cap_common_discover_complete(conn, 0, member, client->csis_inst);
343348
}
344349
}
345350

@@ -350,7 +355,7 @@ static uint8_t bt_cap_common_discover_cas_cb(struct bt_conn *conn, const struct
350355
struct bt_gatt_discover_params *params)
351356
{
352357
if (attr == NULL) {
353-
cap_common_discover_complete(conn, -ENODATA, NULL);
358+
cap_common_discover_complete(conn, -ENODATA, NULL, NULL);
354359
} else {
355360
const struct bt_gatt_service_val *prim_service = attr->user_data;
356361
struct bt_cap_common_client *client =
@@ -362,7 +367,7 @@ static uint8_t bt_cap_common_discover_cas_cb(struct bt_conn *conn, const struct
362367

363368
if (attr->handle == prim_service->end_handle) {
364369
LOG_DBG("Found CAS without CSIS");
365-
cap_common_discover_complete(conn, 0, NULL);
370+
cap_common_discover_complete(conn, 0, NULL, NULL);
366371

367372
return BT_GATT_ITER_STOP;
368373
}
@@ -379,7 +384,7 @@ static uint8_t bt_cap_common_discover_cas_cb(struct bt_conn *conn, const struct
379384
if (err != 0) {
380385
LOG_DBG("Discover failed (err %d)", err);
381386

382-
cap_common_discover_complete(conn, err, NULL);
387+
cap_common_discover_complete(conn, err, NULL, NULL);
383388
}
384389
}
385390

subsys/bluetooth/audio/cap_initiator.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@ int bt_cap_initiator_broadcast_get_base(struct bt_cap_broadcast_source *broadcas
315315

316316
static void
317317
bt_cap_initiator_discover_complete(struct bt_conn *conn, int err,
318+
const struct bt_csip_set_coordinator_set_member *member,
318319
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
319320
{
320321
if (cap_cb && cap_cb->unicast_discovery_complete) {
321-
cap_cb->unicast_discovery_complete(conn, err, csis_inst);
322+
cap_cb->unicast_discovery_complete(conn, err, member, csis_inst);
322323
}
323324
}
324325

subsys/bluetooth/audio/cap_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ struct bt_cap_commander_proc_param {
118118
};
119119

120120
typedef void (*bt_cap_common_discover_func_t)(
121-
struct bt_conn *conn, int err, const struct bt_csip_set_coordinator_csis_inst *csis_inst);
121+
struct bt_conn *conn, int err, const struct bt_csip_set_coordinator_set_member *member,
122+
const struct bt_csip_set_coordinator_csis_inst *csis_inst);
122123

123124
struct bt_cap_common_proc_param {
124125
union {

subsys/bluetooth/audio/csip_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ struct bt_csip_set_coordinator_svc_inst {
4848

4949
struct bt_csip_set_coordinator_csis_inst *bt_csip_set_coordinator_csis_inst_by_handle(
5050
struct bt_conn *conn, uint16_t start_handle);
51+
struct bt_csip_set_coordinator_set_member *
52+
bt_csip_set_coordinator_csis_member_by_conn(struct bt_conn *conn);

subsys/bluetooth/audio/csip_set_coordinator.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,22 @@ struct bt_csip_set_coordinator_csis_inst *bt_csip_set_coordinator_csis_inst_by_h
14181418
return NULL;
14191419
}
14201420

1421+
struct bt_csip_set_coordinator_set_member *
1422+
bt_csip_set_coordinator_csis_member_by_conn(struct bt_conn *conn)
1423+
{
1424+
struct bt_csip_set_coordinator_inst *client;
1425+
1426+
CHECKIF(conn == NULL) {
1427+
LOG_DBG("conn is NULL");
1428+
1429+
return NULL;
1430+
}
1431+
1432+
client = &client_insts[bt_conn_index(conn)];
1433+
1434+
return &client->set_member;
1435+
}
1436+
14211437
/*************************** PUBLIC FUNCTIONS ***************************/
14221438
int bt_csip_set_coordinator_register_cb(struct bt_csip_set_coordinator_cb *cb)
14231439
{

subsys/bluetooth/audio/shell/cap_commander.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "audio.h"
2020

2121
static void cap_discover_cb(struct bt_conn *conn, int err,
22+
const struct bt_csip_set_coordinator_set_member *member,
2223
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
2324
{
2425
if (err != 0) {

0 commit comments

Comments
 (0)