1 /** @file
2 * @brief Bluetooth Call Control Profile (CCP) Server role.
3 *
4 * Copyright 2023,2025 NXP
5 * Copyright (c) 2024 Nordic Semiconductor ASA
6 *
7 * SPDX-License-Identifier: Apache-2.0
8 */
9
10 #include <stdint.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include <zephyr/bluetooth/conn.h>
15 #include <zephyr/bluetooth/audio/tbs.h>
16 #include <zephyr/kernel.h>
17 #include <zephyr/sys/printk.h>
18
19 #define URI_LIST_LEN 2
20
21 static const char *uri_list[URI_LIST_LEN] = {"skype", "tel"};
22
tbs_originate_call_cb(struct bt_conn * conn,uint8_t call_index,const char * caller_id)23 static bool tbs_originate_call_cb(struct bt_conn *conn, uint8_t call_index,
24 const char *caller_id)
25 {
26 printk("CCP: Placing call to remote with id %u to %s\n",
27 call_index, caller_id);
28 return true;
29 }
30
tbs_terminate_call_cb(struct bt_conn * conn,uint8_t call_index,uint8_t reason)31 static void tbs_terminate_call_cb(struct bt_conn *conn, uint8_t call_index, uint8_t reason)
32 {
33 printk("CCP: Call terminated for id %u with reason %u\n",
34 call_index, reason);
35 }
36
37 static struct bt_tbs_cb tbs_cbs = {
38 .originate_call = tbs_originate_call_cb,
39 .terminate_call = tbs_terminate_call_cb,
40 .hold_call = NULL,
41 .accept_call = NULL,
42 .retrieve_call = NULL,
43 .join_calls = NULL,
44 .authorize = NULL,
45 };
46
ccp_call_control_server_init(void)47 int ccp_call_control_server_init(void)
48 {
49 int err;
50
51 const struct bt_tbs_register_param gtbs_param = {
52 .provider_name = "Generic TBS",
53 .uci = "un000",
54 .uri_schemes_supported = "tel",
55 .gtbs = true,
56 .authorization_required = false,
57 .technology = BT_TBS_TECHNOLOGY_3G,
58 .supported_features = CONFIG_BT_TBS_SUPPORTED_FEATURES,
59 };
60
61 err = bt_tbs_register_bearer(>bs_param);
62 if (err < 0) {
63 printk("Failed to register GTBS: %d\n", err);
64 return -ENOEXEC;
65 }
66
67 bt_tbs_register_cb(&tbs_cbs);
68 err = bt_tbs_set_uri_scheme_list(BT_TBS_GTBS_INDEX, (const char **)&uri_list, URI_LIST_LEN);
69
70 return err;
71 }
72