MT2523 API Reference  LinkIt SDK v4
bt_gap.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2017 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __BT_GAP_H__
36 #define __BT_GAP_H__
37 
284 #include "bt_type.h"
285 #include "bt_system.h"
286 
287 BT_EXTERN_C_BEGIN
288 
294 #define BT_GAP_LINK_STATUS_UPDATED_IND (BT_MODULE_GAP | 0x0101)
295 #define BT_GAP_IO_CAPABILITY_REQ_IND (BT_MODULE_GAP | 0x0103)
297 #define BT_GAP_USER_CONFIRM_REQ_IND (BT_MODULE_GAP | 0x0104)
298 #define BT_GAP_USER_PASSKEY_NOTIFICATION_IND (BT_MODULE_GAP | 0x0105)
299 #define BT_GAP_USER_PASSKEY_NOTIFICATION_END_IND (BT_MODULE_GAP | 0x0106)
300 #define BT_GAP_LINK_KEY_NOTIFICATION_IND (BT_MODULE_GAP | 0x0107)
301 #define BT_GAP_USER_REPLY_PASSKEY_IND (BT_MODULE_GAP | 0x0108)
302 #define BT_GAP_SET_SCAN_MODE_CNF (BT_MODULE_GAP | 0x0109)
303 #define BT_GAP_INQUIRY_CNF (BT_MODULE_GAP | 0x010A)
304 #define BT_GAP_CANCEL_INQUIRY_CNF (BT_MODULE_GAP | 0x010B)
305 #define BT_GAP_INQUIRY_IND (BT_MODULE_GAP | 0x010C)
306 #define BT_GAP_INQUIRY_COMPLETE_IND (BT_MODULE_GAP | 0x010D)
307 #define BT_GAP_SET_ROLE_CNF (BT_MODULE_GAP | 0x010E)
308 #define BT_GAP_ROLE_CHANGED_IND (BT_MODULE_GAP | 0x010F)
309 #define BT_GAP_READ_REMOTE_NAME_CNF (BT_MODULE_GAP | 0x0110)
310 #define BT_GAP_READ_REMOTE_NAME_COMPLETE_IND (BT_MODULE_GAP | 0x0111)
311 #define BT_GAP_READ_CANCEL_REMOTE_NAME_CNF (BT_MODULE_GAP | 0x0112)
312 #define BT_GAP_ENTER_TEST_MODE_CNF (BT_MODULE_GAP | 0x0113)
313 #define BT_GAP_WRITE_INQUIRY_TX_PWR_CNF (BT_MODULE_GAP | 0x0114)
314 #define BT_GAP_READ_INQUIRY_RESPONSE_TX_CNF (BT_MODULE_GAP | 0x0115)
315 #define BT_GAP_READ_RSSI_CNF (BT_MODULE_GAP | 0x0116)
316 #define BT_GAP_GET_ROLE_CNF (BT_MODULE_GAP | 0x0117)
317 #define BT_GAP_SET_EIR_CNF (BT_MODULE_GAP | 0x0118)
318 #define BT_GAP_BONDING_START_IND (BT_MODULE_GAP | 0x0119)
319 #define BT_GAP_BONDING_COMPLETE_IND (BT_MODULE_GAP | 0x011A)
320 #define BT_GAP_WRITING_PAGE_SCAN_CNF (BT_MODULE_GAP | 0x011B)
321 #define BT_GAP_WRITING_INQUIRY_SCAN_CNF (BT_MODULE_GAP | 0x011C)
322 #define BT_GAP_SNIFF_MODE_CHANGE_IND (BT_MODULE_GAP | 0x011F)
324 #define BT_GAP_SCAN_MODE_NOT_ACCESSIBLE 0x00
325 #define BT_GAP_SCAN_MODE_DISCOVERABLE_ONLY 0x01
326 #define BT_GAP_SCAN_MODE_CONNECTABLE_ONLY 0x02
327 #define BT_GAP_SCAN_MODE_GENERAL_ACCESSIBLE 0x03
328 typedef uint8_t bt_gap_scan_mode_t;
330 #define BT_GAP_MAX_PIN_CODE_LENGTH 16
331 #define BT_GAP_MAX_DEVICE_NAME_LENGTH 31
333 #define BT_GAP_OOB_DATA_PRESENTED_NONE 0x00
334 #define BT_GAP_OOB_DATA_PRESENTED_P192 0x01
335 #define BT_GAP_OOB_DATA_PRESENTED_P256 0x02
336 #define BT_GAP_OOB_DATA_PRESENTED_P192_AND_P256 0x03
337 typedef uint8_t bt_gap_oob_data_presented_t;
339 #define BT_GAP_IO_CAPABILITY_DISPLAY_ONLY 0x00
340 #define BT_GAP_IO_CAPABILITY_DISPLAY_YES_NO 0x01
341 #define BT_GAP_IO_CAPABILITY_KEYBOARD_ONLY 0x02
342 #define BT_GAP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 0x03
343 typedef uint8_t bt_gap_io_capability_t;
345 #define BT_GAP_SECURITY_LEVEL_0 0x8000
346 #define BT_GAP_SECURITY_LEVEL_1 0x9000
347 #define BT_GAP_SECURITY_LEVEL_2 0xA000
348 #define BT_GAP_SECURITY_LEVEL_3 0xB000
349 #define BT_GAP_SECURITY_LEVEL_4 0xC000
350 typedef uint16_t bt_gap_security_level_t;
352 #define BT_GAP_LINK_STATUS_NONE 0x0000
353 #define BT_GAP_LINK_STATUS_DISCONNECTED 0x0004
354 #define BT_GAP_LINK_STATUS_CONNECTED_0 BT_GAP_SECURITY_LEVEL_0
355 #define BT_GAP_LINK_STATUS_CONNECTED_1 BT_GAP_SECURITY_LEVEL_1
356 #define BT_GAP_LINK_STATUS_CONNECTED_2 BT_GAP_SECURITY_LEVEL_2
357 #define BT_GAP_LINK_STATUS_CONNECTED_3 BT_GAP_SECURITY_LEVEL_3
358 #define BT_GAP_LINK_STATUS_CONNECTED_4 BT_GAP_SECURITY_LEVEL_4
359 typedef uint16_t bt_gap_link_status_t;
361 #define BT_GAP_SECURITY_AUTH_REQUEST_NO_BONDING_AUTO_ACCEPTED 0x00
362 #define BT_GAP_SECURITY_AUTH_REQUEST_MITM_NO_BONDING 0x01
363 #define BT_GAP_SECURITY_AUTH_REQUEST_DEDICATED_BONDING_AUTO_ACCEPTED 0x02
364 #define BT_GAP_SECURITY_AUTH_REQUEST_MITM_DEDICATED_BONDING 0x03
365 #define BT_GAP_SECURITY_AUTH_REQUEST_GENERAL_BONDING_AUTO_ACCEPTED 0x04
366 #define BT_GAP_SECURITY_AUTH_REQUEST_MITM_GENERAL_BONDING 0x05
367 typedef uint8_t bt_gap_security_auth_request_t;
369 #define BT_GAP_LINK_KEY_TYPE_COMBINATION 0x00
370 #define BT_GAP_LINK_KEY_TYPE_LOCAL_UNIT 0x01
371 #define BT_GAP_LINK_KEY_TYPE_REMOTE_UNIT 0x02
372 #define BT_GAP_LINK_KEY_TYPE_DEBUG 0x03
373 #define BT_GAP_LINK_KEY_TYPE_UNAUTH_P192 0x04
374 #define BT_GAP_LINK_KEY_TYPE_AUTH_P192 0x05
375 #define BT_GAP_LINK_KEY_TYPE_CHANGED 0x06
376 #define BT_GAP_LINK_KEY_TYPE_UNAUTH_P256 0x07
377 #define BT_GAP_LINK_KEY_TYPE_AUTH_P256 0x08
381 #define BT_GAP_LINK_KEY_TYPE_INVAILIDE 0xFF
382 #define BT_GAP_LINK_KEY_TYPE_INVALID 0xFF
383 typedef uint8_t bt_gap_link_key_type_t;
385 #define BT_GAP_INQUIRY_MODE_STANDARD 0x00
386 #define BT_GAP_INQUIRY_MODE_RSSI 0x01
387 #define BT_GAP_INQUIRY_MODE_RSSI_EIR 0x02
388 typedef uint8_t bt_gap_inquiry_mode_t;
390 #define BT_GAP_LINK_SNIFF_TYPE_ACTIVE 0x00
391 #define BT_GAP_LINK_SNIFF_TYPE_SNIFFED 0x02
392 #define BT_GAP_LINK_SNIFF_TYPE_SUB_SNIFFED 0x03
393 typedef uint8_t bt_gap_link_sniff_status_t;
395 #define BT_GAP_ACCEPT_AS_MASTER 0x00
396 #define BT_GAP_ACCEPT_AS_SLAVE 0x01
397 #define BT_GAP_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
398 #define BT_GAP_REJECTED_DUE_TO_SECURITY_REASONS 0x0E
399 #define BT_GAP_ACCEPT_REJECTED_DUE_TO_UNACCEPTABLE_BDADDR 0x0F
400 typedef uint8_t bt_gap_accept_connection_status_t;
402 typedef uint32_t bt_gap_connection_handle_t;
416 typedef struct {
418  bt_role_t local_role;
420 
426 typedef struct {
427  uint16_t max_sniff_interval;
428  uint16_t min_sniff_interval;
429  uint16_t sniff_attempt;
430  uint16_t sniff_timeout;
432 
436 typedef struct {
439  uint16_t sniff_interval;
441 
445 typedef struct {
446  uint16_t latency;
447  uint16_t min_remote_timeout;
448  uint16_t min_local_timeout;
450 
454 typedef struct {
456  bt_gap_link_status_t link_status;
457  const bt_bd_addr_t* address;
459 
463 typedef struct {
465  int8_t rssi;
467 
471 BT_PACKED (
472 typedef struct {
473  uint8_t pin_len;
474  uint8_t pin_code[BT_GAP_MAX_PIN_CODE_LENGTH];
480 typedef struct {
481  const bt_bd_addr_t* address;
482  uint32_t cod;
483  const uint8_t* rssi;
484  const uint8_t* eir;
486 
490 typedef struct {
491  const bt_bd_addr_t* address;
492  const char* name;
494 
498 BT_PACKED (
499 typedef struct {
500  bt_bd_addr_t address;
501  bt_key_t key;
502  bt_gap_link_key_type_t key_type;
508 typedef struct {
509  bt_gap_inquiry_mode_t inquiry_mode;
510  bt_gap_io_capability_t io_capability;
511  uint32_t cod;
512  char device_name[BT_GAP_MAX_DEVICE_NAME_LENGTH];
514 
527 
538 bt_status_t bt_gap_inquiry(uint8_t duration, uint8_t max_count);
539 
547 
557 
567 
577 
586 
595 
604 
612 
621 bt_status_t bt_gap_set_extended_inquiry_response(uint8_t* eir_data, uint32_t data_length);
622 
630 bt_status_t bt_gap_write_inquiry_tx(int8_t tx_power);
631 
639 
648 bt_status_t bt_gap_write_page_scan_activity(uint16_t interval, uint16_t window);
649 
658 bt_status_t bt_gap_write_inquiry_scan_activity(uint16_t interval, uint16_t window);
659 
667 
676 
682 
692 
700 
708 bt_status_t bt_gap_reply_passkey_request(const uint32_t* passkey);
709 
718 
725 
731 
739 
747 
759 
760 BT_EXTERN_C_END
761 
768 #endif
769 
uint16_t bt_gap_link_status_t
The link status types, refer to BT_GAP_LINK_STATUS_UPDATED_IND.
Definition: bt_gap.h:360
uint8_t bt_gap_inquiry_mode_t
The inquiry mode types.
Definition: bt_gap.h:389
bt_status_t bt_gap_cancel_inquiry(void)
This function stops the inquiry.
uint8_t bt_gap_security_auth_request_t
The types of authenticated request, refer to # bt_gap_reply_io_capability_request().
Definition: bt_gap.h:368
bt_status_t bt_gap_get_role(bt_gap_connection_handle_t handle)
This function gets the device's role type.
bt_status_t bt_gap_read_inquiry_response_tx(void)
This function reads the inquiry response transmit power.
bt_status_t bt_gap_write_inquiry_scan_activity(uint16_t interval, uint16_t window)
This function writes values for the interval and the window of inquiry scanning.
void bt_gap_get_link_key(bt_gap_link_key_notification_ind_t *key_information)
This is a user defined callback to get the link key and pass it to the GAP process.
bt_status_t bt_gap_reject_io_capability_request(void)
This function rejects the BT_GAP_IO_CAPABILITY_REQ_IND event and terminates the bonding.
bt_status_t bt_gap_set_role(bt_gap_connection_handle_t handle, bt_role_t role)
This function changes the device's role type.
bt_status_t bt_gap_read_rssi(bt_gap_connection_handle_t handle)
This function reads the RSSI of the connected device.
bt_status_t bt_gap_reply_user_confirm_request(bool accept)
This function is a reply to the BT_GAP_USER_CONFIRM_REQ_IND event.
uint8_t const * bt_bd_addr_ptr_t
A pointer to the bt_bd_addr_t.
Definition: bt_type.h:181
This structure defines the pin code information used in the function bt_gap_get_pin_code().
Definition: bt_gap.h:476
This structure defines the default sniff subrating parameters used in the function bt_gap_set_default...
Definition: bt_gap.h:446
uint8_t bt_role_t
Define the role type.
Definition: bt_type.h:98
const bt_bd_addr_t * bt_gap_get_remote_address(bt_gap_connection_handle_t handle)
This function gets the address of a connected device.
This structure defines the BT_GAP_SNIFF_MODE_CHANGE_IND parameter type.
Definition: bt_gap.h:437
uint8_t bt_gap_io_capability_t
The device IO Capability types.
Definition: bt_gap.h:344
bt_status_t bt_gap_reply_passkey_request(const uint32_t *passkey)
This function is a reply to the BT_GAP_USER_REPLY_PASSKEY_IND event.
bt_status_t bt_gap_exit_sniff_mode(bt_gap_connection_handle_t handle)
This function exits the sniff mode for the link.
const bt_gap_pin_code_information_t * bt_gap_get_pin_code(void)
This is a user defined callback to get the pin code and pass it to the GAP process.
bt_status_t bt_gap_enter_test_mode(void)
This function sets the device into a test mode.
uint8_t bt_gap_accept_connection_status_t
Connection request status check.
Definition: bt_gap.h:401
#define BT_GAP_MAX_DEVICE_NAME_LENGTH
The maximum length of the device name, including null-ending char.
Definition: bt_gap.h:332
bt_status_t bt_gap_set_default_sniff_subrating_parameters(const bt_gap_default_sniff_subrating_params_t *sniff_subrating_params)
This function sets the default subrating_parameters.
bt_status_t bt_gap_read_remote_name(const bt_bd_addr_t *address)
This function gets the device's name, no need to be connected to the device.
bt_status_t bt_gap_inquiry(uint8_t duration, uint8_t max_count)
This function inquires the search for nearby devices.
bt_status_t bt_gap_reply_io_capability_request(bt_gap_oob_data_presented_t oob_present, bt_gap_security_auth_request_t auth_request)
This function sends a reply to the BT_GAP_IO_CAPABILITY_REQ_IND event with Out-of-band data presented...
#define BT_GAP_MAX_PIN_CODE_LENGTH
The maximum length of pin code.
Definition: bt_gap.h:331
bt_status_t bt_gap_cancel_name_request(const bt_bd_addr_t *address)
This function cancels the request of bt_gap_read_remote_name().
uint8_t bt_gap_link_sniff_status_t
The connection sniff status types.
Definition: bt_gap.h:394
This structure defines the BT_GAP_ROLE_CHANGED_IND parameter type.
Definition: bt_gap.h:417
bt_status_t bt_gap_set_extended_inquiry_response(uint8_t *eir_data, uint32_t data_length)
This function sets the EIR data.
uint8_t bt_gap_oob_data_presented_t
The type of Out-of-band data are present.
Definition: bt_gap.h:338
This structure defines the BT_GAP_READ_RSSI_CNF parameter type.
Definition: bt_gap.h:464
uint8_t bt_bd_addr_t[6]
Address type, defined in Bluetooth core specification version 4.2.
Definition: bt_type.h:180
int32_t bt_status_t
Define the status type, returned from the APIs, and defined as BT_STATUS_XXX.
Definition: bt_type.h:173
bt_gap_accept_connection_status_t bt_gap_check_connect_request(bt_bd_addr_ptr_t address, uint32_t cod)
This is a user defined callback to check whether to accept the connecting request or reject it...
uint32_t bt_gap_connection_handle_t
The link handle type.
Definition: bt_gap.h:403
uint8_t bt_gap_link_key_type_t
The link-key types.
Definition: bt_gap.h:384
bt_status_t bt_gap_set_scan_mode(bt_gap_scan_mode_t mode)
This function sets the accessible mode.
uint8_t bt_gap_scan_mode_t
GAP scan mode types for bt_gap_set_scan_mode().
Definition: bt_gap.h:329
This structure defines the BT_GAP_INQUIRY_IND event parameter type.
Definition: bt_gap.h:481
bt_status_t bt_gap_write_page_scan_activity(uint16_t interval, uint16_t window)
This function writes the values for the interval and the window of page scanning. ...
bt_status_t bt_gap_disconnect(bt_gap_connection_handle_t handle)
This function disconnects the special link.
uint8_t bt_key_t[16]
Define the SM key type.
Definition: bt_type.h:91
This structure defines the BT_GAP_READ_REMOTE_NAME_COMPLETE_IND event parameter type.
Definition: bt_gap.h:491
bt_status_t bt_gap_write_inquiry_tx(int8_t tx_power)
This function writes the inquiry transmit power.
This structure defines the Bluetooth configuration information, please refer to bt_gap_get_local_conf...
Definition: bt_gap.h:509
bt_status_t bt_gap_set_default_sniff_parameters(const bt_gap_default_sniff_params_t *sniff_params)
This function sets the default sniff parameters.
bt_gap_role_changed_ind_t bt_gap_get_role_cnf_t
Define the BT_GAP_GET_ROLE_CNF parameter type.
Definition: bt_gap.h:422
This structure defines the default sniff parameters used in the function bt_gap_set_default_sniff_par...
Definition: bt_gap.h:427
const bt_gap_config_t * bt_gap_get_local_configuration(void)
This is a user defined callback to get the configuration parameters for the GAP initialization proces...