1 /* 2 * Copyright (c) 2022 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/sys/check.h> 8 #include <zephyr/bluetooth/gatt.h> 9 #include <zephyr/bluetooth/audio/tbs.h> 10 #include <zephyr/bluetooth/audio/csip.h> 11 #include "cap_internal.h" 12 13 #include <zephyr/logging/log.h> 14 15 LOG_MODULE_REGISTER(bt_cap_acceptor, CONFIG_BT_CAP_ACCEPTOR_LOG_LEVEL); 16 17 #if defined(CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER) 18 19 static struct bt_gatt_attr svc_attrs[] = { 20 BT_GATT_PRIMARY_SERVICE(BT_UUID_CAS), 21 BT_GATT_INCLUDE_SERVICE(NULL) /* To be overwritten */ 22 }; 23 bt_cap_acceptor_register(const struct bt_csip_set_member_register_param * param,struct bt_csip_set_member_svc_inst ** svc_inst)24int bt_cap_acceptor_register(const struct bt_csip_set_member_register_param *param, 25 struct bt_csip_set_member_svc_inst **svc_inst) 26 { 27 static struct bt_gatt_service cas; 28 int err; 29 30 err = bt_csip_set_member_register(param, svc_inst); 31 if (err != 0) { 32 LOG_DBG("Failed to register CSIP"); 33 return err; 34 } 35 36 cas = (struct bt_gatt_service)BT_GATT_SERVICE(svc_attrs); 37 38 /* Overwrite the include definition with the CSIP */ 39 cas.attrs[1].user_data = bt_csip_set_member_svc_decl_get(*svc_inst); 40 41 err = bt_gatt_service_register(&cas); 42 if (err) { 43 LOG_DBG("Failed to register CAS"); 44 return err; 45 } 46 47 return 0; 48 } 49 50 #else /* CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER */ 51 52 BT_GATT_SERVICE_DEFINE(cas_svc, 53 BT_GATT_PRIMARY_SERVICE(BT_UUID_CAS) 54 /* TODO: Add support for included CSIP */ 55 ); 56 57 #endif /* CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER */ 58 bt_cap_acceptor_ccid_exist(const struct bt_conn * conn,uint8_t ccid)59bool bt_cap_acceptor_ccid_exist(const struct bt_conn *conn, uint8_t ccid) 60 { 61 if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_CCID) && 62 bt_tbs_client_get_by_ccid(conn, ccid) != NULL) { 63 return true; 64 } 65 66 /* TODO: check mcs */ 67 68 return false; 69 } 70