1 /** @file
2  *  @brief Public APIs for Bluetooth Telephone Bearer Service.
3  *
4  * Copyright (c) 2020 Bose Corporation
5  * Copyright (c) 2021 Nordic Semiconductor ASA
6  *
7  * SPDX-License-Identifier: Apache-2.0
8  */
9 
10 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_
11 #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_
12 
13 #include <stdint.h>
14 #include <stdbool.h>
15 
16 #include <zephyr/bluetooth/conn.h>
17 
18 /* Call States */
19 #define BT_TBS_CALL_STATE_INCOMING                      0x00
20 #define BT_TBS_CALL_STATE_DIALING                       0x01
21 #define BT_TBS_CALL_STATE_ALERTING                      0x02
22 #define BT_TBS_CALL_STATE_ACTIVE                        0x03
23 #define BT_TBS_CALL_STATE_LOCALLY_HELD                  0x04
24 #define BT_TBS_CALL_STATE_REMOTELY_HELD                 0x05
25 #define BT_TBS_CALL_STATE_LOCALLY_AND_REMOTELY_HELD     0x06
26 
27 /* Terminate Reason */
28 #define BT_TBS_REASON_BAD_REMOTE_URI                    0x00
29 #define BT_TBS_REASON_CALL_FAILED                       0x01
30 #define BT_TBS_REASON_REMOTE_ENDED_CALL                 0x02
31 #define BT_TBS_REASON_SERVER_ENDED_CALL                 0x03
32 #define BT_TBS_REASON_LINE_BUSY                         0x04
33 #define BT_TBS_REASON_NETWORK_CONGESTED                 0x05
34 #define BT_TBS_REASON_CLIENT_TERMINATED                 0x06
35 #define BT_TBS_REASON_UNSPECIFIED                       0x07
36 
37 /* Application error codes */
38 #define BT_TBS_RESULT_CODE_SUCCESS                      0x00
39 #define BT_TBS_RESULT_CODE_OPCODE_NOT_SUPPORTED         0x01
40 #define BT_TBS_RESULT_CODE_OPERATION_NOT_POSSIBLE       0x02
41 #define BT_TBS_RESULT_CODE_INVALID_CALL_INDEX           0x03
42 #define BT_TBS_RESULT_CODE_STATE_MISMATCH               0x04
43 #define BT_TBS_RESULT_CODE_OUT_OF_RESOURCES             0x05
44 #define BT_TBS_RESULT_CODE_INVALID_URI                  0x06
45 
46 #define BT_TBS_FEATURE_HOLD                             BIT(0)
47 #define BT_TBS_FEATURE_JOIN                             BIT(1)
48 
49 #define BT_TBS_CALL_FLAG_SET_INCOMING(flag)            (flag &= ~BIT(0))
50 #define BT_TBS_CALL_FLAG_SET_OUTGOING(flag)            (flag |= BIT(0))
51 
52 #define BT_TBS_SIGNAL_STRENGTH_NO_SERVICE               0
53 #define BT_TBS_SIGNAL_STRENGTH_MAX                      100
54 #define BT_TBS_SIGNAL_STRENGTH_UNKNOWN                  255
55 
56 /* Bearer Technology */
57 #define BT_TBS_TECHNOLOGY_3G                       0x01
58 #define BT_TBS_TECHNOLOGY_4G                       0x02
59 #define BT_TBS_TECHNOLOGY_LTE                      0x03
60 #define BT_TBS_TECHNOLOGY_WIFI                     0x04
61 #define BT_TBS_TECHNOLOGY_5G                       0x05
62 #define BT_TBS_TECHNOLOGY_GSM                      0x06
63 #define BT_TBS_TECHNOLOGY_CDMA                     0x07
64 #define BT_TBS_TECHNOLOGY_2G                       0x08
65 #define BT_TBS_TECHNOLOGY_WCDMA                    0x09
66 #define BT_TBS_TECHNOLOGY_IP                       0x0a
67 
68 /**
69  * @brief The GTBS index denotes whenever a callback is from a
70  * Generic Telephone Bearer Service (GTBS) instance, or
71  * whenever the client should perform on action on the GTBS instance of the
72  * server, rather than any of the specific Telephone Bearer Service instances.
73  */
74 #define BT_TBS_GTBS_INDEX                               0xFF
75 
76 /** @brief Opaque Telephone Bearer Service instance. */
77 struct bt_tbs_instance;
78 
79 /**
80  * @brief Callback function for client originating a call.
81  *
82  * @param conn          The connection used.
83  * @param call_index    The call index.
84  * @param uri           The URI. The value may change, so should be
85  *                      copied if persistence is wanted.
86  *
87  * @return true if the call request was accepted and remote party is alerted.
88  */
89 typedef bool (*bt_tbs_originate_call_cb)(struct bt_conn *conn,
90 					 uint8_t call_index,
91 					 const char *uri);
92 
93 /**
94  * @brief Callback function for client terminating a call.
95  *
96  * The call may be either terminated by the client or the server.
97  *
98  * @param conn          The connection used.
99  * @param call_index    The call index.
100  * @param reason        The termination BT_TBS_REASON_* reason.
101  */
102 typedef void (*bt_tbs_terminate_call_cb)(struct bt_conn *conn,
103 					 uint8_t call_index,
104 					 uint8_t reason);
105 
106 /**
107  * @brief Callback function for client joining calls.
108  *
109  * @param conn                  The connection used.
110  * @param call_index_count      The number of call indexes to join.
111  * @param call_indexes          The call indexes.
112  */
113 typedef void (*bt_tbs_join_calls_cb)(struct bt_conn *conn,
114 				     uint8_t call_index_count,
115 				     const uint8_t *call_indexes);
116 
117 /**
118  * @brief Callback function for client request call state change
119  *
120  * @param conn          The connection used.
121  * @param call_index    The call index.
122  */
123 typedef void (*bt_tbs_call_change_cb)(struct bt_conn *conn,
124 				      uint8_t call_index);
125 
126 /**
127  * @brief Callback function for authorizing a client.
128  *
129  * Only used if BT_TBS_AUTHORIZATION is enabled.
130  *
131  * @param conn         The connection used.
132  *
133  * @return true if authorized, false otherwise
134  */
135 typedef bool (*bt_tbs_authorize_cb)(struct bt_conn *conn);
136 
137 struct bt_tbs_cb {
138 	bt_tbs_originate_call_cb      originate_call;
139 	bt_tbs_terminate_call_cb      terminate_call;
140 	bt_tbs_call_change_cb         hold_call;
141 	bt_tbs_call_change_cb         accept_call;
142 	bt_tbs_call_change_cb         retrieve_call;
143 	bt_tbs_join_calls_cb          join_calls;
144 	bt_tbs_authorize_cb           authorize;
145 };
146 
147 /**
148  * @brief Accept an alerting call.
149  *
150  * @param call_index    The index of the call that will be accepted.
151  *
152  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
153  *                      errno value if negative.
154  */
155 int bt_tbs_accept(uint8_t call_index);
156 
157 /**
158  * @brief Hold a call.
159  *
160  * @param call_index    The index of the call that will be held.
161  *
162  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
163  *                      errno value if negative.
164  */
165 int bt_tbs_hold(uint8_t call_index);
166 
167 /**
168  * @brief Retrieve a call.
169  *
170  * @param call_index    The index of the call that will be retrieved.
171  *
172  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
173  *                      errno value if negative.
174  */
175 int bt_tbs_retrieve(uint8_t call_index);
176 
177 /**
178  * @brief Terminate a call.
179  *
180  * @param call_index    The index of the call that will be terminated.
181  *
182  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
183  *                      errno value if negative.
184  */
185 int bt_tbs_terminate(uint8_t call_index);
186 
187 /**
188  * @brief Originate a call
189  *
190  * @param[in]  bearer_index  The index of the Telephone Bearer.
191  * @param[in]  uri           The remote URI.
192  * @param[out] call_index    Pointer to a value where the new call_index will be
193  *                           stored.
194  *
195  * @return int          A call index on success (positive value),
196  *                      errno value on fail.
197  */
198 int bt_tbs_originate(uint8_t bearer_index, char *uri, uint8_t *call_index);
199 
200 /**
201  * @brief Join calls
202  *
203  * @param call_index_cnt   The number of call indexes to join
204  * @param call_indexes     Array of call indexes to join.
205  *
206  * @return int             BT_TBS_RESULT_CODE_* if positive or 0,
207  *                         errno value if negative.
208  */
209 int bt_tbs_join(uint8_t call_index_cnt, uint8_t *call_indexes);
210 
211 /**
212  * @brief Notify the server that the remote party answered the call.
213  *
214  * @param call_index    The index of the call that was answered.
215  *
216  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
217  *                      errno value if negative.
218  */
219 int bt_tbs_remote_answer(uint8_t call_index);
220 
221 /**
222  * @brief Notify the server that the remote party held the call.
223  *
224  * @param call_index    The index of the call that was held.
225  *
226  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
227  *                      errno value if negative.
228  */
229 int bt_tbs_remote_hold(uint8_t call_index);
230 
231 /**
232  * @brief Notify the server that the remote party retrieved the call.
233  *
234  * @param call_index    The index of the call that was retrieved.
235  *
236  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
237  *                      errno value if negative.
238  */
239 int bt_tbs_remote_retrieve(uint8_t call_index);
240 
241 /**
242  * @brief Notify the server that the remote party terminated the call.
243  *
244  * @param call_index    The index of the call that was terminated.
245  *
246  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
247  *                      errno value if negative.
248  */
249 int bt_tbs_remote_terminate(uint8_t call_index);
250 
251 /**
252  * @brief Notify the server of an incoming call.
253  *
254  * @param bearer_index    The index of the Telephone Bearer.
255  * @param to              The URI that is receiving the call.
256  * @param from            The URI of the remote caller.
257  * @param friendly_name   The  friendly name of the remote caller.
258  *
259  * @return int            New call index if positive or 0,
260  *                        errno value if negative.
261  */
262 int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to,
263 			   const char *from, const char *friendly_name);
264 
265 /**
266  * @brief Set a new bearer provider.
267  *
268  * @param bearer_index  The index of the Telephone Bearer or BT_TBS_GTBS_INDEX
269  *                      for GTBS.
270  * @param name          The new bearer provider name.
271  *
272  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
273  *                      errno value if negative.
274  */
275 int bt_tbs_set_bearer_provider_name(uint8_t bearer_index, const char *name);
276 
277 /**
278  * @brief Set a new bearer technology.
279  *
280  * @param bearer_index   The index of the Telephone Bearer or BT_TBS_GTBS_INDEX
281  *                       for GTBS.
282  * @param new_technology The new bearer technology.
283  *
284  * @return int           BT_TBS_RESULT_CODE_* if positive or 0,
285  *                       errno value if negative.
286  */
287 int bt_tbs_set_bearer_technology(uint8_t bearer_index, uint8_t new_technology);
288 
289 /**
290  * @brief Update the signal strength reported by the server.
291  *
292  * @param bearer_index        The index of the Telephone Bearer or
293  *                            BT_TBS_GTBS_INDEX for GTBS.
294  * @param new_signal_strength The new signal strength.
295  *
296  * @return int                BT_TBS_RESULT_CODE_* if positive or 0,
297  *                            errno value if negative.
298  */
299 int bt_tbs_set_signal_strength(uint8_t bearer_index,
300 			       uint8_t new_signal_strength);
301 
302 /**
303  * @brief Sets the feature and status value.
304  *
305  * @param bearer_index  The index of the Telephone Bearer or BT_TBS_GTBS_INDEX
306  *                      for GTBS.
307  * @param status_flags  The new feature and status value.
308  *
309  * @return int          BT_TBS_RESULT_CODE_* if positive or 0,
310  *                      errno value if negative.
311  */
312 int bt_tbs_set_status_flags(uint8_t bearer_index, uint16_t status_flags);
313 
314 /** @brief Sets the URI scheme list of a bearer.
315  *
316  *  @param bearer_index  The index of the Telephone Bearer.
317  *  @param uri_list      List of URI prefixes (e.g. {"skype", "tel"}).
318  *  @param uri_count     Number of URI prefixies in @p uri_list.
319  *
320  *  @return BT_TBS_RESULT_CODE_* if positive or 0, errno value if negative.
321  */
322 int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list,
323 			       uint8_t uri_count);
324 /**
325  * @brief Register the callbacks for TBS.
326  *
327  * @param cbs Pointer to the callback structure.
328  */
329 void bt_tbs_register_cb(struct bt_tbs_cb *cbs);
330 
331 /** @brief Prints all calls of all services to the debug log */
332 void bt_tbs_dbg_print_calls(void);
333 
334 struct bt_tbs_client_call_state {
335 	uint8_t index;
336 	uint8_t state;
337 	uint8_t flags;
338 } __packed;
339 
340 struct bt_tbs_client_call {
341 	struct bt_tbs_client_call_state call_info;
342 	char *remote_uri;
343 };
344 
345 /**
346  * @brief Callback function for ccp_discover.
347  *
348  * @param conn          The connection that was used to discover CCP for a
349  *                      device.
350  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
351  *                      GATT error or errno value.
352  * @param tbs_count     Number of TBS instances on peer device.
353  * @param gtbs_found    Whether or not the server has a Generic TBS instance.
354  */
355 typedef void (*bt_tbs_client_discover_cb)(struct bt_conn *conn, int err,
356 					  uint8_t tbs_count, bool gtbs_found);
357 
358 /**
359  * @brief Callback function for writing values to peer device.
360  *
361  * @param conn          The connection used in the function.
362  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
363  *                      GATT error or errno value.
364  * @param inst_index    The index of the TBS instance that was updated.
365  */
366 typedef void (*bt_tbs_client_write_value_cb)(struct bt_conn *conn, int err,
367 					     uint8_t inst_index);
368 
369 /**
370  * @brief Callback function for the CCP call control functions.
371  *
372  * @param conn          The connection used in the function.
373  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
374  *                      GATT error or errno value.
375  * @param inst_index    The index of the TBS instance that was updated.
376  * @param call_index    The call index. For #bt_tbs_client_originate_call this will
377  *                      always be 0, and does not reflect the actual call index.
378  */
379 typedef void (*bt_tbs_client_cp_cb)(struct bt_conn *conn, int err,
380 				    uint8_t inst_index, uint8_t call_index);
381 
382 /**
383  * @brief Callback function for functions that read a string value.
384  *
385  * @param conn          The connection used in the function.
386  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
387  *                      GATT error or errno value.
388  * @param inst_index    The index of the TBS instance that was updated.
389  * @param value         The Null-terminated string value. The value is not kept
390  *                      by the client, so must be copied to be saved.
391  */
392 typedef void (*bt_tbs_client_read_string_cb)(struct bt_conn *conn, int err,
393 					     uint8_t inst_index,
394 					     const char *value);
395 
396 /**
397  * @brief Callback function for functions that read an integer value.
398  *
399  * @param conn          The connection used in the function.
400  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
401  *                      GATT error or errno value.
402  * @param inst_index    The index of the TBS instance that was updated.
403  * @param value         The integer value.
404  */
405 typedef void (*bt_tbs_client_read_value_cb)(struct bt_conn *conn, int err,
406 					    uint8_t inst_index, uint32_t value);
407 
408 /**
409  * @brief Callback function for ccp_read_termination_reason.
410  *
411  * @param conn          The connection used in the function.
412  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
413  *                      GATT error or errno value.
414  * @param inst_index    The index of the TBS instance that was updated.
415  * @param call_index    The call index.
416  * @param reason        The termination reason.
417  */
418 typedef void (*bt_tbs_client_termination_reason_cb)(struct bt_conn *conn,
419 						    int err, uint8_t inst_index,
420 						    uint8_t call_index,
421 						    uint8_t reason);
422 
423 /**
424  * @brief Callback function for ccp_read_current_calls.
425  *
426  * @param conn          The connection used in the function.
427  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
428  *                      GATT error or errno value.
429  * @param inst_index    The index of the TBS instance that was updated.
430  * @param call_count    Number of calls read.
431  * @param calls         Array of calls. The array is not kept by
432  *                      the client, so must be copied to be saved.
433  */
434 typedef void (*bt_tbs_client_current_calls_cb)(struct bt_conn *conn, int err,
435 					       uint8_t inst_index,
436 					       uint8_t call_count,
437 					       const struct bt_tbs_client_call *calls);
438 
439 /**
440  * @brief Callback function for ccp_read_call_state.
441  *
442  * @param conn          The connection used in the function.
443  * @param err           Error value. BT_TBS_CLIENT_RESULT_CODE_*,
444  *                      GATT error or errno value.
445  * @param inst_index    The index of the TBS instance that was updated.
446  * @param call_count    Number of call states read.
447  * @param call_states   Array of call states. The array is not kept by
448  *                      the client, so must be copied to be saved.
449  */
450 typedef void (*bt_tbs_client_call_states_cb)(struct bt_conn *conn, int err,
451 					     uint8_t inst_index,
452 					     uint8_t call_count,
453 					     const struct bt_tbs_client_call_state *call_states);
454 
455 struct bt_tbs_client_cb {
456 	bt_tbs_client_discover_cb            discover;
457 #if defined(CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL)
458 	bt_tbs_client_cp_cb                  originate_call;
459 #endif /* defined(CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL) */
460 #if defined(CONFIG_BT_TBS_CLIENT_TERMINATE_CALL)
461 	bt_tbs_client_cp_cb                  terminate_call;
462 #endif /* defined(CONFIG_BT_TBS_CLIENT_TERMINATE_CALL) */
463 #if defined(CONFIG_BT_TBS_CLIENT_HOLD_CALL)
464 	bt_tbs_client_cp_cb                  hold_call;
465 #endif /* defined(CONFIG_BT_TBS_CLIENT_HOLD_CALL) */
466 #if defined(CONFIG_BT_TBS_CLIENT_ACCEPT_CALL)
467 	bt_tbs_client_cp_cb                  accept_call;
468 #endif /* defined(CONFIG_BT_TBS_CLIENT_ACCEPT_CALL) */
469 #if defined(CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL)
470 	bt_tbs_client_cp_cb                  retrieve_call;
471 #endif /* defined(CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL) */
472 #if defined(CONFIG_BT_TBS_CLIENT_JOIN_CALLS)
473 	bt_tbs_client_cp_cb                  join_calls;
474 #endif /* defined(CONFIG_BT_TBS_CLIENT_JOIN_CALLS) */
475 #if defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME)
476 	bt_tbs_client_read_string_cb         bearer_provider_name;
477 #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) */
478 #if defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI)
479 	bt_tbs_client_read_string_cb         bearer_uci;
480 #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) */
481 #if defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY)
482 	bt_tbs_client_read_value_cb          technology;
483 #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) */
484 #if defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST)
485 	bt_tbs_client_read_string_cb         uri_list;
486 #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST) */
487 #if defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH)
488 	bt_tbs_client_read_value_cb          signal_strength;
489 #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH) */
490 #if defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL)
491 	bt_tbs_client_read_value_cb          signal_interval;
492 #endif /* defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL) */
493 #if defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS)
494 	bt_tbs_client_current_calls_cb       current_calls;
495 #endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) */
496 #if defined(CONFIG_BT_TBS_CLIENT_CCID)
497 	bt_tbs_client_read_value_cb          ccid;
498 #endif /* defined(CONFIG_BT_TBS_CLIENT_CCID) */
499 #if defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI)
500 	bt_tbs_client_read_string_cb         call_uri;
501 #endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI) */
502 #if defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS)
503 	bt_tbs_client_read_value_cb          status_flags;
504 #endif /* defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) */
505 	bt_tbs_client_call_states_cb         call_state;
506 #if defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES)
507 	bt_tbs_client_read_value_cb          optional_opcodes;
508 #endif /* defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES) */
509 	bt_tbs_client_termination_reason_cb  termination_reason;
510 #if defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL)
511 	bt_tbs_client_read_string_cb         remote_uri;
512 #endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL) */
513 #if defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME)
514 	bt_tbs_client_read_string_cb         friendly_name;
515 #endif /* defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) */
516 };
517 
518 /**
519  * @brief Discover TBS for a connection. This will start a GATT
520  * discover and setup handles and subscriptions.
521  *
522  * @param conn          The connection to discover TBS for.
523  *
524  * @return int          0 on success, GATT error value on fail.
525  */
526 int bt_tbs_client_discover(struct bt_conn *conn);
527 
528 /**
529  * @brief Set the outgoing URI for a TBS instance on the peer device.
530  *
531  * @param conn          The connection to the TBS server.
532  * @param inst_index    The index of the TBS instance.
533  * @param uri           The Null-terminated URI string.
534  *
535  * @return int          0 on success, errno value on fail.
536  */
537 int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index,
538 				   const char *uri);
539 
540 /**
541  * @brief Set the signal strength reporting interval for a TBS instance.
542  *
543  * @param conn          The connection to the TBS server.
544  * @param inst_index    The index of the TBS instance.
545  * @param interval      The interval to write (0-255 seconds).
546  *
547  * @return int          0 on success, errno value on fail.
548  *
549  * @note @kconfig{CONFIG_BT_TBS_CLIENT_SET_BEARER_SIGNAL_INTERVAL} must be set
550  * for this function to be effective.
551  */
552 int bt_tbs_client_set_signal_strength_interval(struct bt_conn *conn,
553 					       uint8_t inst_index,
554 					       uint8_t interval);
555 
556 /**
557  * @brief Request to originate a call.
558  *
559  * @param conn          The connection to the TBS server.
560  * @param inst_index    The index of the TBS instance.
561  * @param uri           The URI of the callee.
562  *
563  * @return int          0 on success, errno value on fail.
564  *
565  * @note @kconfig{CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL} must be set
566  * for this function to be effective.
567  */
568 int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index,
569 				 const char *uri);
570 
571 /**
572  * @brief Request to terminate a call
573  *
574  * @param conn          The connection to the TBS server.
575  * @param inst_index    The index of the TBS instance.
576  * @param call_index    The call index to terminate.
577  *
578  * @return int          0 on success, errno value on fail.
579  *
580  * @note @kconfig{CONFIG_BT_TBS_CLIENT_TERMINATE_CALL} must be set
581  * for this function to be effective.
582  */
583 int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index,
584 				 uint8_t call_index);
585 
586 /**
587  * @brief Request to hold a call
588  *
589  * @param conn          The connection to the TBS server.
590  * @param inst_index    The index of the TBS instance.
591  * @param call_index    The call index to place on hold.
592  *
593  * @return int          0 on success, errno value on fail.
594  *
595  * @note @kconfig{CONFIG_BT_TBS_CLIENT_HOLD_CALL} must be set
596  * for this function to be effective.
597  */
598 int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index,
599 			    uint8_t call_index);
600 
601 /**
602  * @brief Accept an incoming call
603  *
604  * @param conn          The connection to the TBS server.
605  * @param inst_index    The index of the TBS instance.
606  * @param call_index    The call index to accept.
607  *
608  * @return int          0 on success, errno value on fail.
609  *
610  * @note @kconfig{CONFIG_BT_TBS_CLIENT_ACCEPT_CALL} must be set
611  * for this function to be effective.
612  */
613 int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index,
614 			      uint8_t call_index);
615 
616 /**
617  * @brief Retrieve call from (local) hold.
618  *
619  * @param conn          The connection to the TBS server.
620  * @param inst_index    The index of the TBS instance.
621  * @param call_index    The call index to retrieve.
622  *
623  * @return int          0 on success, errno value on fail.
624  *
625  * @note @kconfig{CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL} must be set
626  * for this function to be effective.
627  */
628 int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index,
629 				uint8_t call_index);
630 
631 /**
632  * @brief Join multiple calls.
633  *
634  * @param conn          The connection to the TBS server.
635  * @param inst_index    The index of the TBS instance.
636  * @param call_indexes  Array of call indexes.
637  * @param count         Number of call indexes in the call_indexes array.
638  *
639  * @return int          0 on success, errno value on fail.
640  *
641  * @note @kconfig{CONFIG_BT_TBS_CLIENT_JOIN_CALLS} must be set
642  * for this function to be effective.
643  */
644 int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index,
645 			     const uint8_t *call_indexes, uint8_t count);
646 
647 /**
648  * @brief Read the bearer provider name of a TBS instance.
649  *
650  * @param conn          The connection to the TBS server.
651  * @param inst_index    The index of the TBS instance.
652  *
653  * @return int          0 on success, errno value on fail.
654  *
655  * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME} must be set
656  * for this function to be effective.
657  */
658 int bt_tbs_client_read_bearer_provider_name(struct bt_conn *conn,
659 					    uint8_t inst_index);
660 
661 /**
662  * @brief Read the UCI of a TBS instance.
663  *
664  * @param conn          The connection to the TBS server.
665  * @param inst_index    The index of the TBS instance.
666  *
667  * @return int          0 on success, errno value on fail.
668  *
669  * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_UCI} must be set
670  * for this function to be effective.
671  */
672 int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index);
673 
674 /**
675  * @brief Read the technology of a TBS instance.
676  *
677  * @param conn          The connection to the TBS server.
678  * @param inst_index    The index of the TBS instance.
679  *
680  * @return int          0 on success, errno value on fail.
681  *
682  * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY} must be set
683  * for this function to be effective.
684  */
685 int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index);
686 
687 /**
688  * @brief Read the URI schemes list of a TBS instance.
689  *
690  * @param conn          The connection to the TBS server.
691  * @param inst_index    The index of the TBS instance.
692  *
693  * @return int          0 on success, errno value on fail.
694  *
695  * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST} must be set
696  * for this function to be effective.
697  */
698 int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index);
699 
700 /**
701  * @brief Read the current signal strength of a TBS instance.
702  *
703  * @param conn          The connection to the TBS server.
704  * @param inst_index    The index of the TBS instance.
705  *
706  * @return              int 0 on success, errno value on fail.
707  *
708  * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH} must be set
709  * for this function to be effective.
710  */
711 int bt_tbs_client_read_signal_strength(struct bt_conn *conn,
712 				       uint8_t inst_index);
713 
714 /**
715  * @brief Read the signal strength reporting interval of a TBS instance.
716  *
717  * @param conn          The connection to the TBS server.
718  * @param inst_index    The index of the TBS instance.
719  *
720  * @return              int 0 on success, errno value on fail.
721  *
722  * @note @kconfig{CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL} must be set
723  * for this function to be effective.
724  */
725 int bt_tbs_client_read_signal_interval(struct bt_conn *conn,
726 				       uint8_t inst_index);
727 
728 /**
729  * @brief Read the list of current calls of a TBS instance.
730  *
731  * @param conn          The connection to the TBS server.
732  * @param inst_index    The index of the TBS instance.
733  *
734  * @return              int 0 on success, errno value on fail.
735  *
736  * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS} must be set
737  * for this function to be effective.
738  */
739 int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index);
740 
741 /**
742  * @brief Read the content ID of a TBS instance.
743  *
744  * @param conn          The connection to the TBS server.
745  * @param inst_index    The index of the TBS instance.
746  *
747  * @return              int 0 on success, errno value on fail.
748  *
749  * @note @kconfig{CONFIG_BT_TBS_CLIENT_CCID} must be set
750  * for this function to be effective.
751  */
752 int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index);
753 
754 /**
755  * @brief Read the call target URI of a TBS instance.
756  *
757  * @param conn          The connection to the TBS server.
758  * @param inst_index    The index of the TBS instance.
759  *
760  * @return              int 0 on success, errno value on fail.
761  *
762  * @note @kconfig{CONFIG_BT_TBS_CLIENT_INCOMING_URI} must be set
763  * for this function to be effective.
764  */
765 int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index);
766 
767 /**
768  * @brief Read the feature and status value of a TBS instance.
769  *
770  * @param conn          The connection to the TBS server.
771  * @param inst_index    The index of the TBS instance.
772  *
773  * @return              int 0 on success, errno value on fail.
774  *
775  * @note @kconfig{CONFIG_BT_TBS_CLIENT_STATUS_FLAGS} must be set
776  * for this function to be effective.
777  */
778 int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index);
779 
780 /**
781  * @brief Read the states of the current calls of a TBS instance.
782  *
783  * @param conn          The connection to the TBS server.
784  * @param inst_index    The index of the TBS instance.
785  *
786  * @return              int 0 on success, errno value on fail.
787  */
788 int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index);
789 
790 /**
791  * @brief Read the remote URI of a TBS instance.
792  *
793  * @param conn          The connection to the TBS server.
794  * @param inst_index    The index of the TBS instance.
795  *
796  * @return              int 0 on success, errno value on fail.
797  *
798  * @note @kconfig{CONFIG_BT_TBS_CLIENT_INCOMING_CALL} must be set
799  * for this function to be effective.
800  */
801 int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index);
802 
803 /**
804  * @brief Read the friendly name of a call for a TBS instance.
805  *
806  * @param conn          The connection to the TBS server.
807  * @param inst_index    The index of the TBS instance.
808  *
809  * @return              int 0 on success, errno value on fail.
810  *
811  * @note @kconfig{CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME} must be set
812  * for this function to be effective.
813  */
814 int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index);
815 
816 /** @brief Read the supported opcode of a TBS instance.
817  *
818  *  @param conn          The connection to the TBS server.
819  *  @param inst_index    The index of the TBS instance.
820  *
821  *  @return              int 0 on success, errno value on fail.
822  *
823  * @note @kconfig{CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES} must be set
824  * for this function to be effective.
825  */
826 int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn,
827 					uint8_t inst_index);
828 
829 /**
830  * @brief Register the callbacks for CCP.
831  *
832  * @param cbs Pointer to the callback structure.
833  */
834 void bt_tbs_client_register_cb(const struct bt_tbs_client_cb *cbs);
835 
836 /**
837  * @brief Look up Telephone Bearer Service instance by CCID
838  *
839  * @param conn  The connection to the TBS server.
840  * @param ccid  The CCID to lookup a service instance for.
841  *
842  * @return Pointer to a Telephone Bearer Service instance if found else NULL.
843  *
844  * @note @kconfig{CONFIG_BT_TBS_CLIENT_CCID} must be set
845  * for this function to be effective.
846  */
847 struct bt_tbs_instance *bt_tbs_client_get_by_ccid(const struct bt_conn *conn,
848 						  uint8_t ccid);
849 
850 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_ */
851