1 /** @file
2  *  @brief Bluetooth Call Control Profile (CCP) Server role.
3  *
4  *  Copyright 2023 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_server_init(void)47 int ccp_server_init(void)
48 {
49 	int err;
50 
51 	bt_tbs_register_cb(&tbs_cbs);
52 
53 	err = bt_tbs_set_uri_scheme_list(0, (const char **)&uri_list, URI_LIST_LEN);
54 
55 	return err;
56 }
57