Zephyr Project API  3.1.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
84typedef bool (*bt_tbs_originate_call_cb)(struct bt_conn *conn,
85 uint8_t call_index,
86 const char *uri);
87
97typedef void (*bt_tbs_terminate_call_cb)(struct bt_conn *conn,
98 uint8_t call_index,
99 uint8_t reason);
100
108typedef void (*bt_tbs_join_calls_cb)(struct bt_conn *conn,
109 uint8_t call_index_count,
110 const uint8_t *call_indexes);
111
118typedef void (*bt_tbs_call_change_cb)(struct bt_conn *conn,
119 uint8_t call_index);
120
130typedef bool (*bt_tbs_authorize_cb)(struct bt_conn *conn);
131
132struct bt_tbs_cb {
140};
141
150int bt_tbs_accept(uint8_t call_index);
151
160int bt_tbs_hold(uint8_t call_index);
161
170int bt_tbs_retrieve(uint8_t call_index);
171
180int bt_tbs_terminate(uint8_t call_index);
181
193int bt_tbs_originate(uint8_t bearer_index, char *uri, uint8_t *call_index);
194
204int bt_tbs_join(uint8_t call_index_cnt, uint8_t *call_indexes);
205
215
225
235
245
257int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to,
258 const char *from, const char *friendly_name);
259
270int bt_tbs_set_bearer_provider_name(uint8_t bearer_index, const char *name);
271
282int bt_tbs_set_bearer_technology(uint8_t bearer_index, uint8_t new_technology);
283
295 uint8_t new_signal_strength);
296
307int bt_tbs_set_status_flags(uint8_t bearer_index, uint16_t status_flags);
308
317int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list,
318 uint8_t uri_count);
325
326#if defined(CONFIG_BT_DEBUG_TBS)
328void bt_tbs_dbg_print_calls(void);
329#endif /* defined(CONFIG_BT_DEBUG_TBS) */
330
335} __packed;
336
339 char remote_uri[CONFIG_BT_TBS_MAX_URI_LENGTH + 1];
340} __packed;
341
352typedef void (*bt_tbs_client_discover_cb)(struct bt_conn *conn, int err,
353 uint8_t tbs_count, bool gtbs_found);
354
363typedef void (*bt_tbs_client_write_value_cb)(struct bt_conn *conn, int err,
364 uint8_t inst_index);
365
376typedef void (*bt_tbs_client_cp_cb)(struct bt_conn *conn, int err,
377 uint8_t inst_index, uint8_t call_index);
378
389typedef void (*bt_tbs_client_read_string_cb)(struct bt_conn *conn, int err,
390 uint8_t inst_index,
391 const char *value);
392
402typedef void (*bt_tbs_client_read_value_cb)(struct bt_conn *conn, int err,
403 uint8_t inst_index, uint32_t value);
404
415typedef void (*bt_tbs_client_termination_reason_cb)(struct bt_conn *conn,
416 int err, uint8_t inst_index,
417 uint8_t call_index,
418 uint8_t reason);
419
431typedef void (*bt_tbs_client_current_calls_cb)(struct bt_conn *conn, int err,
432 uint8_t inst_index,
433 uint8_t call_count,
434 const struct bt_tbs_client_call *calls);
435
447typedef void (*bt_tbs_client_call_states_cb)(struct bt_conn *conn, int err,
448 uint8_t inst_index,
449 uint8_t call_count,
450 const struct bt_tbs_client_call_state *call_states);
451
460
476};
477
487int bt_tbs_client_discover(struct bt_conn *conn, bool subscribe);
488
498int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index,
499 const char *uri);
500
511 uint8_t inst_index,
512 uint8_t interval);
513
523int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index,
524 const char *uri);
525
535int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index,
536 uint8_t call_index);
537
547int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index,
548 uint8_t call_index);
549
559int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index,
560 uint8_t call_index);
561
571int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index,
572 uint8_t call_index);
573
584int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index,
585 const uint8_t *call_indexes, uint8_t count);
586
596 uint8_t inst_index);
597
606int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index);
607
616int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index);
617
618
627int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index);
628
637int bt_tbs_client_read_signal_strength(struct bt_conn *conn,
638 uint8_t inst_index);
639
648int bt_tbs_client_read_signal_interval(struct bt_conn *conn,
649 uint8_t inst_index);
650
659int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index);
660
669int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index);
670
679int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index);
680
689int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index);
690
699int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index);
700
709int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index);
710
719int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index);
720
728int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn,
729 uint8_t inst_index);
730
737
738#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:132
bt_tbs_originate_call_cb originate_call
Definition: tbs.h:133
bt_tbs_call_change_cb accept_call
Definition: tbs.h:136
bt_tbs_call_change_cb hold_call
Definition: tbs.h:135
bt_tbs_terminate_call_cb terminate_call
Definition: tbs.h:134
bt_tbs_authorize_cb authorize
Definition: tbs.h:139
bt_tbs_join_calls_cb join_calls
Definition: tbs.h:138
bt_tbs_call_change_cb retrieve_call
Definition: tbs.h:137
Definition: tbs.h:331
uint8_t index
Definition: tbs.h:332
uint8_t state
Definition: tbs.h:333
uint8_t flags
Definition: tbs.h:334
Definition: tbs.h:337
char remote_uri[CONFIG_BT_TBS_MAX_URI_LENGTH+1]
Definition: tbs.h:339
struct bt_tbs_client_call_state call_info
Definition: tbs.h:338
Definition: tbs.h:452
bt_tbs_client_read_value_cb signal_interval
Definition: tbs.h:466
bt_tbs_client_cp_cb originate_call
Definition: tbs.h:454
bt_tbs_client_current_calls_cb current_calls
Definition: tbs.h:467
bt_tbs_client_read_string_cb bearer_uci
Definition: tbs.h:462
bt_tbs_client_cp_cb retrieve_call
Definition: tbs.h:458
bt_tbs_client_cp_cb join_calls
Definition: tbs.h:459
bt_tbs_client_cp_cb hold_call
Definition: tbs.h:456
bt_tbs_client_read_string_cb remote_uri
Definition: tbs.h:474
bt_tbs_client_read_string_cb bearer_provider_name
Definition: tbs.h:461
bt_tbs_client_cp_cb accept_call
Definition: tbs.h:457
bt_tbs_client_read_string_cb uri_list
Definition: tbs.h:464
bt_tbs_client_read_value_cb technology
Definition: tbs.h:463
bt_tbs_client_call_states_cb call_state
Definition: tbs.h:471
bt_tbs_client_read_value_cb ccid
Definition: tbs.h:468
bt_tbs_client_read_value_cb optional_opcodes
Definition: tbs.h:472
bt_tbs_client_read_value_cb status_flags
Definition: tbs.h:469
bt_tbs_client_read_value_cb signal_strength
Definition: tbs.h:465
bt_tbs_client_cp_cb terminate_call
Definition: tbs.h:455
bt_tbs_client_discover_cb discover
Definition: tbs.h:453
bt_tbs_client_read_string_cb friendly_name
Definition: tbs.h:475
bt_tbs_client_termination_reason_cb termination_reason
Definition: tbs.h:473
bt_tbs_client_read_string_cb call_uri
Definition: tbs.h:470
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:130
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:447
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:118
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:376
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:389
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:402
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:84
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_terminate_call_cb)(struct bt_conn *conn, uint8_t call_index, uint8_t reason)
Callback function for client terminating a call.
Definition: tbs.h:97
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:431
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:352
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:108
int bt_tbs_client_read_signal_strength(struct bt_conn *conn, uint8_t inst_index)
Read the current signal strength of a TBS instance.
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:415
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:363
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.