Skip to content

Commit ce641d9

Browse files
committed
Bluetooth: CCP: Initial CCP Client implemenation
Added initial CCP client implementation that simply does discovery of TBS on a remote CCP server. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 4456ecc commit ce641d9

File tree

44 files changed

+1670
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1670
-7
lines changed

doc/connectivity/bluetooth/api/audio/bluetooth-le-audio-arch.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,8 @@ Bluetooth Audio Stack.
726726
| | | | | - Shell Module | - Sample Application (in progress) |
727727
| | | | | - BSIM test | |
728728
| +-------------------------------+---------+------------------+-----------------------+--------------------------------------------------+
729-
| | Call Control Client | 1.0 | 3.0 | - Feature complete | - API refactor |
730-
| | | | | - Shell Module | - Sample Application |
729+
| | Call Control Client | 1.0 | 3.0 | - Feature complete | - API refactor (in progress) |
730+
| | | | | - Shell Module | - Sample Application (in progress) |
731731
| | | | | - BSIM test | |
732732
+--------+-------------------------------+---------+------------------+-----------------------+--------------------------------------------------+
733733
| MCP | Media Control Server | 1.0 | 3.0 | - Feature complete | - API refactor |

doc/connectivity/bluetooth/shell/audio/ccp.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,28 @@ Setup
3333
Registered GTBS bearer
3434
Registered bearer[1]
3535
uart:~$ bt connect xx:xx:xx:xx:xx:xx public
36+
37+
Call Control Client
38+
*******************
39+
The Call Control Client is a role that typically resides on resource constrained devices such as
40+
earbuds or headsets.
41+
42+
Using the Call Control Client
43+
=============================
44+
The Client can control a remote CCP server device.
45+
For example a remote device may have an incoming call that can be accepted by the Client.
46+
47+
.. code-block:: console
48+
49+
uart:~$ ccp_call_control_client --help
50+
ccp_call_control_client - Bluetooth CCP Call Control Client shell commands
51+
Subcommands:
52+
discover : Discover GTBS and TBS on remote device
53+
54+
Example Usage when connected
55+
============================
56+
57+
.. code-block:: console
58+
59+
uart:~$ ccp_call_control_client discover
60+
Discovery completed with GTBS and 1 TBS bearers

include/zephyr/bluetooth/audio/ccp.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@
3131
* The profile is not limited to carrier phone calls and can be used with common applications like
3232
* Discord and Teams.
3333
*/
34+
#include <stdint.h>
3435

36+
#include <zephyr/autoconf.h>
3537
#include <zephyr/bluetooth/audio/tbs.h>
38+
#include <zephyr/bluetooth/conn.h>
39+
#include <zephyr/sys/slist.h>
3640

3741
#ifdef __cplusplus
3842
extern "C" {
@@ -90,6 +94,82 @@ int bt_ccp_call_control_server_unregister_bearer(struct bt_ccp_call_control_serv
9094

9195
/** @} */ /* End of group bt_ccp_call_control_server */
9296

97+
/**
98+
* @defgroup bt_ccp_call_control_client CCP Call Control Client APIs
99+
* @ingroup bt_ccp
100+
* @{
101+
*/
102+
/** Abstract Call Control Client structure. */
103+
struct bt_ccp_call_control_client;
104+
105+
/** Abstract Call Control Client bearer structure. */
106+
struct bt_ccp_call_control_client_bearer;
107+
108+
/** Struct with information about bearers of a client */
109+
struct bt_ccp_call_control_client_bearers {
110+
#if defined(CONFIG_BT_TBS_CLIENT_GTBS)
111+
/** The GTBS bearer. */
112+
struct bt_ccp_call_control_client_bearer *gtbs_bearer;
113+
#endif /* CONFIG_BT_TBS_CLIENT_GTBS */
114+
115+
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
116+
/** Number of TBS bearers in @p tbs_bearers */
117+
size_t tbs_count;
118+
119+
/** Array of pointers of TBS bearers */
120+
struct bt_ccp_call_control_client_bearer
121+
*tbs_bearers[CONFIG_BT_CCP_CALL_CONTROL_CLIENT_BEARER_COUNT];
122+
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
123+
};
124+
125+
/**
126+
* @brief Struct to hold the Telephone Bearer Service client callbacks
127+
*
128+
* These can be registered for usage with bt_tbs_client_register_cb().
129+
*/
130+
struct bt_ccp_call_control_client_cb {
131+
/**
132+
* @brief Callback function for bt_ccp_call_control_client_discover().
133+
*
134+
* This callback is called once the discovery procedure is completed.
135+
*
136+
* @param client Call Control Client pointer.
137+
* @param err Error value. 0 on success, GATT error on positive
138+
* value or errno on negative value.
139+
* @param bearers The bearers found.
140+
*/
141+
void (*discover)(struct bt_ccp_call_control_client *client, int err,
142+
struct bt_ccp_call_control_client_bearers *bearers);
143+
144+
/** @internal Internally used field for list handling */
145+
sys_snode_t _node;
146+
};
147+
148+
int bt_ccp_call_control_client_discover(struct bt_conn *conn,
149+
struct bt_ccp_call_control_client **out_client);
150+
151+
/**
152+
* @brief Register callbacks for the Call Control Client
153+
*
154+
* @param cb The callback struct
155+
*
156+
* @retval 0 Succsss
157+
* @retval -EINVAL @p cb is NULL
158+
* @retval -EEXISTS @p cb is already registered
159+
*/
160+
int bt_ccp_call_control_client_register_cb(struct bt_ccp_call_control_client_cb *cb);
161+
162+
/**
163+
* @brief Unregister callbacks for the Call Control Client
164+
*
165+
* @param cb The callback struct
166+
*
167+
* @retval 0 Succsss
168+
* @retval -EINVAL @p cb is NULL
169+
* @retval -EALREADY @p cb is not registered
170+
*/
171+
int bt_ccp_call_control_client_unregister_cb(struct bt_ccp_call_control_client_cb *cb);
172+
/** @} */ /* End of group bt_ccp_call_control_client */
93173
#ifdef __cplusplus
94174
}
95175
#endif
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(ccp_call_control_client)
6+
7+
target_sources(app PRIVATE
8+
src/main.c
9+
)
10+
11+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2023 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source "share/sysbuild/Kconfig"
5+
6+
config NET_CORE_BOARD
7+
string
8+
default "nrf5340dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340dk"
9+
default "nrf5340_audio_dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340_audio_dk"
10+
default "nrf5340bsim/nrf5340/cpunet" if $(BOARD_TARGET_STRING) = "NRF5340BSIM_NRF5340_CPUAPP"
11+
12+
config NET_CORE_IMAGE_HCI_IPC
13+
bool "HCI IPC image on network core"
14+
default y
15+
depends on NET_CORE_BOARD != ""
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.. zephyr:code-sample:: bluetooth_ccp_call_control_client
2+
:name: Call Control Profile (CCP) Call Control Server
3+
:relevant-api: bluetooth bt_ccp bt_tbs
4+
5+
CCP Call Control Server sample that registers one or more TBS bearers and advertises the
6+
TBS UUID(s).
7+
8+
Overview
9+
********
10+
11+
Application demonstrating the CCP Call Control Client functionality.
12+
Starts by scanning for a CCP Call Control Server to connect and set up calls.
13+
14+
The profile works for both GAP Central and GAP Peripheral devices, but this sample only assumes the
15+
GAP Central role.
16+
17+
This sample can be found under :zephyr_file:`samples/bluetooth/ccp_call_control_client`
18+
in the Zephyr tree.
19+
20+
Check the :zephyr:code-sample-category:`bluetooth` samples for general information.
21+
22+
Requirements
23+
************
24+
25+
* BlueZ running on the host, or
26+
* A board with Bluetooth Low Energy 5.2 support
27+
28+
Building and Running
29+
********************
30+
31+
When building targeting an nrf52 series board with the Zephyr Bluetooth Controller,
32+
use ``-DOVERLAY_CONFIG=overlay-bt_ll_sw_split.conf`` to enable the required feature support.
33+
34+
Building for an nrf5340dk
35+
-------------------------
36+
37+
You can build both the application core image and an appropriate controller image for the network
38+
core with:
39+
40+
.. zephyr-app-commands::
41+
:zephyr-app: samples/bluetooth/ccp_call_control_client/
42+
:board: nrf5340dk/nrf5340/cpuapp
43+
:goals: build
44+
:west-args: --sysbuild
45+
46+
If you prefer to only build the application core image, you can do so by doing instead:
47+
48+
.. zephyr-app-commands::
49+
:zephyr-app: samples/bluetooth/ccp_call_control_client/
50+
:board: nrf5340dk/nrf5340/cpuapp
51+
:goals: build
52+
53+
In that case you can pair this application core image with the
54+
:zephyr:code-sample:`bluetooth_hci_ipc` sample
55+
:zephyr_file:`samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf` configuration.
56+
57+
Building for a simulated nrf5340bsim
58+
------------------------------------
59+
60+
Similarly to how you would for real HW, you can do:
61+
62+
.. zephyr-app-commands::
63+
:zephyr-app: samples/bluetooth/ccp_call_control_client/
64+
:board: nrf5340bsim/nrf5340/cpuapp
65+
:goals: build
66+
:west-args: --sysbuild
67+
68+
Note this will produce a Linux executable in :file:`./build/zephyr/zephyr.exe`.
69+
For more information, check :ref:`this board documentation <nrf5340bsim>`.
70+
71+
Building for a simulated nrf52_bsim
72+
-----------------------------------
73+
74+
.. zephyr-app-commands::
75+
:zephyr-app: samples/bluetooth/ccp_call_control_client/
76+
:board: nrf52_bsim
77+
:goals: build
78+
:gen-args: -DOVERLAY_CONFIG=overlay-bt_ll_sw_split.conf
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_BT_BUF_EVT_RX_SIZE=255
2+
CONFIG_BT_BUF_ACL_RX_SIZE=255
3+
CONFIG_BT_BUF_ACL_TX_SIZE=251
4+
CONFIG_BT_BUF_CMD_TX_SIZE=255
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_BT_BUF_EVT_RX_SIZE=255
2+
CONFIG_BT_BUF_ACL_RX_SIZE=255
3+
CONFIG_BT_BUF_ACL_TX_SIZE=251
4+
CONFIG_BT_BUF_CMD_TX_SIZE=255
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Zephyr Bluetooth Controller
2+
CONFIG_BT_LL_SW_SPLIT=y
3+
4+
# Zephyr Controller tested maximum advertising data that can be set in a single HCI command
5+
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191
6+
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CONFIG_BT=y
2+
CONFIG_LOG=y
3+
CONFIG_BT_CENTRAL=y
4+
CONFIG_BT_GATT_CLIENT=y
5+
CONFIG_BT_GATT_AUTO_DISCOVER_CCC=y
6+
CONFIG_BT_AUDIO=y
7+
CONFIG_BT_EXT_ADV=y
8+
CONFIG_BT_DEVICE_NAME="CCP Call Control Client"
9+
10+
CONFIG_BT_SMP=y
11+
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
12+
13+
# CCP support
14+
CONFIG_BT_CCP_CALL_CONTROL_CLIENT=y
15+
CONFIG_BT_CCP_CALL_CONTROL_CLIENT_BEARER_COUNT=2
16+
CONFIG_BT_TBS_CLIENT_GTBS=y
17+
CONFIG_BT_TBS_CLIENT_TBS=y
18+
CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES=1
19+
CONFIG_UTF8=y
20+
21+
# TBS Client may require up to 12 buffers
22+
CONFIG_BT_ATT_TX_COUNT=12

0 commit comments

Comments
 (0)