MT2523 API Reference  LinkIt SDK v4
bt_gap.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 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)
323 #define BT_GAP_SCAN_MODE_NOT_ACCESSIBLE 0x00
324 #define BT_GAP_SCAN_MODE_DISCOVERABLE_ONLY 0x01
325 #define BT_GAP_SCAN_MODE_CONNECTABLE_ONLY 0x02
326 #define BT_GAP_SCAN_MODE_GENERAL_ACCESSIBLE 0x03
327 typedef uint8_t bt_gap_scan_mode_t;
329 #define BT_GAP_MAX_PIN_CODE_LENGTH 16
330 #define BT_GAP_MAX_DEVICE_NAME_LENGTH 31
332 #define BT_GAP_OOB_DATA_PRESENTED_NONE 0x00
333 #define BT_GAP_OOB_DATA_PRESENTED_P192 0x01
334 #define BT_GAP_OOB_DATA_PRESENTED_P256 0x02
335 #define BT_GAP_OOB_DATA_PRESENTED_P192_AND_P256 0x03
336 typedef uint8_t bt_gap_oob_data_presented_t;
338 #define BT_GAP_IO_CAPABILITY_DISPLAY_ONLY 0x00
339 #define BT_GAP_IO_CAPABILITY_DISPLAY_YES_NO 0x01
340 #define BT_GAP_IO_CAPABILITY_KEYBOARD_ONLY 0x02
341 #define BT_GAP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 0x03
342 typedef uint8_t bt_gap_io_capability_t;
344 #define BT_GAP_SECURITY_LEVEL_0 0x8000
345 #define BT_GAP_SECURITY_LEVEL_1 0x9000
346 #define BT_GAP_SECURITY_LEVEL_2 0xA000
347 #define BT_GAP_SECURITY_LEVEL_3 0xB000
348 #define BT_GAP_SECURITY_LEVEL_4 0xC000
349 typedef uint16_t bt_gap_security_level_t;
351 #define BT_GAP_LINK_STATUS_NONE 0x0000
352 #define BT_GAP_LINK_STATUS_DISCONNECTED 0x0004
353 #define BT_GAP_LINK_STATUS_CONNECTED_0 BT_GAP_SECURITY_LEVEL_0
354 #define BT_GAP_LINK_STATUS_CONNECTED_1 BT_GAP_SECURITY_LEVEL_1
355 #define BT_GAP_LINK_STATUS_CONNECTED_2 BT_GAP_SECURITY_LEVEL_2
356 #define BT_GAP_LINK_STATUS_CONNECTED_3 BT_GAP_SECURITY_LEVEL_3
357 #define BT_GAP_LINK_STATUS_CONNECTED_4 BT_GAP_SECURITY_LEVEL_4
358 typedef uint16_t bt_gap_link_status_t;
360 #define BT_GAP_SECURITY_AUTH_REQUEST_NO_BONDING_AUTO_ACCEPTED 0x00
361 #define BT_GAP_SECURITY_AUTH_REQUEST_MITM_NO_BONDING 0x01
362 #define BT_GAP_SECURITY_AUTH_REQUEST_DEDICATED_BONDING_AUTO_ACCEPTED 0x02
363 #define BT_GAP_SECURITY_AUTH_REQUEST_MITM_DEDICATED_BONDING 0x03
364 #define BT_GAP_SECURITY_AUTH_REQUEST_GENERAL_BONDING_AUTO_ACCEPTED 0x04
365 #define BT_GAP_SECURITY_AUTH_REQUEST_MITM_GENERAL_BONDING 0x05
366 typedef uint8_t bt_gap_security_auth_request_t;
368 #define BT_GAP_LINK_KEY_TYPE_COMBINATION 0x00
369 #define BT_GAP_LINK_KEY_TYPE_LOCAL_UNIT 0x01
370 #define BT_GAP_LINK_KEY_TYPE_REMOTE_UNIT 0x02
371 #define BT_GAP_LINK_KEY_TYPE_DEBUG 0x03
372 #define BT_GAP_LINK_KEY_TYPE_UNAUTH_P192 0x04
373 #define BT_GAP_LINK_KEY_TYPE_AUTH_P192 0x05
374 #define BT_GAP_LINK_KEY_TYPE_CHANGED 0x06
375 #define BT_GAP_LINK_KEY_TYPE_UNAUTH_P256 0x07
376 #define BT_GAP_LINK_KEY_TYPE_AUTH_P256 0x08
380 #define BT_GAP_LINK_KEY_TYPE_INVAILIDE 0xFF
381 #define BT_GAP_LINK_KEY_TYPE_INVALID 0xFF
382 typedef uint8_t bt_gap_link_key_type_t;
384 #define BT_GAP_INQUIRY_MODE_STANDARD 0x00
385 #define BT_GAP_INQUIRY_MODE_RSSI 0x01
386 #define BT_GAP_INQUIRY_MODE_RSSI_EIR 0x02
387 typedef uint8_t bt_gap_inquiry_mode_t;
390 typedef uint32_t bt_gap_connection_handle_t;
404 typedef struct {
406  bt_role_t local_role;
408 
414 typedef struct {
415  uint16_t max_sniff_interval;
416  uint16_t min_sniff_interval;
417  uint16_t sniff_attempt;
418  uint16_t sniff_timeout;
420 
424 typedef struct {
425  uint16_t latency;
426  uint16_t min_remote_timeout;
427  uint16_t min_local_timeout;
429 
433 typedef struct {
435  bt_gap_link_status_t link_status;
436  const bt_bd_addr_t* address;
438 
442 typedef struct {
444  int8_t rssi;
446 
450 BT_PACKED (
451 typedef struct {
452  uint8_t pin_len;
453  uint8_t pin_code[BT_GAP_MAX_PIN_CODE_LENGTH];
459 typedef struct {
460  const bt_bd_addr_t* address;
461  uint32_t cod;
462  const uint8_t* rssi;
463  const uint8_t* eir;
465 
469 typedef struct {
470  const bt_bd_addr_t* address;
471  const char* name;
473 
477 BT_PACKED (
478 typedef struct {
479  bt_bd_addr_t address;
480  bt_key_t key;
481  bt_gap_link_key_type_t key_type;
487 typedef struct {
488  bt_gap_inquiry_mode_t inquiry_mode;
489  bt_gap_io_capability_t io_capability;
490  uint32_t cod;
491  char device_name[BT_GAP_MAX_DEVICE_NAME_LENGTH];
493 
506 
517 bt_status_t bt_gap_inquiry(uint8_t duration, uint8_t max_count);
518 
526 
536 
546 
555 
564 
573 
581 
590 bt_status_t bt_gap_set_extended_inquiry_response(uint8_t* eir_data, uint32_t data_length);
591 
599 bt_status_t bt_gap_write_inquiry_tx(int8_t tx_power);
600 
608 
617 bt_status_t bt_gap_write_page_scan_activity(uint16_t interval, uint16_t window);
618 
627 bt_status_t bt_gap_write_inquiry_scan_activity(uint16_t interval, uint16_t window);
628 
636 
645 
651 
661 
669 
677 bt_status_t bt_gap_reply_passkey_request(const uint32_t* passkey);
678 
687 
694 
700 
708 
716 
717 BT_EXTERN_C_END
718 
725 #endif
726 
uint16_t bt_gap_link_status_t
The link status types, refer to BT_GAP_LINK_STATUS_UPDATED_IND.
Definition: bt_gap.h:359
uint8_t bt_gap_inquiry_mode_t
The inquiry mode types.
Definition: bt_gap.h:388
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:367
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.
This structure defines the pin code information used in the function bt_gap_get_pin_code().
Definition: bt_gap.h:455
This structure defines the default sniff subrating parameters used in the function bt_gap_set_default...
Definition: bt_gap.h:425
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.
uint8_t bt_gap_io_capability_t
The device IO Capability types.
Definition: bt_gap.h:343
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.
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.
#define BT_GAP_MAX_DEVICE_NAME_LENGTH
The maximum length of the device name, including null-ending char.
Definition: bt_gap.h:331
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:330
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().
This structure defines the BT_GAP_ROLE_CHANGED_IND parameter type.
Definition: bt_gap.h:405
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 being presented.
Definition: bt_gap.h:337
This structure defines the BT_GAP_READ_RSSI_CNF parameter type.
Definition: bt_gap.h:443
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
uint32_t bt_gap_connection_handle_t
The link handle type.
Definition: bt_gap.h:391
uint8_t bt_gap_link_key_type_t
The link-key types.
Definition: bt_gap.h:383
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:328
This structure defines the BT_GAP_INQUIRY_IND event parameter type.
Definition: bt_gap.h:460
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:470
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:488
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:410
This structure defines the default sniff parameters used in the function bt_gap_set_default_sniff_par...
Definition: bt_gap.h:415
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...