Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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 <stdint.h>
14#include <stdbool.h>
15
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
74#define BT_TBS_GTBS_INDEX 0xFF
75
77struct bt_tbs_instance;
78
89typedef bool (*bt_tbs_originate_call_cb)(struct bt_conn *conn,
90 uint8_t call_index,
91 const char *uri);
92
102typedef void (*bt_tbs_terminate_call_cb)(struct bt_conn *conn,
103 uint8_t call_index,
104 uint8_t reason);
105
113typedef void (*bt_tbs_join_calls_cb)(struct bt_conn *conn,
114 uint8_t call_index_count,
115 const uint8_t *call_indexes);
116
123typedef void (*bt_tbs_call_change_cb)(struct bt_conn *conn,
124 uint8_t call_index);
125
135typedef bool (*bt_tbs_authorize_cb)(struct bt_conn *conn);
136
137struct bt_tbs_cb {
145};
146
155int bt_tbs_accept(uint8_t call_index);
156
165int bt_tbs_hold(uint8_t call_index);
166
175int bt_tbs_retrieve(uint8_t call_index);
176
185int bt_tbs_terminate(uint8_t call_index);
186
198int bt_tbs_originate(uint8_t bearer_index, char *uri, uint8_t *call_index);
199
209int bt_tbs_join(uint8_t call_index_cnt, uint8_t *call_indexes);
210
220
230
240
250
262int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to,
263 const char *from, const char *friendly_name);
264
275int bt_tbs_set_bearer_provider_name(uint8_t bearer_index, const char *name);
276
287int bt_tbs_set_bearer_technology(uint8_t bearer_index, uint8_t new_technology);
288
300 uint8_t new_signal_strength);
301
312int bt_tbs_set_status_flags(uint8_t bearer_index, uint16_t status_flags);
313
322int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list,
323 uint8_t uri_count);
330
333
338} __packed;
339
343};
344
355typedef void (*bt_tbs_client_discover_cb)(struct bt_conn *conn, int err,
356 uint8_t tbs_count, bool gtbs_found);
357
366typedef void (*bt_tbs_client_write_value_cb)(struct bt_conn *conn, int err,
367 uint8_t inst_index);
368
379typedef void (*bt_tbs_client_cp_cb)(struct bt_conn *conn, int err,
380 uint8_t inst_index, uint8_t call_index);
381
392typedef void (*bt_tbs_client_read_string_cb)(struct bt_conn *conn, int err,
393 uint8_t inst_index,
394 const char *value);
395
405typedef void (*bt_tbs_client_read_value_cb)(struct bt_conn *conn, int err,
406 uint8_t inst_index, uint32_t value);
407
418typedef 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
434typedef 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
450typedef 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
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)
480#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) */
481#if defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY)
483#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) */
484#if defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_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)
498#endif /* defined(CONFIG_BT_TBS_CLIENT_CCID) */
499#if defined(CONFIG_BT_TBS_CLIENT_INCOMING_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) */
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) */
510#if defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL)
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
526int bt_tbs_client_discover(struct bt_conn *conn);
527
537int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index,
538 const char *uri);
539
553 uint8_t inst_index,
554 uint8_t interval);
555
568int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index,
569 const char *uri);
570
583int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index,
584 uint8_t call_index);
585
598int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index,
599 uint8_t call_index);
600
613int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index,
614 uint8_t call_index);
615
628int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index,
629 uint8_t call_index);
630
644int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index,
645 const uint8_t *call_indexes, uint8_t count);
646
659 uint8_t inst_index);
660
672int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index);
673
685int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index);
686
698int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index);
699
711int bt_tbs_client_read_signal_strength(struct bt_conn *conn,
712 uint8_t inst_index);
713
725int bt_tbs_client_read_signal_interval(struct bt_conn *conn,
726 uint8_t inst_index);
727
739int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index);
740
752int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index);
753
765int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index);
766
778int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index);
779
788int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index);
789
801int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index);
802
814int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index);
815
826int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn,
827 uint8_t inst_index);
828
835
847struct 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_ */
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:137
bt_tbs_originate_call_cb originate_call
Definition: tbs.h:138
bt_tbs_call_change_cb accept_call
Definition: tbs.h:141
bt_tbs_call_change_cb hold_call
Definition: tbs.h:140
bt_tbs_terminate_call_cb terminate_call
Definition: tbs.h:139
bt_tbs_authorize_cb authorize
Definition: tbs.h:144
bt_tbs_join_calls_cb join_calls
Definition: tbs.h:143
bt_tbs_call_change_cb retrieve_call
Definition: tbs.h:142
Definition: tbs.h:334
uint8_t index
Definition: tbs.h:335
uint8_t state
Definition: tbs.h:336
uint8_t flags
Definition: tbs.h:337
Definition: tbs.h:340
struct bt_tbs_client_call_state call_info
Definition: tbs.h:341
char * remote_uri
Definition: tbs.h:342
Definition: tbs.h:455
bt_tbs_client_call_states_cb call_state
Definition: tbs.h:505
bt_tbs_client_discover_cb discover
Definition: tbs.h:456
bt_tbs_client_termination_reason_cb termination_reason
Definition: tbs.h:509
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:135
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:450
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:123
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:379
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:392
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:405
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:89
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:102
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:434
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:355
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:113
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:418
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_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_client_discover(struct bt_conn *conn)
Discover TBS for a connection.
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:366
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.