1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24 * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 /** 39 * @title Genral Access Profile (GAP) 40 * 41 */ 42 43 #ifndef GAP_H 44 #define GAP_H 45 46 #if defined __cplusplus 47 extern "C" { 48 #endif 49 50 #include "btstack_defines.h" 51 #include "btstack_util.h" 52 53 #ifdef ENABLE_CLASSIC 54 #include "classic/btstack_link_key_db.h" 55 #endif 56 57 // BIG has up to 2 BIS (stereo) 58 #ifndef MAX_NR_BIS 59 #define MAX_NR_BIS 2 60 #endif 61 62 typedef enum { 63 64 // MITM protection not required 65 // No encryption required 66 // No user interaction required 67 LEVEL_0 = 0, 68 69 // MITM protection not required 70 // No encryption required 71 // Minimal user interaction desired 72 LEVEL_1, 73 74 // MITM protection not required 75 // Encryption required 76 LEVEL_2, 77 78 // MITM protection required 79 // Encryption required 80 // User interaction acceptable 81 LEVEL_3, 82 83 // MITM protection required 84 // Encryption required 85 // 128-bit equivalent strength for link and encryption keys required (P-192 is not enough) 86 // User interaction acceptable 87 LEVEL_4, 88 } gap_security_level_t; 89 90 91 typedef enum { 92 // non-secure 93 GAP_SECURITY_MODE_1 = 1, 94 95 // service level enforced security 96 GAP_SECURITY_MODE_2, 97 98 // link level enforced security 99 GAP_SECURITY_MODE_3, 100 101 // service level enforced security 102 GAP_SECURITY_MODE_4 103 } gap_security_mode_t; 104 105 typedef enum { 106 GAP_SECURITY_NONE, 107 GAP_SECURITY_ENCRYPTED, // SSP: JUST WORKS 108 GAP_SECURITY_AUTHENTICATED, // SSP: numeric comparison, passkey, OOB 109 // GAP_SECURITY_AUTHORIZED 110 } gap_security_state; 111 112 typedef enum { 113 GAP_CONNECTION_INVALID, 114 GAP_CONNECTION_ACL, 115 GAP_CONNECTION_SCO, 116 GAP_CONNECTION_LE 117 } gap_connection_type_t; 118 119 typedef struct le_connection_parameter_range{ 120 uint16_t le_conn_interval_min; 121 uint16_t le_conn_interval_max; 122 uint16_t le_conn_latency_min; 123 uint16_t le_conn_latency_max; 124 uint16_t le_supervision_timeout_min; 125 uint16_t le_supervision_timeout_max; 126 } le_connection_parameter_range_t; 127 128 typedef enum { 129 GAP_RANDOM_ADDRESS_TYPE_OFF = 0, 130 GAP_RANDOM_ADDRESS_TYPE_STATIC, 131 GAP_RANDOM_ADDRESS_NON_RESOLVABLE, 132 GAP_RANDOM_ADDRESS_RESOLVABLE, 133 } gap_random_address_type_t; 134 135 // Authorization state 136 typedef enum { 137 AUTHORIZATION_UNKNOWN, 138 AUTHORIZATION_PENDING, 139 AUTHORIZATION_DECLINED, 140 AUTHORIZATION_GRANTED 141 } authorization_state_t; 142 143 // Extended Advertising Parameters 144 typedef struct { 145 uint16_t advertising_event_properties; 146 uint16_t primary_advertising_interval_min; 147 uint16_t primary_advertising_interval_max; 148 uint8_t primary_advertising_channel_map; 149 bd_addr_type_t own_address_type; 150 bd_addr_type_t peer_address_type; 151 bd_addr_t peer_address; 152 uint8_t advertising_filter_policy; 153 int8_t advertising_tx_power; 154 uint8_t primary_advertising_phy; 155 uint8_t secondary_advertising_max_skip; 156 uint8_t secondary_advertising_phy; 157 uint8_t advertising_sid; 158 uint8_t scan_request_notification_enable; 159 } le_extended_advertising_parameters_t; 160 161 typedef struct { 162 uint16_t periodic_advertising_interval_min; 163 uint16_t periodic_advertising_interval_max; 164 uint16_t periodic_advertising_properties; 165 } le_periodic_advertising_parameters_t; 166 167 // Extended Advertising Set State 168 typedef struct { 169 btstack_linked_item_t item; 170 le_extended_advertising_parameters_t extended_params; 171 le_periodic_advertising_parameters_t periodic_params; 172 bd_addr_t random_address; 173 const uint8_t * adv_data; 174 const uint8_t * scan_data; 175 const uint8_t * periodic_data; 176 uint16_t adv_data_len; 177 uint16_t scan_data_len; 178 uint16_t periodic_data_len; 179 uint16_t adv_data_pos; 180 uint16_t scan_data_pos; 181 uint16_t periodic_data_pos; 182 uint16_t enable_timeout; 183 uint8_t advertising_handle; 184 uint8_t enable_max_scan_events; 185 bool periodic_include_adi; 186 uint8_t state; 187 uint8_t tasks; 188 } le_advertising_set_t; 189 190 // Isochronous Streams 191 192 // -- Broadcast Isochronous Group BIG 193 194 typedef struct { 195 uint8_t big_handle; 196 uint8_t advertising_handle; 197 uint8_t num_bis; 198 uint32_t sdu_interval_us; 199 uint16_t max_sdu; 200 uint16_t max_transport_latency_ms; 201 uint8_t rtn; 202 uint8_t phy; 203 uint8_t packing; 204 uint8_t framing; 205 uint8_t encryption; 206 uint8_t broadcast_code[16]; 207 } le_audio_big_params_t; 208 209 typedef struct { 210 uint8_t big_handle; 211 uint8_t sync_handle; 212 uint8_t encryption; 213 uint8_t broadcast_code[16]; 214 uint8_t mse; 215 uint16_t big_sync_timeout_10ms; 216 uint8_t num_bis; 217 uint8_t bis_indices[MAX_NR_BIS]; 218 } le_audio_big_sync_params_t; 219 220 typedef enum { 221 LE_AUDIO_BIG_STATE_CREATE, 222 LE_AUDIO_BIG_STATE_W4_ESTABLISHED, 223 LE_AUDIO_BIG_STATE_SETUP_ISO_PATH, 224 LE_AUDIO_BIG_STATE_W4_SETUP_ISO_PATH, 225 LE_AUDIO_BIG_STATE_W4_SETUP_ISO_PATH_THEN_TERMINATE, 226 LE_AUDIO_BIG_STATE_SETUP_ISO_PATHS_FAILED, 227 LE_AUDIO_BIG_STATE_ACTIVE, 228 LE_AUDIO_BIG_STATE_TERMINATE, 229 LE_AUDIO_BIG_STATE_W4_TERMINATED_AFTER_SETUP_FAILED, 230 LE_AUDIO_BIG_STATE_W4_TERMINATED, 231 } le_audio_big_state_t; 232 233 typedef struct { 234 btstack_linked_item_t item; 235 uint8_t big_handle; 236 le_audio_big_state_t state; 237 union { 238 uint8_t next_bis; 239 uint8_t status; 240 } state_vars; 241 uint8_t num_bis; 242 hci_con_handle_t bis_con_handles[MAX_NR_BIS]; 243 const le_audio_big_params_t * params; 244 // request to send 245 bool can_send_now_requested; 246 // previous and current timestamp of number completed event to track ISO intervals 247 bool num_completed_timestamp_previous_valid; 248 bool num_completed_timestamp_current_valid; 249 uint32_t num_completed_timestamp_previous_ms; 250 uint32_t num_completed_timestamp_current_ms; 251 252 } le_audio_big_t; 253 254 typedef struct { 255 btstack_linked_item_t item; 256 uint8_t big_handle; 257 le_audio_big_state_t state; 258 union { 259 uint8_t next_bis; 260 uint8_t status; 261 } state_vars; 262 uint8_t num_bis; 263 hci_con_handle_t bis_con_handles[MAX_NR_BIS]; 264 const le_audio_big_sync_params_t * params; 265 } le_audio_big_sync_t; 266 267 // -- Connected Isochronuous Group CIG 268 269 typedef enum { 270 LE_AUDIO_CIG_STATE_CREATE, 271 LE_AUDIO_CIG_STATE_W4_ESTABLISHED, 272 // LE_AUDIO_CIG_STATE_SETUP_ISO_PATH, 273 // LE_AUDIO_CIG_STATE_W4_SETUP_ISO_PATH, 274 // LE_AUDIO_CIG_STATE_W4_SETUP_ISO_PATH_THEN_TERMINATE, 275 // LE_AUDIO_CIG_STATE_SETUP_ISO_PATHS_FAILED, 276 LE_AUDIO_CIG_STATE_ACTIVE, 277 // LE_AUDIO_CIG_STATE_TERMINATE, 278 // LE_AUDIO_CIG_STATE_W4_TERMINATED_AFTER_SETUP_FAILED, 279 // LE_AUDIO_CIG_STATE_W4_TERMINATED, 280 } le_audio_cig_state_t; 281 282 typedef struct { 283 uint8_t cis_id; 284 uint16_t max_sdu_c_to_p; 285 uint16_t max_sdu_p_to_c; 286 uint8_t phy_c_to_p; 287 uint8_t phy_p_to_c; 288 uint8_t rtn_c_to_p; 289 uint8_t rtn_p_to_c; 290 } le_audio_cis_params_t; 291 292 typedef struct { 293 uint8_t cig_id; 294 uint32_t sdu_interval_c_to_p; 295 uint32_t sdu_interval_p_to_c; 296 uint8_t worst_case_sca; 297 uint8_t packing; 298 uint8_t framing; 299 uint16_t max_transport_latency_c_to_p; 300 uint16_t max_transport_latency_p_to_c; 301 uint8_t num_cis; 302 le_audio_cis_params_t cis_params[MAX_NR_CIS]; 303 } le_audio_cig_params_t; 304 305 typedef struct { 306 btstack_linked_item_t item; 307 uint8_t cig_id; 308 le_audio_cig_params_t * params; 309 le_audio_cig_state_t state; 310 union { 311 uint8_t next_cis; 312 uint8_t status; 313 } state_vars; 314 uint8_t num_cis; 315 hci_con_handle_t cis_con_handles[MAX_NR_CIS]; 316 // request to send 317 bool can_send_now_requested; 318 } le_audio_cig_t; 319 320 /* API_START */ 321 322 // Classic + LE 323 324 /** 325 * @brief Read RSSI 326 * @param con_handle 327 * @events: GAP_EVENT_RSSI_MEASUREMENT 328 */ 329 int gap_read_rssi(hci_con_handle_t con_handle); 330 331 332 /** 333 * @brief Gets local address. 334 */ 335 void gap_local_bd_addr(bd_addr_t address_buffer); 336 337 /** 338 * @brief Disconnect connection with handle 339 * @param handle 340 */ 341 uint8_t gap_disconnect(hci_con_handle_t handle); 342 343 /** 344 * @brief Get connection type 345 * @param con_handle 346 * @result connection_type 347 */ 348 gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle); 349 350 /** 351 * @brief Get HCI connection role 352 * @param con_handle 353 * @result hci_role_t HCI_ROLE_MASTER / HCI_ROLE_SLAVE / HCI_ROLE_INVALID (if connection does not exist) 354 */ 355 hci_role_t gap_get_role(hci_con_handle_t connection_handle); 356 357 // Classic 358 359 /** 360 * @brief Request role switch 361 * @note this only requests the role switch. A HCI_EVENT_ROLE_CHANGE is emitted and its status field will indicate if the switch was succesful 362 * @param addr 363 * @param hci_role_t HCI_ROLE_MASTER / HCI_ROLE_SLAVE 364 * @result status 365 */ 366 uint8_t gap_request_role(const bd_addr_t addr, hci_role_t role); 367 368 /** 369 * @brief Sets local name. 370 * @note Default name is 'BTstack 00:00:00:00:00:00' 371 * @note '00:00:00:00:00:00' in local_name will be replaced with actual bd addr 372 * @param name is not copied, make sure memory stays valid 373 */ 374 void gap_set_local_name(const char * local_name); 375 376 /** 377 * @brief Set Extended Inquiry Response data 378 * @note If not set, local name will be used for EIR data (see gap_set_local_name) 379 * @note '00:00:00:00:00:00' in local_name will be replaced with actual bd addr 380 * @param eir_data size HCI_EXTENDED_INQUIRY_RESPONSE_DATA_LEN (240) bytes, is not copied make sure memory stays valid 381 */ 382 void gap_set_extended_inquiry_response(const uint8_t * data); 383 384 /** 385 * @brief Set class of device 386 */ 387 void gap_set_class_of_device(uint32_t class_of_device); 388 389 /** 390 * @brief Set default link policy settings for all classic ACL links 391 * @param default_link_policy_settings - see LM_LINK_POLICY_* in bluetooth.h 392 * @note common value: LM_LINK_POLICY_ENABLE_ROLE_SWITCH | LM_LINK_POLICY_ENABLE_SNIFF_MODE to enable role switch and sniff mode 393 */ 394 void gap_set_default_link_policy_settings(uint16_t default_link_policy_settings); 395 396 /** 397 * @brief Set Allow Role Switch param for outgoing classic ACL links 398 * @param allow_role_switch - true: allow remote device to request role switch, false: stay master 399 */ 400 void gap_set_allow_role_switch(bool allow_role_switch); 401 402 /** 403 * @brief Set link supervision timeout for outgoing classic ACL links 404 * @param default_link_supervision_timeout * 0.625 ms, default 0x7d00 = 20 seconds, 0 = no link supervision timeout 405 */ 406 void gap_set_link_supervision_timeout(uint16_t link_supervision_timeout); 407 408 /** 409 * @brief Enable link watchdog. If no ACL packet is sent within timeout_ms, the link will get disconnected 410 * note: current implementation uses the automatic flush timeout controller feature with a max timeout of 1.28s 411 * @param timeout_ms 412 */ 413 void gap_enable_link_watchdog(uint16_t timeout_ms); 414 415 /** 416 * @brief Enable/disable bonding. Default is enabled. 417 * @param enabled 418 */ 419 void gap_set_bondable_mode(int enabled); 420 421 /** 422 * @brief Get bondable mode. 423 * @return 1 if bondable 424 */ 425 int gap_get_bondable_mode(void); 426 427 /** 428 * @brief Set security mode for all outgoing and incoming connections. Default: GAP_SECURITY_MODE_4 429 * @param security_mode is GAP_SECURITY_MODE_2 or GAP_SECURITY_MODE_4 430 * @return status ERROR_CODE_SUCCESS or ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE 431 */ 432 uint8_t gap_set_security_mode(gap_security_mode_t security_mode); 433 434 /** 435 * @brief Get security mode 436 * @return security_mode 437 */ 438 gap_security_mode_t gap_get_security_mode(void); 439 440 /** 441 * @brief Set security level for all outgoing and incoming connections. Default: LEVEL_2 442 * @param security_level 443 * @note has to be called before services or profiles are initialized 444 */ 445 void gap_set_security_level(gap_security_level_t security_level); 446 447 /** 448 * @brief Get security level 449 * @return security_level 450 */ 451 gap_security_level_t gap_get_security_level(void); 452 453 /** 454 * @brief Set Secure Connections Only Mode for BR/EDR (Classic) Default: false 455 * @param enable 456 */ 457 void gap_set_secure_connections_only_mode(bool enable); 458 459 /** 460 * @breif Get Secure Connections Only Mode 461 * @param enabled 462 */ 463 bool gap_get_secure_connections_only_mode(void); 464 465 /** 466 * @brief Set minimal security level for registered services 467 * @param security_level 468 * @note Called by L2CAP based on registered services 469 */ 470 void gap_set_minimal_service_security_level(gap_security_level_t security_level); 471 472 /** 473 * @brief Register filter for rejecting classic connections. Callback will return 1 accept connection, 0 on reject. 474 */ 475 void gap_register_classic_connection_filter(int (*accept_callback)(bd_addr_t addr, hci_link_type_t link_type)); 476 477 /* Configure Secure Simple Pairing */ 478 479 /** 480 * @brief Enable will enable SSP during init. Default: true 481 */ 482 void gap_ssp_set_enable(int enable); 483 484 /** 485 * @brief Set IO Capability. BTstack will return capability to SSP requests 486 */ 487 void gap_ssp_set_io_capability(int ssp_io_capability); 488 489 /** 490 * @brief Set Authentication Requirements using during SSP 491 */ 492 void gap_ssp_set_authentication_requirement(int authentication_requirement); 493 494 /** 495 * @brief Enable/disable Secure Connections. Default: true if supported by Controller 496 */ 497 void gap_secure_connections_enable(bool enable); 498 499 /** 500 * @brief Query if Secure Connections can be used for Classic connections. 501 * @note Requires gap_secure_connections_enable == true and Controller to support it 502 */ 503 bool gap_secure_connections_active(void); 504 505 /** 506 * @brief If set, BTstack will confirm a numeric comparison and enter '000000' if requested. 507 */ 508 void gap_ssp_set_auto_accept(int auto_accept); 509 510 /** 511 * @brief Set required encryption key size for GAP Levels 1-3 on ccassic connections. Default: 16 bytes 512 * @param encryption_key_size in bytes. Valid 7..16 513 */ 514 void gap_set_required_encryption_key_size(uint8_t encryption_key_size); 515 516 /** 517 * @brief Start dedicated bonding with device. Disconnect after bonding. 518 * @param device 519 * @param request MITM protection 520 * @return error, if max num acl connections active 521 * @result GAP_DEDICATED_BONDING_COMPLETE 522 */ 523 int gap_dedicated_bonding(bd_addr_t device, int mitm_protection_required); 524 525 gap_security_level_t gap_security_level_for_link_key_type(link_key_type_t link_key_type); 526 527 /** 528 * @brief map link keys to secure connection yes/no 529 */ 530 bool gap_secure_connection_for_link_key_type(link_key_type_t link_key_type); 531 532 /** 533 * @brief map link keys to authenticated 534 */ 535 bool gap_authenticated_for_link_key_type(link_key_type_t link_key_type); 536 537 gap_security_level_t gap_security_level(hci_con_handle_t con_handle); 538 539 void gap_request_security_level(hci_con_handle_t con_handle, gap_security_level_t level); 540 541 bool gap_mitm_protection_required_for_security_level(gap_security_level_t level); 542 543 /** 544 * @brief Set Page Scan Type 545 * @param page_scan_interval * 0.625 ms, range: 0x0012..0x1000, default: 0x0800 546 * @param page_scan_windows * 0.625 ms, range: 0x0011..page_scan_interval, default: 0x0012 547 */ 548 void gap_set_page_scan_activity(uint16_t page_scan_interval, uint16_t page_scan_window); 549 550 /** 551 * @brief Set Page Scan Type 552 * @param page_scan_mode 553 */ 554 void gap_set_page_scan_type(page_scan_type_t page_scan_type); 555 556 /** 557 * @brief Set Page Timeout 558 * @param page_timeout * 0.625 ms, range: 0x0001..0xffff, default: 0x6000 (ca 15 seconds) 559 */ 560 void gap_set_page_timeout(uint16_t page_timeout); 561 562 // LE 563 564 /** 565 * @brief Set parameters for LE Scan 566 * @param scan_type 0 = passive, 1 = active 567 * @param scan_interval range 0x0004..0x4000, unit 0.625 ms 568 * @param scan_window range 0x0004..0x4000, unit 0.625 ms 569 * @param scanning_filter_policy 0 = all devices, 1 = all from whitelist 570 */ 571 void gap_set_scan_params(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t scanning_filter_policy); 572 573 /** 574 * @brief Set parameters for LE Scan 575 * @deprecated Use gap_set_scan_params instead 576 */ 577 void gap_set_scan_parameters(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window); 578 579 /** 580 * @brief Start LE Scan 581 */ 582 void gap_start_scan(void); 583 584 /** 585 * @brief Stop LE Scan 586 */ 587 void gap_stop_scan(void); 588 589 /** 590 * @brief Enable privacy by using random addresses 591 * @param random_address_type to use (incl. OFF) 592 */ 593 void gap_random_address_set_mode(gap_random_address_type_t random_address_type); 594 595 /** 596 * @brief Get privacy mode 597 */ 598 gap_random_address_type_t gap_random_address_get_mode(void); 599 600 /** 601 * @brief Sets update period for random address 602 * @param period_ms in ms 603 */ 604 void gap_random_address_set_update_period(int period_ms); 605 606 /** 607 * @brief Sets a fixed random address for advertising 608 * @param addr 609 * @note Sets random address mode to type off 610 */ 611 void gap_random_address_set(const bd_addr_t addr); 612 613 /** 614 * @brief Set Advertisement Data 615 * @param advertising_data_length 616 * @param advertising_data (max 31 octets) 617 * @note data is not copied, pointer has to stay valid 618 * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 619 */ 620 void gap_advertisements_set_data(uint8_t advertising_data_length, uint8_t * advertising_data); 621 622 /** 623 * @brief Set Advertisement Parameters 624 * @param adv_int_min 625 * @param adv_int_max 626 * @param adv_type 627 * @param direct_address_type 628 * @param direct_address 629 * @param channel_map 630 * @param filter_policy 631 * @note own_address_type is used from gap_random_address_set_mode 632 */ 633 void gap_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type, 634 uint8_t direct_address_typ, bd_addr_t direct_address, uint8_t channel_map, uint8_t filter_policy); 635 636 /** 637 * @brief Enable/Disable Advertisements. OFF by default. 638 * @param enabled 639 */ 640 void gap_advertisements_enable(int enabled); 641 642 /** 643 * @brief Set Scan Response Data 644 * 645 * @note For scan response data, scannable undirected advertising (ADV_SCAN_IND) need to be used 646 * 647 * @param advertising_data_length 648 * @param advertising_data (max 31 octets) 649 * @note data is not copied, pointer has to stay valid 650 * @note '00:00:00:00:00:00' in scan_response_data will be replaced with actual bd addr 651 */ 652 void gap_scan_response_set_data(uint8_t scan_response_data_length, uint8_t * scan_response_data); 653 654 /** 655 * @brief Provide storage for new advertising set and setup on Controller 656 * @param storage to use by stack, needs to stay valid until adv set is removed with gap_extended_advertising_remove 657 * @param advertising_parameters 658 * @param out_advertising_handle to use with other adv config commands 659 * @return status 660 * @events: GAP_SUBEVENT_ADVERTISING_SET_INSTALLED 661 */ 662 uint8_t gap_extended_advertising_setup(le_advertising_set_t * storage, const le_extended_advertising_parameters_t * advertising_parameters, uint8_t * out_advertising_handle); 663 664 /** 665 * @param Set advertising params for advertising set 666 * @param advertising_handle 667 * @param advertising_parameters 668 * @return status 669 */ 670 uint8_t gap_extended_advertising_set_params(uint8_t advertising_handle, const le_extended_advertising_parameters_t * advertising_parameters); 671 672 /** 673 * @param Get advertising params for advertising set, e.g. to update params 674 * @param advertising_handle 675 * @param advertising_parameters 676 * @return status 677 */ 678 uint8_t gap_extended_advertising_get_params(uint8_t advertising_handle, le_extended_advertising_parameters_t * advertising_parameters); 679 680 /** 681 * @param Set periodic advertising params for advertising set 682 * @param advertising_handle 683 * @param advertising_parameters 684 * @return status 685 */ 686 uint8_t gap_periodic_advertising_set_params(uint8_t advertising_handle, const le_periodic_advertising_parameters_t * advertising_parameters); 687 688 /** 689 * @param Get params for periodic advertising set, e.g. to update params 690 * @param advertising_handle 691 * @param advertising_parameters 692 * @return status 693 */ 694 uint8_t gap_periodic_advertising_get_params(uint8_t advertising_handle, le_periodic_advertising_parameters_t * advertising_parameters); 695 696 /** 697 * @param Set random addrress for advertising set 698 * @param advertising_handle 699 * @param random_address 700 * @return status 701 */ 702 uint8_t gap_extended_advertising_set_random_address(uint8_t advertising_handle, bd_addr_t random_address); 703 704 /** 705 * @brief Set Advertising Data for a advertisement set 706 * @param advertising_handle 707 * @param advertising_data_length 708 * @param advertising_data 709 * @return status 710 */ 711 uint8_t gap_extended_advertising_set_adv_data(uint8_t advertising_handle, uint16_t advertising_data_length, const uint8_t * advertising_data); 712 713 /** 714 * @brief Set Scan Response Data for a advertisement set 715 * @param advertising_handle 716 * @param scan_response_data_length 717 * @param scan_response_data 718 * @return status 719 */ 720 uint8_t gap_extended_advertising_set_scan_response_data(uint8_t advertising_handle, uint16_t scan_response_data_length, const uint8_t * scan_response_data); 721 722 /** 723 * @brief Set data for periodic advertisement set 724 * @param advertising_handle 725 * @param periodic_data_length 726 * @param periodic_data 727 * @return status 728 */ 729 uint8_t gap_periodic_advertising_set_data(uint8_t advertising_handle, uint16_t periodic_data_length, const uint8_t * periodic_data); 730 731 /** 732 * @brief Start advertising advertising set 733 * @param advertising_handle 734 * @param timeout in 10ms, or 0 == no timeout 735 * @param num_extended_advertising_events Controller shall send, or 0 == no max number 736 * @return status 737 */ 738 uint8_t gap_extended_advertising_start(uint8_t advertising_handle, uint16_t timeout, uint8_t num_extended_advertising_events); 739 740 /** 741 * @brief Stop advertising 742 * @param advertising_handle 743 * @return status 744 */ 745 uint8_t gap_extended_advertising_stop(uint8_t advertising_handle); 746 747 /** 748 * @brief Start periodic advertising for given advertising set 749 * @param advertising_handle 750 * @param include_adi 751 * @return status 752 */ 753 uint8_t gap_periodic_advertising_start(uint8_t advertising_handle, bool include_adi); 754 755 /** 756 * @brief Stop periodic advertising for given advertising set 757 * @param advertising_handle 758 * @return status 759 */ 760 uint8_t gap_periodic_advertising_stop(uint8_t advertising_handle); 761 762 /** 763 * @brief Remove advertising set from Controller 764 * @param advertising_handle 765 * @return status 766 * @events GAP_SUBEVENT_ADVERTISING_SET_REMOVED 767 */ 768 uint8_t gap_extended_advertising_remove(uint8_t advertising_handle); 769 770 /** 771 * @brief Create Broadcast Isochronous Group (BIG) 772 * @param storage to use by stack, needs to stay valid until adv set is removed with gap_big_terminate 773 * @param big_params 774 * @return status 775 * @events GAP_SUBEVENT_BIG_CREATED unless interrupted by call to gap_big_terminate 776 */ 777 uint8_t gap_big_create(le_audio_big_t * storage, le_audio_big_params_t * big_params); 778 779 /** 780 * @brief Terminate Broadcast Isochronous Group (BIG) 781 * @param big_handle 782 * @return status 783 * @events: GAP_SUBEVENT_BIG_TERMINATED 784 */ 785 uint8_t gap_big_terminate(uint8_t big_handle); 786 787 /** 788 * @brief Synchronize to Broadcast Isochronous Group (BIG) 789 * @param storage to use by stack, needs to stay valid until adv set is removed with gap_big_terminate 790 * @param big_sync_params 791 * @return status 792 * @events GAP_SUBEVENT_BIG_SYNC_CREATED unless interrupted by call to gap_big_sync_terminate 793 */ 794 uint8_t gap_big_sync_create(le_audio_big_sync_t * storage, le_audio_big_sync_params_t * big_sync_params); 795 796 /** 797 * @brief Stop synchronizing to Broadcast Isochronous Group (BIG). Triggers GAP_SUBEVENT_BIG_SYNC_STOPPED 798 * @note Also used to stop synchronizing before BIG Sync was established 799 * @param big_handle 800 * @return status 801 * @events GAP_SUBEVENT_BIG_SYNC_STOPPED 802 */ 803 uint8_t gap_big_sync_terminate(uint8_t big_handle); 804 805 /** 806 * @brief Set connection parameters for outgoing connections 807 * @param conn_scan_interval (unit: 0.625 msec), default: 60 ms 808 * @param conn_scan_window (unit: 0.625 msec), default: 30 ms 809 * @param conn_interval_min (unit: 1.25ms), default: 10 ms 810 * @param conn_interval_max (unit: 1.25ms), default: 30 ms 811 * @param conn_latency, default: 4 812 * @param supervision_timeout (unit: 10ms), default: 720 ms 813 * @param min_ce_length (unit: 0.625ms), default: 10 ms 814 * @param max_ce_length (unit: 0.625ms), default: 30 ms 815 */ 816 void gap_set_connection_parameters(uint16_t conn_scan_interval, uint16_t conn_scan_window, 817 uint16_t conn_interval_min, uint16_t conn_interval_max, uint16_t conn_latency, 818 uint16_t supervision_timeout, uint16_t min_ce_length, uint16_t max_ce_length); 819 820 /** 821 * @brief Request an update of the connection parameter for a given LE connection 822 * @param handle 823 * @param conn_interval_min (unit: 1.25ms) 824 * @param conn_interval_max (unit: 1.25ms) 825 * @param conn_latency 826 * @param supervision_timeout (unit: 10ms) 827 * @return 0 if ok 828 */ 829 int gap_request_connection_parameter_update(hci_con_handle_t con_handle, uint16_t conn_interval_min, 830 uint16_t conn_interval_max, uint16_t conn_latency, uint16_t supervision_timeout); 831 832 /** 833 * @brief Updates the connection parameters for a given LE connection 834 * @param handle 835 * @param conn_interval_min (unit: 1.25ms) 836 * @param conn_interval_max (unit: 1.25ms) 837 * @param conn_latency 838 * @param supervision_timeout (unit: 10ms) 839 * @return 0 if ok 840 */ 841 int gap_update_connection_parameters(hci_con_handle_t con_handle, uint16_t conn_interval_min, 842 uint16_t conn_interval_max, uint16_t conn_latency, uint16_t supervision_timeout); 843 844 /** 845 * @brief Set accepted connection parameter range 846 * @param range 847 */ 848 void gap_get_connection_parameter_range(le_connection_parameter_range_t * range); 849 850 /** 851 * @brief Get accepted connection parameter range 852 * @param range 853 */ 854 void gap_set_connection_parameter_range(le_connection_parameter_range_t * range); 855 856 /** 857 * @brief Test if connection parameters are inside in existing rage 858 * @param conn_interval_min (unit: 1.25ms) 859 * @param conn_interval_max (unit: 1.25ms) 860 * @param conn_latency 861 * @param supervision_timeout (unit: 10ms) 862 * @return 1 if included 863 */ 864 int gap_connection_parameter_range_included(le_connection_parameter_range_t * existing_range, uint16_t le_conn_interval_min, uint16_t le_conn_interval_max, uint16_t le_conn_latency, uint16_t le_supervision_timeout); 865 866 /** 867 * @brief Set max number of connections in LE Peripheral role (if Bluetooth Controller supports it) 868 * @note: default: 1 869 * @param max_peripheral_connections 870 */ 871 void gap_set_max_number_peripheral_connections(int max_peripheral_connections); 872 873 /** 874 * @brief Add Device to Whitelist 875 * @param address_typ 876 * @param address 877 * @return 0 if ok 878 */ 879 uint8_t gap_whitelist_add(bd_addr_type_t address_type, const bd_addr_t address); 880 881 /** 882 * @brief Remove Device from Whitelist 883 * @param address_typ 884 * @param address 885 * @return 0 if ok 886 */ 887 uint8_t gap_whitelist_remove(bd_addr_type_t address_type, const bd_addr_t address); 888 889 /** 890 * @brief Clear Whitelist 891 * @return 0 if ok 892 */ 893 uint8_t gap_whitelist_clear(void); 894 895 /** 896 * @brief Connect to remote LE device 897 */ 898 uint8_t gap_connect(const bd_addr_t addr, bd_addr_type_t addr_type); 899 900 /** 901 * @brief Connect with Whitelist 902 * @note Explicit whitelist management and this connect with whitelist replace deprecated gap_auto_connection_* functions 903 * @return - if ok 904 */ 905 uint8_t gap_connect_with_whitelist(void); 906 907 /** 908 * @brief Cancel connection process initiated by gap_connect 909 */ 910 uint8_t gap_connect_cancel(void); 911 912 /** 913 * @brief Auto Connection Establishment - Start Connecting to device 914 * @deprecated Please setup Whitelist with gap_whitelist_* and start connecting with gap_connect_with_whitelist 915 * @param address_type 916 * @param address 917 * @return 0 if ok 918 */ 919 uint8_t gap_auto_connection_start(bd_addr_type_t address_type, const bd_addr_t address); 920 921 /** 922 * @brief Auto Connection Establishment - Stop Connecting to device 923 * @deprecated Please setup Whitelist with gap_whitelist_* and start connecting with gap_connect_with_whitelist 924 * @param address_type 925 * @param address 926 * @return 0 if ok 927 */ 928 uint8_t gap_auto_connection_stop(bd_addr_type_t address_type, const bd_addr_t address); 929 930 /** 931 * @brief Auto Connection Establishment - Stop everything 932 * @deprecated Please setup Whitelist with gap_whitelist_* and start connecting with gap_connect_with_whitelist 933 * @note Convenience function to stop all active auto connection attempts 934 */ 935 uint8_t gap_auto_connection_stop_all(void); 936 937 /** 938 * @brief Set LE PHY 939 * @param con_handle 940 * @param all_phys 0 = set rx/tx, 1 = set only rx, 2 = set only tx 941 * @param tx_phys 1 = 1M, 2 = 2M, 4 = Coded 942 * @param rx_phys 1 = 1M, 2 = 2M, 4 = Coded 943 * @param phy_options 0 = no preferred coding for Coded, 1 = S=2 coding (500 kbit), 2 = S=8 coding (125 kbit) 944 * @return 0 if ok 945 */ 946 uint8_t gap_le_set_phy(hci_con_handle_t con_handle, uint8_t all_phys, uint8_t tx_phys, uint8_t rx_phys, uint8_t phy_options); 947 948 /** 949 * @brief Get connection interval 950 * @param con_handle 951 * @return connection interval, otherwise 0 if error 952 */ 953 uint16_t gap_le_connection_interval(hci_con_handle_t con_handle); 954 955 /** 956 * 957 * @brief Get encryption key size. 958 * @param con_handle 959 * @return 0 if not encrypted, 7-16 otherwise 960 */ 961 uint8_t gap_encryption_key_size(hci_con_handle_t con_handle); 962 963 /** 964 * @brief Get authentication property. 965 * @param con_handle 966 * @return 1 if bonded with OOB/Passkey (AND MITM protection) 967 */ 968 bool gap_authenticated(hci_con_handle_t con_handle); 969 970 /** 971 * @brief Get secure connection property 972 * @param con_handle 973 * @return 1 if bonded usiung LE Secure Connections 974 */ 975 bool gap_secure_connection(hci_con_handle_t con_handle); 976 977 /** 978 * @brief Queries authorization state. 979 * @param con_handle 980 * @return authorization_state for the current session 981 */ 982 authorization_state_t gap_authorization_state(hci_con_handle_t con_handle); 983 984 /** 985 * @brief Get bonded property (BR/EDR/LE) 986 * @note LE: has to be called after identity resolving is complete 987 * @param con_handle 988 * @return true if bonded 989 */ 990 bool gap_bonded(hci_con_handle_t con_handle); 991 992 // Classic 993 #ifdef ENABLE_CLASSIC 994 995 /** 996 * @brief Override page scan mode. Page scan mode enabled by l2cap when services are registered 997 * @note Might be used to reduce power consumption while Bluetooth module stays powered but no (new) 998 * connections are expected 999 */ 1000 void gap_connectable_control(uint8_t enable); 1001 1002 /** 1003 * @brief Allows to control if device is discoverable. OFF by default. 1004 */ 1005 void gap_discoverable_control(uint8_t enable); 1006 1007 /** 1008 * @brief Deletes link key for remote device with baseband address. 1009 * @param addr 1010 * @note On most desktop ports, the Link Key DB uses a TLV and there is one TLV storage per 1011 * Controller resp. its Bluetooth Address. As the Bluetooth Address is retrieved during 1012 * power up, this function only works, when the stack is in working state for these ports. 1013 */ 1014 void gap_drop_link_key_for_bd_addr(bd_addr_t addr); 1015 1016 /** 1017 * @brief Delete all stored link keys 1018 * @note On most desktop ports, the Link Key DB uses a TLV and there is one TLV storage per 1019 * Controller resp. its Bluetooth Address. As the Bluetooth Address is retrieved during 1020 * power up, this function only works, when the stack is in working state for these ports. 1021 */ 1022 void gap_delete_all_link_keys(void); 1023 1024 /** 1025 * @brief Store link key for remote device with baseband address 1026 * @param addr 1027 * @param link_key 1028 * @param link_key_type 1029 * @note On most desktop ports, the Link Key DB uses a TLV and there is one TLV storage per 1030 * Controller resp. its Bluetooth Address. As the Bluetooth Address is retrieved during 1031 * power up, this function only works, when the stack is in working state for these ports. 1032 */ 1033 void gap_store_link_key_for_bd_addr(bd_addr_t addr, link_key_t link_key, link_key_type_t type); 1034 1035 /** 1036 * @brief Get link for remote device with basband address 1037 * @param addr 1038 * @param link_key (out) is stored here 1039 * @param link_key_type (out) is stored here 1040 * @note On most desktop ports, the Link Key DB uses a TLV and there is one TLV storage per 1041 * Controller resp. its Bluetooth Address. As the Bluetooth Address is retrieved during 1042 * power up, this function only works, when the stack is in working state for these ports. 1043 */ 1044 bool gap_get_link_key_for_bd_addr(bd_addr_t addr, link_key_t link_key, link_key_type_t * type); 1045 1046 /** 1047 * @brief Setup Link Key iterator 1048 * @param it 1049 * @return 1 on success 1050 * @note On most desktop ports, the Link Key DB uses a TLV and there is one TLV storage per 1051 * Controller resp. its Bluetooth Address. As the Bluetooth Address is retrieved during 1052 * power up, this function only works, when the stack is in working state for these ports. 1053 */ 1054 int gap_link_key_iterator_init(btstack_link_key_iterator_t * it); 1055 1056 /** 1057 * @brief Get next Link Key 1058 * @param it 1059 * @brief addr 1060 * @brief link_key 1061 * @brief type of link key 1062 * @return 1, if valid link key found 1063 * @see note on gap_link_key_iterator_init 1064 */ 1065 int gap_link_key_iterator_get_next(btstack_link_key_iterator_t * it, bd_addr_t bd_addr, link_key_t link_key, link_key_type_t * type); 1066 1067 /** 1068 * @brief Frees resources allocated by iterator_init 1069 * @note Must be called after iteration to free resources 1070 * @param it 1071 * @see note on gap_link_key_iterator_init 1072 */ 1073 void gap_link_key_iterator_done(btstack_link_key_iterator_t * it); 1074 1075 /** 1076 * @brief Start GAP Classic Inquiry 1077 * @param duration in 1.28s units 1078 * @return 0 if ok 1079 * @events: GAP_EVENT_INQUIRY_RESULT, GAP_EVENT_INQUIRY_COMPLETE 1080 */ 1081 int gap_inquiry_start(uint8_t duration_in_1280ms_units); 1082 1083 /** 1084 * @brief Start GAP Classic Periodic Inquiry 1085 * @param duration in 1.28s units 1086 * @param max_period_length between consecutive inquiries in 1.28s units 1087 * @param min_period_length between consecutive inquiries in 1.28s units 1088 * @return 0 if ok 1089 * @events: GAP_EVENT_INQUIRY_RESULT, GAP_EVENT_INQUIRY_COMPLETE 1090 */ 1091 uint8_t gap_inquiry_periodic_start(uint8_t duration, uint16_t max_period_length, uint16_t min_period_length); 1092 1093 /** 1094 * @brief Stop GAP Classic Inquiry (regular or periodic) 1095 * @return 0 if ok 1096 * @events: GAP_EVENT_INQUIRY_COMPLETE 1097 */ 1098 int gap_inquiry_stop(void); 1099 1100 /** 1101 * @brief Set LAP for GAP Classic Inquiry 1102 * @param lap GAP_IAC_GENERAL_INQUIRY (default), GAP_IAC_LIMITED_INQUIRY 1103 */ 1104 void gap_inquiry_set_lap(uint32_t lap); 1105 1106 /** 1107 * @brief Set Inquiry Scan Activity 1108 * @param inquiry_scan_interval range: 0x0012 to 0x1000; only even values are valid, Time = N * 0.625 ms 1109 * @param inquiry_scan_window range: 0x0011 to 0x1000; Time = N * 0.625 ms 1110 */ 1111 void gap_inquiry_set_scan_activity(uint16_t inquiry_scan_interval, uint16_t inquiry_scan_window); 1112 1113 /** 1114 * @brief Remote Name Request 1115 * @param addr 1116 * @param page_scan_repetition_mode 1117 * @param clock_offset only used when bit 15 is set - pass 0 if not known 1118 * @events: HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE 1119 */ 1120 int gap_remote_name_request(const bd_addr_t addr, uint8_t page_scan_repetition_mode, uint16_t clock_offset); 1121 1122 /** 1123 * @brief Legacy Pairing Pin Code Response 1124 * @note data is not copied, pointer has to stay valid 1125 * @param addr 1126 * @param pin 1127 * @return 0 if ok 1128 */ 1129 int gap_pin_code_response(const bd_addr_t addr, const char * pin); 1130 1131 /** 1132 * @brief Legacy Pairing Pin Code Response for binary data / non-strings 1133 * @note data is not copied, pointer has to stay valid 1134 * @param addr 1135 * @param pin_data 1136 * @param pin_len 1137 * @return 0 if ok 1138 */ 1139 int gap_pin_code_response_binary(const bd_addr_t addr, const uint8_t * pin_data, uint8_t pin_len); 1140 1141 /** 1142 * @brief Abort Legacy Pairing 1143 * @param addr 1144 * @param pin 1145 * @return 0 if ok 1146 */ 1147 int gap_pin_code_negative(bd_addr_t addr); 1148 1149 /** 1150 * @brief SSP Passkey Response 1151 * @param addr 1152 * @param passkey [0..999999] 1153 * @return 0 if ok 1154 */ 1155 int gap_ssp_passkey_response(const bd_addr_t addr, uint32_t passkey); 1156 1157 /** 1158 * @brief Abort SSP Passkey Entry/Pairing 1159 * @param addr 1160 * @param pin 1161 * @return 0 if ok 1162 */ 1163 int gap_ssp_passkey_negative(const bd_addr_t addr); 1164 1165 /** 1166 * @brief Accept SSP Numeric Comparison 1167 * @param addr 1168 * @param passkey 1169 * @return 0 if ok 1170 */ 1171 int gap_ssp_confirmation_response(const bd_addr_t addr); 1172 1173 /** 1174 * @brief Abort SSP Numeric Comparison/Pairing 1175 * @param addr 1176 * @param pin 1177 * @return 0 if ok 1178 */ 1179 int gap_ssp_confirmation_negative(const bd_addr_t addr); 1180 1181 /** 1182 * @brief Generate new OOB data 1183 * @note OOB data will be provided in GAP_EVENT_LOCAL_OOB_DATA and be used in future pairing procedures 1184 */ 1185 void gap_ssp_generate_oob_data(void); 1186 1187 /** 1188 * @brief Report Remote OOB Data 1189 * @note Pairing Hash and Randomizer are expected in big-endian byte format 1190 * @param bd_addr 1191 * @param c_192 Simple Pairing Hash C derived from P-192 public key 1192 * @param r_192 Simple Pairing Randomizer derived from P-192 public key 1193 * @param c_256 Simple Pairing Hash C derived from P-256 public key 1194 * @param r_256 Simple Pairing Randomizer derived from P-256 public key 1195 */ 1196 uint8_t gap_ssp_remote_oob_data(const bd_addr_t addr, const uint8_t * c_192, const uint8_t * r_192, const uint8_t * c_256, const uint8_t * r_256); 1197 1198 /** 1199 * Send SSP IO Capabilities Reply 1200 * @note IO Capabilities (Negative) Reply is sent automatically unless ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY 1201 * @param addr 1202 * @return 0 if ok 1203 */ 1204 uint8_t gap_ssp_io_capabilities_response(const bd_addr_t addr); 1205 1206 /** 1207 * Send SSP IO Capabilities Negative Reply 1208 * @note IO Capabilities (Negative) Reply is sent automatically unless ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY 1209 * @param addr 1210 * @return 0 if ok 1211 */ 1212 uint8_t gap_ssp_io_capabilities_negative(const bd_addr_t addr); 1213 1214 /** 1215 * Send Link Key Reponse 1216 * @note Link Key (Negative) Reply is sent automatically unless ENABLE_EXPLICIT_LINK_KEY_RESPONSE 1217 * @param addr 1218 * @param link_key 1219 * @param type or INVALID_LINK_KEY if link key not available 1220 * @return 0 if ok 1221 */ 1222 uint8_t gap_send_link_key_response(const bd_addr_t addr, link_key_t link_key, link_key_type_t type); 1223 1224 /** 1225 * @brief Enter Sniff mode 1226 * @param con_handle 1227 * @param sniff_min_interval range: 0x0002 to 0xFFFE; only even values are valid, Time = N * 0.625 ms 1228 * @param sniff_max_interval range: 0x0002 to 0xFFFE; only even values are valid, Time = N * 0.625 ms 1229 * @param sniff_attempt Number of Baseband receive slots for sniff attempt. 1230 * @param sniff_timeout Number of Baseband receive slots for sniff timeout. 1231 @ @return 0 if ok 1232 */ 1233 uint8_t gap_sniff_mode_enter(hci_con_handle_t con_handle, uint16_t sniff_min_interval, uint16_t sniff_max_interval, uint16_t sniff_attempt, uint16_t sniff_timeout); 1234 1235 /** 1236 * @brief Exit Sniff mode 1237 * @param con_handle 1238 @ @return 0 if ok 1239 */ 1240 uint8_t gap_sniff_mode_exit(hci_con_handle_t con_handle); 1241 1242 /** 1243 * @brief Configure Sniff Subrating 1244 * @param con_handle 1245 * @param max_latency range: 0x0002 to 0xFFFE; Time = N * 0.625 ms 1246 * @param min_remote_timeout range: 0x0002 to 0xFFFE; Time = N * 0.625 ms 1247 * @param min_local_timeout range: 0x0002 to 0xFFFE; Time = N * 0.625 ms 1248 @ @return 0 if ok 1249 */ 1250 uint8_t gap_sniff_subrating_configure(hci_con_handle_t con_handle, uint16_t max_latency, uint16_t min_remote_timeout, uint16_t min_local_timeout); 1251 1252 /** 1253 * @Brief Set QoS 1254 * @param con_handle 1255 * @param service_type 1256 * @param token_rate 1257 * @param peak_bandwidth 1258 * @param latency 1259 * @param delay_variation 1260 @ @return 0 if ok 1261 */ 1262 uint8_t gap_qos_set(hci_con_handle_t con_handle, hci_service_type_t service_type, uint32_t token_rate, uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation); 1263 1264 #endif 1265 1266 // LE 1267 1268 /** 1269 * @brief Get own addr type and address used for LE for next scan/advertisement/connect operation 1270 */ 1271 void gap_le_get_own_address(uint8_t * addr_type, bd_addr_t addr); 1272 1273 /** 1274 * @brief Get own addr type and address used for LE advertisements (Peripheral) 1275 */ 1276 void gap_le_get_own_advertisements_address(uint8_t * addr_type, bd_addr_t addr); 1277 1278 /** 1279 * @brief Get own addr type and address used for LE connections (Central) 1280 */ 1281 void gap_le_get_own_connection_address(uint8_t * addr_type, bd_addr_t addr); 1282 1283 /** 1284 * @brief Get state of connection re-encryption for bonded devices when in central role 1285 * @note used by gatt_client and att_server to wait for re-encryption 1286 * @param con_handle 1287 * @return 1 if security setup is active 1288 */ 1289 int gap_reconnect_security_setup_active(hci_con_handle_t con_handle); 1290 1291 /** 1292 * @brief Delete bonding information for remote device 1293 * @note On most desktop ports, the LE Device DB uses a TLV and there is one TLV storage per 1294 * Controller resp. its Bluetooth Address. As the Bluetooth Address is retrieved during 1295 * power up, this function only works, when the stack is in working state for these ports. 1296 * @param address_type 1297 * @param address 1298 */ 1299 void gap_delete_bonding(bd_addr_type_t address_type, bd_addr_t address); 1300 1301 /** 1302 * LE Privacy 1.2 - requires support by Controller and ENABLE_LE_RESOLVING_LIST to be defined 1303 */ 1304 1305 /** 1306 * @brief Load LE Device DB entries into Controller Resolving List to allow filtering on 1307 * bonded devies with resolvable private addresses 1308 * @return EROOR_CODE_SUCCESS if supported by Controller 1309 */ 1310 uint8_t gap_load_resolving_list_from_le_device_db(void); 1311 1312 /** 1313 * @brief Get local persistent IRK 1314 */ 1315 const uint8_t * gap_get_persistent_irk(void); 1316 1317 /* API_END*/ 1318 1319 #if defined __cplusplus 1320 } 1321 #endif 1322 1323 #endif // GAP_H 1324