zephyr/subsys/bluetooth/audio/cap_acceptor.c

70 lines
1.6 KiB
C

/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/sys/check.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/tbs.h>
#include <zephyr/bluetooth/audio/csis.h>
#include "cap_internal.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CAP_ACCEPTOR)
#define LOG_MODULE_NAME bt_cap_acceptor
#include "common/log.h"
#if defined(CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER)
static struct bt_gatt_attr svc_attrs[] = {
BT_GATT_PRIMARY_SERVICE(BT_UUID_CAS),
BT_GATT_INCLUDE_SERVICE(NULL) /* To be overwritten */
};
int bt_cap_acceptor_register(const struct bt_csis_register_param *param,
struct bt_csis **csis)
{
static struct bt_gatt_service cas;
int err;
err = bt_csis_register(param, csis);
if (err != 0) {
BT_DBG("Failed to register CSIS");
return err;
}
cas = (struct bt_gatt_service)BT_GATT_SERVICE(svc_attrs);
/* Overwrite the include definition with the CSIS */
cas.attrs[1].user_data = bt_csis_svc_decl_get(*csis);
err = bt_gatt_service_register(&cas);
if (err) {
BT_DBG("Failed to register CAS");
return err;
}
return 0;
}
#else /* CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER */
BT_GATT_SERVICE_DEFINE(cas_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_CAS)
/* TODO: Add support for included CSIS */
);
#endif /* CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER */
bool bt_cap_acceptor_ccid_exist(const struct bt_conn *conn, uint8_t ccid)
{
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_CCID) &&
bt_tbs_client_get_by_ccid(conn, ccid) != NULL) {
return true;
}
/* TODO: check mcs */
return false;
}