Zephyr Project API  3.3.0
A Scalable Open Source RTOS
tbs.h
Go to the documentation of this file.
1
10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_
12
13#include <zephyr/types.h>
15
16/* Call States */
17#define BT_TBS_CALL_STATE_INCOMING 0x00
18#define BT_TBS_CALL_STATE_DIALING 0x01
19#define BT_TBS_CALL_STATE_ALERTING 0x02
20#define BT_TBS_CALL_STATE_ACTIVE 0x03
21#define BT_TBS_CALL_STATE_LOCALLY_HELD 0x04
22#define BT_TBS_CALL_STATE_REMOTELY_HELD 0x05
23#define BT_TBS_CALL_STATE_LOCALLY_AND_REMOTELY_HELD 0x06
24
25/* Terminate Reason */
26#define BT_TBS_REASON_BAD_REMOTE_URI 0x00
27#define BT_TBS_REASON_CALL_FAILED 0x01
28#define BT_TBS_REASON_REMOTE_ENDED_CALL 0x02
29#define BT_TBS_REASON_SERVER_ENDED_CALL 0x03
30#define BT_TBS_REASON_LINE_BUSY 0x04
31#define BT_TBS_REASON_NETWORK_CONGESTED 0x05
32#define BT_TBS_REASON_CLIENT_TERMINATED 0x06
33#define BT_TBS_REASON_UNSPECIFIED 0x07
34
35/* Application error codes */
36#define BT_TBS_RESULT_CODE_SUCCESS 0x00
37#define BT_TBS_RESULT_CODE_OPCODE_NOT_SUPPORTED 0x01
38#define BT_TBS_RESULT_CODE_OPERATION_NOT_POSSIBLE 0x02
39#define BT_TBS_RESULT_CODE_INVALID_CALL_INDEX 0x03
40#define BT_TBS_RESULT_CODE_STATE_MISMATCH 0x04
41#define BT_TBS_RESULT_CODE_OUT_OF_RESOURCES 0x05
42#define BT_TBS_RESULT_CODE_INVALID_URI 0x06
43
44#define BT_TBS_FEATURE_HOLD BIT(0)
45#define BT_TBS_FEATURE_JOIN BIT(1)
46
47#define BT_TBS_CALL_FLAG_SET_INCOMING(flag) (flag &= ~BIT(0))
48#define BT_TBS_CALL_FLAG_SET_OUTGOING(flag) (flag |= BIT(0))
49
50#define BT_TBS_SIGNAL_STRENGTH_NO_SERVICE 0
51#define BT_TBS_SIGNAL_STRENGTH_MAX 100
52#define BT_TBS_SIGNAL_STRENGTH_UNKNOWN 255
53
54/* Bearer Technology */
55#define BT_TBS_TECHNOLOGY_3G 0x01
56#define BT_TBS_TECHNOLOGY_4G 0x02
57#define BT_TBS_TECHNOLOGY_LTE 0x03
58#define BT_TBS_TECHNOLOGY_WIFI 0x04
59#define BT_TBS_TECHNOLOGY_5G 0x05
60#define BT_TBS_TECHNOLOGY_GSM 0x06
61#define BT_TBS_TECHNOLOGY_CDMA 0x07
62#define BT_TBS_TECHNOLOGY_2G 0x08
63#define BT_TBS_TECHNOLOGY_WCDMA 0x09
64#define BT_TBS_TECHNOLOGY_IP 0x0a
65
72#define BT_TBS_GTBS_INDEX 0xFF
73
75struct bt_tbs_instance;
76
87typedef bool (*bt_tbs_originate_call_cb)(struct bt_conn *conn,
88 uint8_t call_index,
89 const char *uri);
90
100typedef void (*bt_tbs_terminate_call_cb)(struct bt_conn *conn,
101 uint8_t call_index,
102 uint8_t reason);
103
111typedef void (*bt_tbs_join_calls_cb)(struct bt_conn *conn,
112 uint8_t call_index_count,
113 const uint8_t *call_indexes);
114
121typedef void (*bt_tbs_call_change_cb)(struct bt_conn *conn,
122 uint8_t call_index);
123
133typedef bool (*bt_tbs_authorize_cb)(struct bt_conn *conn);
134
135struct bt_tbs_cb {
143};
144
153int bt_tbs_accept(uint8_t call_index);
154
163int bt_tbs_hold(uint8_t call_index);
164
173int bt_tbs_retrieve(uint8_t call_index);
174
183int bt_tbs_terminate(uint8_t call_index);
184
196int bt_tbs_originate(uint8_t bearer_index, char *uri, uint8_t *call_index);
197
207int bt_tbs_join(uint8_t call_index_cnt, uint8_t *call_indexes);
208
218
228
238
248
260int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to,
261 const char *from, const char *friendly_name);
262
273int bt_tbs_set_bearer_provider_name(uint8_t bearer_index, const char *name);
274
285int bt_tbs_set_bearer_technology(uint8_t bearer_index, uint8_t new_technology);
286
298 uint8_t new_signal_strength);
299
310int bt_tbs_set_status_flags(uint8_t bearer_index, uint16_t status_flags);
311
320int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list,
321 uint8_t uri_count);
328
331
336} __packed;
337
341};
342
353typedef void (*bt_tbs_client_discover_cb)(struct bt_conn *conn, int err,
354 uint8_t tbs_count, bool gtbs_found);
355
364typedef void (*bt_tbs_client_write_value_cb)(struct bt_conn *conn, int err,
365 uint8_t inst_index);
366
377typedef void (*bt_tbs_client_cp_cb)(struct bt_conn *conn, int err,
378 uint8_t inst_index, uint8_t call_index);
379
390typedef void (*bt_tbs_client_read_string_cb)(struct bt_conn *conn, int err,
391 uint8_t inst_index,
392 const char *value);
393
403typedef void (*bt_tbs_client_read_value_cb)(struct bt_conn *conn, int err,
404 uint8_t inst_index, uint32_t value);
405
416typedef void (*bt_tbs_client_termination_reason_cb)(struct bt_conn *conn,
417 int err, uint8_t inst_index,
418 uint8_t call_index,
419 uint8_t reason);
420
432typedef void (*bt_tbs_client_current_calls_cb)(struct bt_conn *conn, int err,
433 uint8_t inst_index,
434 uint8_t call_count,
435 const struct bt_tbs_client_call *calls);
436
448typedef void (*bt_tbs_client_call_states_cb)(struct bt_conn *conn, int err,
449 uint8_t inst_index,
450 uint8_t call_count,
451 const struct bt_tbs_client_call_state *call_states);
452
455#if defined(CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL)
456 bt_tbs_client_cp_cb originate_call;
457#endif /* defined(CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL) */
458#if defined(CONFIG_BT_TBS_CLIENT_TERMINATE_CALL)
459 bt_tbs_client_cp_cb terminate_call;
460#endif /* defined(CONFIG_BT_TBS_CLIENT_TERMINATE_CALL) */
461#if defined(CONFIG_BT_TBS_CLIENT_HOLD_CALL)
462 bt_tbs_client_cp_cb hold_call;
463#endif /* defined(CONFIG_BT_TBS_CLIENT_HOLD_CALL) */
464#if defined(CONFIG_BT_TBS_CLIENT_ACCEPT_CALL)
465 bt_tbs_client_cp_cb accept_call;
466#endif /* defined(CONFIG_BT_TBS_CLIENT_ACCEPT_CALL) */
467#if defined(CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL)
468 bt_tbs_client_cp_cb retrieve_call;
469#endif /* defined(CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL) */
470#if defined(CONFIG_BT_TBS_CLIENT_JOIN_CALLS)
471 bt_tbs_client_cp_cb join_calls;
472#endif /* defined(CONFIG_BT_TBS_CLIENT_JOIN_CALLS) */
473#if defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME)
474 bt_tbs_client_read_string_cb bearer_provider_name;
475#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) */
476#if defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI)
478#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) */
479#if defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY)
481#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) */
482#if defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST)
484#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST) */
485#if defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH)
486 bt_tbs_client_read_value_cb signal_strength;
487#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH) */
488#if defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL)
489 bt_tbs_client_read_value_cb signal_interval;
490#endif /* defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL) */
491#if defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS)
492 bt_tbs_client_current_calls_cb current_calls;
493#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) */
494#if defined(CONFIG_BT_TBS_CLIENT_CCID)
496#endif /* defined(CONFIG_BT_TBS_CLIENT_CCID) */
497#if defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI)
499#endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI) */
500#if defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS)
501 bt_tbs_client_read_value_cb status_flags;
502#endif /* defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) */
504#if defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES)
505 bt_tbs_client_read_value_cb optional_opcodes;
506#endif /* defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES) */
508#if defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL)
510#endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL) */
511#if defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME)
512 bt_tbs_client_read_string_cb friendly_name;
513#endif /* defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) */
514};
515
525int bt_tbs_client_discover(struct bt_conn *conn, bool subscribe);
526
536int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index,
537 const char *uri);
538
552 uint8_t inst_index,
553 uint8_t interval);
554
567int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index,
568 const char *uri);
569
582int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index,
583 uint8_t call_index);
584
597int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index,
598 uint8_t call_index);
599
612int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index,
613 uint8_t call_index);
614
627int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index,
628 uint8_t call_index);
629
643int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index,
644 const uint8_t *call_indexes, uint8_t count);
645
658 uint8_t inst_index);
659
671int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index);
672
684int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index);
685
697int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index);
698
710int bt_tbs_client_read_signal_strength(struct bt_conn *conn,
711 uint8_t inst_index);
712
724int bt_tbs_client_read_signal_interval(struct bt_conn *conn,
725 uint8_t inst_index);
726
738int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index);
739
751int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index);
752
764int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index);
765
777int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index);
778
787int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index);
788
800int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index);
801
813int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index);
814
825int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn,
826 uint8_t inst_index);
827
834
846struct bt_tbs_instance *bt_tbs_client_get_by_ccid(const struct bt_conn *conn,
847 uint8_t ccid);
848
849#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_ */
ZTEST_BMEM int count
Definition: main.c:33
Bluetooth connection handling.
#define bool
Definition: stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Definition: tbs.h:135
bt_tbs_originate_call_cb originate_call
Definition: tbs.h:136
bt_tbs_call_change_cb accept_call
Definition: tbs.h:139
bt_tbs_call_change_cb hold_call
Definition: tbs.h:138
bt_tbs_terminate_call_cb terminate_call
Definition: tbs.h:137
bt_tbs_authorize_cb authorize
Definition: tbs.h:142
bt_tbs_join_calls_cb join_calls
Definition: tbs.h:141
bt_tbs_call_change_cb retrieve_call
Definition: tbs.h:140
Definition: tbs.h:332
uint8_t index
Definition: tbs.h:333
uint8_t state
Definition: tbs.h:334
uint8_t flags
Definition: tbs.h:335
Definition: tbs.h:338
struct bt_tbs_client_call_state call_info
Definition: tbs.h:339
char * remote_uri
Definition: tbs.h:340
Definition: tbs.h:453
bt_tbs_client_call_states_cb call_state
Definition: tbs.h:503
bt_tbs_client_discover_cb discover
Definition: tbs.h:454
bt_tbs_client_termination_reason_cb termination_reason
Definition: tbs.h:507
int bt_tbs_remote_retrieve(uint8_t call_index)
Notify the server that the remote party retrieved the call.
int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index, const char *uri)
Request to originate a call.
int bt_tbs_accept(uint8_t call_index)
Accept an alerting call.
bool(* bt_tbs_authorize_cb)(struct bt_conn *conn)
Callback function for authorizing a client.
Definition: tbs.h:133
int bt_tbs_client_read_bearer_provider_name(struct bt_conn *conn, uint8_t inst_index)
Read the bearer provider name of a TBS instance.
int bt_tbs_join(uint8_t call_index_cnt, uint8_t *call_indexes)
Join calls.
int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index, uint8_t call_index)
Request to hold a call.
int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index, uint8_t call_index)
Request to terminate a call.
void(* bt_tbs_client_call_states_cb)(struct bt_conn *conn, int err, uint8_t inst_index, uint8_t call_count, const struct bt_tbs_client_call_state *call_states)
Callback function for ccp_read_call_state.
Definition: tbs.h:448
void(* bt_tbs_call_change_cb)(struct bt_conn *conn, uint8_t call_index)
Callback function for client request call state change.
Definition: tbs.h:121
void bt_tbs_client_register_cb(const struct bt_tbs_client_cb *cbs)
Register the callbacks for CCP.
int bt_tbs_client_read_signal_interval(struct bt_conn *conn, uint8_t inst_index)
Read the signal strength reporting interval of a TBS instance.
int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index, const char *uri)
Set the outgoing URI for a TBS instance on the peer device.
void(* bt_tbs_client_cp_cb)(struct bt_conn *conn, int err, uint8_t inst_index, uint8_t call_index)
Callback function for the CCP call control functions.
Definition: tbs.h:377
int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index)
Read the call target URI of a TBS instance.
int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to, const char *from, const char *friendly_name)
Notify the server of an incoming call.
void(* bt_tbs_client_read_string_cb)(struct bt_conn *conn, int err, uint8_t inst_index, const char *value)
Callback function for functions that read a string value.
Definition: tbs.h:390
int bt_tbs_set_bearer_provider_name(uint8_t bearer_index, const char *name)
Set a new bearer provider.
int bt_tbs_remote_terminate(uint8_t call_index)
Notify the server that the remote party terminated the call.
int bt_tbs_remote_hold(uint8_t call_index)
Notify the server that the remote party held the call.
void(* bt_tbs_client_read_value_cb)(struct bt_conn *conn, int err, uint8_t inst_index, uint32_t value)
Callback function for functions that read an integer value.
Definition: tbs.h:403
bool(* bt_tbs_originate_call_cb)(struct bt_conn *conn, uint8_t call_index, const char *uri)
Callback function for client originating a call.
Definition: tbs.h:87
int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index, uint8_t call_index)
Accept an incoming call.
void bt_tbs_dbg_print_calls(void)
Prints all calls of all services to the debug log.
void(* bt_tbs_terminate_call_cb)(struct bt_conn *conn, uint8_t call_index, uint8_t reason)
Callback function for client terminating a call.
Definition: tbs.h:100
int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index)
Read the technology of a TBS instance.
void bt_tbs_register_cb(struct bt_tbs_cb *cbs)
Register the callbacks for TBS.
void(* bt_tbs_client_current_calls_cb)(struct bt_conn *conn, int err, uint8_t inst_index, uint8_t call_count, const struct bt_tbs_client_call *calls)
Callback function for ccp_read_current_calls.
Definition: tbs.h:432
int bt_tbs_terminate(uint8_t call_index)
Terminate a call.
int bt_tbs_set_status_flags(uint8_t bearer_index, uint16_t status_flags)
Sets the feature and status value.
int bt_tbs_remote_answer(uint8_t call_index)
Notify the server that the remote party answered the call.
int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index)
Read the list of current calls of a TBS instance.
int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list, uint8_t uri_count)
Sets the URI scheme list of a bearer.
int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index)
Read the friendly name of a call for a TBS instance.
void(* bt_tbs_client_discover_cb)(struct bt_conn *conn, int err, uint8_t tbs_count, bool gtbs_found)
Callback function for ccp_discover.
Definition: tbs.h:353
int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index)
Read the feature and status value of a TBS instance.
int bt_tbs_client_set_signal_strength_interval(struct bt_conn *conn, uint8_t inst_index, uint8_t interval)
Set the signal strength reporting interval for a TBS instance.
void(* bt_tbs_join_calls_cb)(struct bt_conn *conn, uint8_t call_index_count, const uint8_t *call_indexes)
Callback function for client joining calls.
Definition: tbs.h:111
int bt_tbs_client_read_signal_strength(struct bt_conn *conn, uint8_t inst_index)
Read the current signal strength of a TBS instance.
struct bt_tbs_instance * bt_tbs_client_get_by_ccid(const struct bt_conn *conn, uint8_t ccid)
Look up Telephone Bearer Service instance by CCID.
int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index, const uint8_t *call_indexes, uint8_t count)
Join multiple calls.
int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index)
Read the remote URI of a TBS instance.
int bt_tbs_hold(uint8_t call_index)
Hold a call.
void(* bt_tbs_client_termination_reason_cb)(struct bt_conn *conn, int err, uint8_t inst_index, uint8_t call_index, uint8_t reason)
Callback function for ccp_read_termination_reason.
Definition: tbs.h:416
int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index)
Read the UCI of a TBS instance.
int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index, uint8_t call_index)
Retrieve call from (local) hold.
int bt_tbs_client_discover(struct bt_conn *conn, bool subscribe)
Discover TBS for a connection. This will start a GATT discover and setup handles and subscriptions.
int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index)
Read the content ID of a TBS instance.
int bt_tbs_set_signal_strength(uint8_t bearer_index, uint8_t new_signal_strength)
Update the signal strength reported by the server.
int bt_tbs_retrieve(uint8_t call_index)
Retrieve a call.
int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index)
Read the URI schemes list of a TBS instance.
int bt_tbs_originate(uint8_t bearer_index, char *uri, uint8_t *call_index)
Originate a call.
int bt_tbs_set_bearer_technology(uint8_t bearer_index, uint8_t new_technology)
Set a new bearer technology.
int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn, uint8_t inst_index)
Read the supported opcode of a TBS instance.
void(* bt_tbs_client_write_value_cb)(struct bt_conn *conn, int err, uint8_t inst_index)
Callback function for writing values to peer device.
Definition: tbs.h:364
int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index)
Read the states of the current calls of a TBS instance.