1 /* csip.c - CAP Commander specific CSIP mocks */
2
3 /*
4 * Copyright (c) 2023 Nordic Semiconductor ASA
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 #include <zephyr/bluetooth/audio/csip.h>
10
11 static struct bt_csip_set_coordinator_cb *csip_cb;
12
13 struct bt_csip_set_coordinator_svc_inst {
14 struct bt_conn *conn;
15 struct bt_csip_set_coordinator_set_info *set_info;
16 } svc_inst;
17
18 static struct bt_csip_set_coordinator_set_member member = {
19 .insts = {
20 {
21 .info = {
22 .set_size = 2,
23 .rank = 1,
24 .lockable = false,
25 },
26 .svc_inst = &svc_inst,
27 },
28 },
29 };
30
31 struct bt_csip_set_coordinator_csis_inst *
bt_csip_set_coordinator_csis_inst_by_handle(struct bt_conn * conn,uint16_t start_handle)32 bt_csip_set_coordinator_csis_inst_by_handle(struct bt_conn *conn, uint16_t start_handle)
33 {
34 return &member.insts[0];
35 }
36
bt_csip_set_coordinator_register_cb(struct bt_csip_set_coordinator_cb * cb)37 int bt_csip_set_coordinator_register_cb(struct bt_csip_set_coordinator_cb *cb)
38 {
39 csip_cb = cb;
40
41 return 0;
42 }
43
bt_csip_set_coordinator_discover(struct bt_conn * conn)44 int bt_csip_set_coordinator_discover(struct bt_conn *conn)
45 {
46 if (csip_cb != NULL) {
47 svc_inst.conn = conn;
48 svc_inst.set_info = &member.insts[0].info;
49 csip_cb->discover(conn, &member, 0, 1);
50 }
51
52 return 0;
53 }
54
55 struct bt_csip_set_coordinator_set_member *
bt_csip_set_coordinator_set_member_by_conn(const struct bt_conn * conn)56 bt_csip_set_coordinator_set_member_by_conn(const struct bt_conn *conn)
57 {
58 if (conn == NULL) {
59 return NULL;
60 }
61
62 return &member;
63 }
64
mock_bt_csip_init(void)65 void mock_bt_csip_init(void)
66 {
67 }
68
mock_bt_csip_cleanup(void)69 void mock_bt_csip_cleanup(void)
70 {
71 csip_cb = NULL;
72 }
73