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