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 * @param subscribe Whether to subscribe to all handles. 524 * 525 * @return int 0 on success, GATT error value on fail. 526 */ 527 int bt_tbs_client_discover(struct bt_conn *conn, bool subscribe); 528 529 /** 530 * @brief Set the outgoing URI for a TBS instance on the peer device. 531 * 532 * @param conn The connection to the TBS server. 533 * @param inst_index The index of the TBS instance. 534 * @param uri The Null-terminated URI string. 535 * 536 * @return int 0 on success, errno value on fail. 537 */ 538 int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index, 539 const char *uri); 540 541 /** 542 * @brief Set the signal strength reporting interval for a TBS instance. 543 * 544 * @param conn The connection to the TBS server. 545 * @param inst_index The index of the TBS instance. 546 * @param interval The interval to write (0-255 seconds). 547 * 548 * @return int 0 on success, errno value on fail. 549 * 550 * @note @kconfig{CONFIG_BT_TBS_CLIENT_SET_BEARER_SIGNAL_INTERVAL} must be set 551 * for this function to be effective. 552 */ 553 int bt_tbs_client_set_signal_strength_interval(struct bt_conn *conn, 554 uint8_t inst_index, 555 uint8_t interval); 556 557 /** 558 * @brief Request to originate a call. 559 * 560 * @param conn The connection to the TBS server. 561 * @param inst_index The index of the TBS instance. 562 * @param uri The URI of the callee. 563 * 564 * @return int 0 on success, errno value on fail. 565 * 566 * @note @kconfig{CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL} must be set 567 * for this function to be effective. 568 */ 569 int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index, 570 const char *uri); 571 572 /** 573 * @brief Request to terminate a call 574 * 575 * @param conn The connection to the TBS server. 576 * @param inst_index The index of the TBS instance. 577 * @param call_index The call index to terminate. 578 * 579 * @return int 0 on success, errno value on fail. 580 * 581 * @note @kconfig{CONFIG_BT_TBS_CLIENT_TERMINATE_CALL} must be set 582 * for this function to be effective. 583 */ 584 int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index, 585 uint8_t call_index); 586 587 /** 588 * @brief Request to hold a call 589 * 590 * @param conn The connection to the TBS server. 591 * @param inst_index The index of the TBS instance. 592 * @param call_index The call index to place on hold. 593 * 594 * @return int 0 on success, errno value on fail. 595 * 596 * @note @kconfig{CONFIG_BT_TBS_CLIENT_HOLD_CALL} must be set 597 * for this function to be effective. 598 */ 599 int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index, 600 uint8_t call_index); 601 602 /** 603 * @brief Accept an incoming call 604 * 605 * @param conn The connection to the TBS server. 606 * @param inst_index The index of the TBS instance. 607 * @param call_index The call index to accept. 608 * 609 * @return int 0 on success, errno value on fail. 610 * 611 * @note @kconfig{CONFIG_BT_TBS_CLIENT_ACCEPT_CALL} must be set 612 * for this function to be effective. 613 */ 614 int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index, 615 uint8_t call_index); 616 617 /** 618 * @brief Retrieve call from (local) hold. 619 * 620 * @param conn The connection to the TBS server. 621 * @param inst_index The index of the TBS instance. 622 * @param call_index The call index to retrieve. 623 * 624 * @return int 0 on success, errno value on fail. 625 * 626 * @note @kconfig{CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL} must be set 627 * for this function to be effective. 628 */ 629 int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index, 630 uint8_t call_index); 631 632 /** 633 * @brief Join multiple calls. 634 * 635 * @param conn The connection to the TBS server. 636 * @param inst_index The index of the TBS instance. 637 * @param call_indexes Array of call indexes. 638 * @param count Number of call indexes in the call_indexes array. 639 * 640 * @return int 0 on success, errno value on fail. 641 * 642 * @note @kconfig{CONFIG_BT_TBS_CLIENT_JOIN_CALLS} must be set 643 * for this function to be effective. 644 */ 645 int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index, 646 const uint8_t *call_indexes, uint8_t count); 647 648 /** 649 * @brief Read the bearer provider name of a TBS instance. 650 * 651 * @param conn The connection to the TBS server. 652 * @param inst_index The index of the TBS instance. 653 * 654 * @return int 0 on success, errno value on fail. 655 * 656 * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME} must be set 657 * for this function to be effective. 658 */ 659 int bt_tbs_client_read_bearer_provider_name(struct bt_conn *conn, 660 uint8_t inst_index); 661 662 /** 663 * @brief Read the UCI of a TBS instance. 664 * 665 * @param conn The connection to the TBS server. 666 * @param inst_index The index of the TBS instance. 667 * 668 * @return int 0 on success, errno value on fail. 669 * 670 * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_UCI} must be set 671 * for this function to be effective. 672 */ 673 int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index); 674 675 /** 676 * @brief Read the technology of a TBS instance. 677 * 678 * @param conn The connection to the TBS server. 679 * @param inst_index The index of the TBS instance. 680 * 681 * @return int 0 on success, errno value on fail. 682 * 683 * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY} must be set 684 * for this function to be effective. 685 */ 686 int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index); 687 688 /** 689 * @brief Read the URI schemes list of a TBS instance. 690 * 691 * @param conn The connection to the TBS server. 692 * @param inst_index The index of the TBS instance. 693 * 694 * @return int 0 on success, errno value on fail. 695 * 696 * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST} must be set 697 * for this function to be effective. 698 */ 699 int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index); 700 701 /** 702 * @brief Read the current signal strength of a TBS instance. 703 * 704 * @param conn The connection to the TBS server. 705 * @param inst_index The index of the TBS instance. 706 * 707 * @return int 0 on success, errno value on fail. 708 * 709 * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH} must be set 710 * for this function to be effective. 711 */ 712 int bt_tbs_client_read_signal_strength(struct bt_conn *conn, 713 uint8_t inst_index); 714 715 /** 716 * @brief Read the signal strength reporting interval of a TBS instance. 717 * 718 * @param conn The connection to the TBS server. 719 * @param inst_index The index of the TBS instance. 720 * 721 * @return int 0 on success, errno value on fail. 722 * 723 * @note @kconfig{CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL} must be set 724 * for this function to be effective. 725 */ 726 int bt_tbs_client_read_signal_interval(struct bt_conn *conn, 727 uint8_t inst_index); 728 729 /** 730 * @brief Read the list of current calls of a TBS instance. 731 * 732 * @param conn The connection to the TBS server. 733 * @param inst_index The index of the TBS instance. 734 * 735 * @return int 0 on success, errno value on fail. 736 * 737 * @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS} must be set 738 * for this function to be effective. 739 */ 740 int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index); 741 742 /** 743 * @brief Read the content ID of a TBS instance. 744 * 745 * @param conn The connection to the TBS server. 746 * @param inst_index The index of the TBS instance. 747 * 748 * @return int 0 on success, errno value on fail. 749 * 750 * @note @kconfig{CONFIG_BT_TBS_CLIENT_CCID} must be set 751 * for this function to be effective. 752 */ 753 int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index); 754 755 /** 756 * @brief Read the call target URI of a TBS instance. 757 * 758 * @param conn The connection to the TBS server. 759 * @param inst_index The index of the TBS instance. 760 * 761 * @return int 0 on success, errno value on fail. 762 * 763 * @note @kconfig{CONFIG_BT_TBS_CLIENT_INCOMING_URI} must be set 764 * for this function to be effective. 765 */ 766 int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index); 767 768 /** 769 * @brief Read the feature and status value of a TBS instance. 770 * 771 * @param conn The connection to the TBS server. 772 * @param inst_index The index of the TBS instance. 773 * 774 * @return int 0 on success, errno value on fail. 775 * 776 * @note @kconfig{CONFIG_BT_TBS_CLIENT_STATUS_FLAGS} must be set 777 * for this function to be effective. 778 */ 779 int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index); 780 781 /** 782 * @brief Read the states of the current calls of a TBS instance. 783 * 784 * @param conn The connection to the TBS server. 785 * @param inst_index The index of the TBS instance. 786 * 787 * @return int 0 on success, errno value on fail. 788 */ 789 int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index); 790 791 /** 792 * @brief Read the remote URI of a TBS instance. 793 * 794 * @param conn The connection to the TBS server. 795 * @param inst_index The index of the TBS instance. 796 * 797 * @return int 0 on success, errno value on fail. 798 * 799 * @note @kconfig{CONFIG_BT_TBS_CLIENT_INCOMING_CALL} must be set 800 * for this function to be effective. 801 */ 802 int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index); 803 804 /** 805 * @brief Read the friendly name of a call for a TBS instance. 806 * 807 * @param conn The connection to the TBS server. 808 * @param inst_index The index of the TBS instance. 809 * 810 * @return int 0 on success, errno value on fail. 811 * 812 * @note @kconfig{CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME} must be set 813 * for this function to be effective. 814 */ 815 int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index); 816 817 /** @brief Read the supported opcode of a TBS instance. 818 * 819 * @param conn The connection to the TBS server. 820 * @param inst_index The index of the TBS instance. 821 * 822 * @return int 0 on success, errno value on fail. 823 * 824 * @note @kconfig{CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES} must be set 825 * for this function to be effective. 826 */ 827 int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn, 828 uint8_t inst_index); 829 830 /** 831 * @brief Register the callbacks for CCP. 832 * 833 * @param cbs Pointer to the callback structure. 834 */ 835 void bt_tbs_client_register_cb(const struct bt_tbs_client_cb *cbs); 836 837 /** 838 * @brief Look up Telephone Bearer Service instance by CCID 839 * 840 * @param conn The connection to the TBS server. 841 * @param ccid The CCID to lookup a service instance for. 842 * 843 * @return Pointer to a Telephone Bearer Service instance if found else NULL. 844 * 845 * @note @kconfig{CONFIG_BT_TBS_CLIENT_CCID} must be set 846 * for this function to be effective. 847 */ 848 struct bt_tbs_instance *bt_tbs_client_get_by_ccid(const struct bt_conn *conn, 849 uint8_t ccid); 850 851 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_ */ 852