119e95205Sopenharmony_ci/*
219e95205Sopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
419e95205Sopenharmony_ci * you may not use this file except in compliance with the License.
519e95205Sopenharmony_ci * You may obtain a copy of the License at
619e95205Sopenharmony_ci *
719e95205Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
819e95205Sopenharmony_ci *
919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and
1319e95205Sopenharmony_ci * limitations under the License.
1419e95205Sopenharmony_ci */
1519e95205Sopenharmony_ci
1619e95205Sopenharmony_ci/**
1719e95205Sopenharmony_ci * @addtogroup Bluetooth
1819e95205Sopenharmony_ci * @{
1919e95205Sopenharmony_ci *
2019e95205Sopenharmony_ci * @brief Generic Access Profile
2119e95205Sopenharmony_ci *
2219e95205Sopenharmony_ci */
2319e95205Sopenharmony_ci
2419e95205Sopenharmony_ci/**
2519e95205Sopenharmony_ci * @file gap.h
2619e95205Sopenharmony_ci *
2719e95205Sopenharmony_ci * @brief bluetooth gap interface
2819e95205Sopenharmony_ci *
2919e95205Sopenharmony_ci */
3019e95205Sopenharmony_ci
3119e95205Sopenharmony_ci#ifndef GAP_IF_H
3219e95205Sopenharmony_ci#define GAP_IF_H
3319e95205Sopenharmony_ci
3419e95205Sopenharmony_ci#include "gap_comm.h"
3519e95205Sopenharmony_ci
3619e95205Sopenharmony_ci#ifdef __cplusplus
3719e95205Sopenharmony_ciextern "C" {
3819e95205Sopenharmony_ci#endif
3919e95205Sopenharmony_ci
4019e95205Sopenharmony_ci/**
4119e95205Sopenharmony_ci * @brief       Result callback of set scan mode.
4219e95205Sopenharmony_ci * @param[in]   status              Result of mode setting.
4319e95205Sopenharmony_ci * @param[in]   context             The context of the caller.
4419e95205Sopenharmony_ci * @return      @c void
4519e95205Sopenharmony_ci */
4619e95205Sopenharmony_citypedef void (*GapSetScanModeResultCallback)(uint8_t status, void *context);
4719e95205Sopenharmony_ci
4819e95205Sopenharmony_ci/**
4919e95205Sopenharmony_ci * @brief       Discoverability modes configuration parameter structure
5019e95205Sopenharmony_ci */
5119e95205Sopenharmony_citypedef struct {
5219e95205Sopenharmony_ci    uint8_t mode;           /// Discoverable Mode
5319e95205Sopenharmony_ci    uint8_t type;           /// Inquiry Scan Type
5419e95205Sopenharmony_ci    uint16_t scanInterval;  /// The amount of time between consecutive inquiry scans.
5519e95205Sopenharmony_ci    uint16_t scanWindow;    /// The amount of time for the duration of the inquiry scan.
5619e95205Sopenharmony_ci} GapDiscoverModeInfo;
5719e95205Sopenharmony_ci
5819e95205Sopenharmony_ci/**
5919e95205Sopenharmony_ci * @brief       Connectionability modes configuration parameter structure
6019e95205Sopenharmony_ci */
6119e95205Sopenharmony_citypedef struct {
6219e95205Sopenharmony_ci    uint8_t mode;           /// Connectable Mode
6319e95205Sopenharmony_ci    uint8_t type;           /// Page Scan Type
6419e95205Sopenharmony_ci    uint16_t scanInterval;  /// The amount of time between consecutive page scans.
6519e95205Sopenharmony_ci    uint16_t scanWindow;    /// The amount of time for the duration of the page scan.
6619e95205Sopenharmony_ci} GapConnectableModeInfo;
6719e95205Sopenharmony_ci
6819e95205Sopenharmony_ci/**
6919e95205Sopenharmony_ci * @brief       Service connection direction.
7019e95205Sopenharmony_ci */
7119e95205Sopenharmony_citypedef enum {
7219e95205Sopenharmony_ci    OUTGOING,
7319e95205Sopenharmony_ci    INCOMING,
7419e95205Sopenharmony_ci} GAP_ServiceConnectDirection;
7519e95205Sopenharmony_ci
7619e95205Sopenharmony_ci#define MAP_MAX_COUNT (13)
7719e95205Sopenharmony_ci
7819e95205Sopenharmony_ci/**
7919e95205Sopenharmony_ci * @brief       Service identity.
8019e95205Sopenharmony_ci */
8119e95205Sopenharmony_citypedef enum {
8219e95205Sopenharmony_ci    UNKNOWN_SERVICE,
8319e95205Sopenharmony_ci    GAP,
8419e95205Sopenharmony_ci    SDP,
8519e95205Sopenharmony_ci    GAVDP_INT,
8619e95205Sopenharmony_ci    GAVDP_ACP,
8719e95205Sopenharmony_ci    A2DP_SINK,
8819e95205Sopenharmony_ci    A2DP_SRC,
8919e95205Sopenharmony_ci    AVRCP_CT,
9019e95205Sopenharmony_ci    AVRCP_TG,
9119e95205Sopenharmony_ci    AVRCP_CT_BROWSING,
9219e95205Sopenharmony_ci    AVRCP_TG_BROWSING,
9319e95205Sopenharmony_ci    HFP_HF,
9419e95205Sopenharmony_ci    HFP_AG,
9519e95205Sopenharmony_ci    PBAP_CLIENT,
9619e95205Sopenharmony_ci    PBAP_SERVER,
9719e95205Sopenharmony_ci    MAP_CLIENT_ID_START,
9819e95205Sopenharmony_ci    MAP_CLIENT_ID_END = MAP_CLIENT_ID_START + MAP_MAX_COUNT,
9919e95205Sopenharmony_ci    MAP_SERVER_ID_START,
10019e95205Sopenharmony_ci    MAP_SERVER_ID_END = MAP_SERVER_ID_START + MAP_MAX_COUNT,
10119e95205Sopenharmony_ci    GATT_CLIENT,
10219e95205Sopenharmony_ci    GATT_SERVER,
10319e95205Sopenharmony_ci    RFCOMM,
10419e95205Sopenharmony_ci    SPP_ID_START,
10519e95205Sopenharmony_ci    HID_HOST,
10619e95205Sopenharmony_ci    PAN_BNEP,
10719e95205Sopenharmony_ci    OPP_CLIENT,
10819e95205Sopenharmony_ci    OPP_SERVER,
10919e95205Sopenharmony_ci} GAP_Service;
11019e95205Sopenharmony_ci
11119e95205Sopenharmony_ci/**
11219e95205Sopenharmony_ci * @brief       Multiplexing protocol identity.
11319e95205Sopenharmony_ci */
11419e95205Sopenharmony_citypedef enum {
11519e95205Sopenharmony_ci    SEC_PROTOCOL_L2CAP,
11619e95205Sopenharmony_ci    SEC_PROTOCOL_RFCOMM,
11719e95205Sopenharmony_ci} GAP_SecMultiplexingProtocol;
11819e95205Sopenharmony_ci
11919e95205Sopenharmony_ci/**
12019e95205Sopenharmony_ci * @brief       Protocol channel.
12119e95205Sopenharmony_ci */
12219e95205Sopenharmony_citypedef union {
12319e95205Sopenharmony_ci    uint16_t l2capPsm;
12419e95205Sopenharmony_ci    uint8_t rfcommChannel;
12519e95205Sopenharmony_ci} GapSecChannel;
12619e95205Sopenharmony_ci
12719e95205Sopenharmony_ci/// Security attributes
12819e95205Sopenharmony_ci#define GAP_SEC_IN_AUTHORIZATION (1 << 0)
12919e95205Sopenharmony_ci#define GAP_SEC_IN_AUTHENTICATION (1 << 1)
13019e95205Sopenharmony_ci#define GAP_SEC_IN_ENCRYPTION (1 << 2)
13119e95205Sopenharmony_ci#define GAP_SEC_MITM (1 << 3)
13219e95205Sopenharmony_ci#define GAP_SEC_OUT_AUTHENTICATION (1 << 4)
13319e95205Sopenharmony_ci#define GAP_SEC_OUT_ENCRYPTION (1 << 5)
13419e95205Sopenharmony_ci
13519e95205Sopenharmony_ci/**
13619e95205Sopenharmony_ci * @brief       Security request information structure.
13719e95205Sopenharmony_ci */
13819e95205Sopenharmony_citypedef struct {
13919e95205Sopenharmony_ci    GAP_ServiceConnectDirection direction;
14019e95205Sopenharmony_ci    GAP_Service serviceId;
14119e95205Sopenharmony_ci    GAP_SecMultiplexingProtocol protocolId;
14219e95205Sopenharmony_ci    GapSecChannel channelId;
14319e95205Sopenharmony_ci} GapServiceSecurityInfo;
14419e95205Sopenharmony_ci
14519e95205Sopenharmony_ci/**
14619e95205Sopenharmony_ci * @brief       Service security request result callback
14719e95205Sopenharmony_ci * @param[in]   result              security request result
14819e95205Sopenharmony_ci * @param[in]   serviceInfo         security request information
14919e95205Sopenharmony_ci * @param[in]   context             security request context
15019e95205Sopenharmony_ci * @return      @c void
15119e95205Sopenharmony_ci *
15219e95205Sopenharmony_ci */
15319e95205Sopenharmony_citypedef void (*GapSecurityResultCallback)(uint16_t result, GapServiceSecurityInfo serviceInfo, void *context);
15419e95205Sopenharmony_ci
15519e95205Sopenharmony_ci/**
15619e95205Sopenharmony_ci * @brief       parameter of interface GAP_RequestSecurity.
15719e95205Sopenharmony_ci */
15819e95205Sopenharmony_citypedef struct {
15919e95205Sopenharmony_ci    GapServiceSecurityInfo info;         /// Security request information
16019e95205Sopenharmony_ci    GapSecurityResultCallback callback;  /// Service request security result callback function
16119e95205Sopenharmony_ci    void *context;                       /// Service request security result callback function context parameter
16219e95205Sopenharmony_ci} GapRequestSecurityParam;
16319e95205Sopenharmony_ci
16419e95205Sopenharmony_ci/**
16519e95205Sopenharmony_ci * @brief       Security modes of BR/EDR physical transport.
16619e95205Sopenharmony_ci */
16719e95205Sopenharmony_citypedef enum {
16819e95205Sopenharmony_ci    SEC_MODE_2,
16919e95205Sopenharmony_ci    SEC_MODE_4,
17019e95205Sopenharmony_ci} GAP_SecurityMode;
17119e95205Sopenharmony_ci
17219e95205Sopenharmony_ci/**
17319e95205Sopenharmony_ci * @brief       Service security verify callback structure of BR/EDR physical transport.
17419e95205Sopenharmony_ci */
17519e95205Sopenharmony_citypedef struct {
17619e95205Sopenharmony_ci    /// Service authorization verify callback
17719e95205Sopenharmony_ci    void (*authorizeInd)(const BtAddr *addr, GAP_Service service, void *context);
17819e95205Sopenharmony_ci} GapSecurityCallback;
17919e95205Sopenharmony_ci
18019e95205Sopenharmony_ci/**
18119e95205Sopenharmony_ci * @brief       authentication callback structure.
18219e95205Sopenharmony_ci */
18319e95205Sopenharmony_citypedef struct {
18419e95205Sopenharmony_ci    void (*userConfirmReq)(const BtAddr *addr, uint32_t number, int localMitmRequired,
18519e95205Sopenharmony_ci        int remoteMitmRequired, void *context);
18619e95205Sopenharmony_ci    void (*userPasskeyReq)(const BtAddr *addr, void *context);
18719e95205Sopenharmony_ci    void (*userPasskeyNotification)(const BtAddr *addr, uint32_t number, void *context);
18819e95205Sopenharmony_ci    void (*remoteOobReq)(const BtAddr *addr, void *context);
18919e95205Sopenharmony_ci    void (*pinCodeReq)(const BtAddr *addr, void *context);
19019e95205Sopenharmony_ci    void (*linkKeyReq)(const BtAddr *addr, void *context);
19119e95205Sopenharmony_ci    void (*linkKeyNotification)(
19219e95205Sopenharmony_ci        const BtAddr *addr, const uint8_t linkKey[GAP_LINKKEY_SIZE], uint8_t keyType, void *context);
19319e95205Sopenharmony_ci    void (*simplePairComplete)(const BtAddr *addr, uint8_t status, void *context);
19419e95205Sopenharmony_ci    void (*IOCapabilityReq)(const BtAddr *addr, void *context);
19519e95205Sopenharmony_ci    void (*IOCapabilityRsp)(const BtAddr *addr, uint8_t ioCapability, void *context);
19619e95205Sopenharmony_ci    void (*authenticationComplete)(const BtAddr *addr, uint8_t status, void *context);
19719e95205Sopenharmony_ci    void (*encryptionChangeCallback)(const BtAddr *addr, uint8_t status, void *context);
19819e95205Sopenharmony_ci} GapAuthenticationCallback;
19919e95205Sopenharmony_ci
20019e95205Sopenharmony_ci/**
20119e95205Sopenharmony_ci * @brief       Encryption change result callback
20219e95205Sopenharmony_ci * @param[in]   addr                encryption change target device address
20319e95205Sopenharmony_ci * @param[in]   status              encryption change result status
20419e95205Sopenharmony_ci * @param[in]   context             encryption change context
20519e95205Sopenharmony_ci * @return      @c void
20619e95205Sopenharmony_ci */
20719e95205Sopenharmony_citypedef void (*GapEncryptionChangeCallback)(const BtAddr *addr, uint8_t status, void *context);
20819e95205Sopenharmony_ci
20919e95205Sopenharmony_ci/// Inquiry mode
21019e95205Sopenharmony_ci#define GAP_INQUIRY_MODE_GENERAL 0x00
21119e95205Sopenharmony_ci#define GAP_INQUIRY_MODE_LIMITED 0x01
21219e95205Sopenharmony_ci
21319e95205Sopenharmony_ci/**
21419e95205Sopenharmony_ci * @brief       Device discover callback structure.
21519e95205Sopenharmony_ci */
21619e95205Sopenharmony_citypedef struct {
21719e95205Sopenharmony_ci    void (*inquiryResult)(const BtAddr *addr, uint32_t classOfDevice, void *context);
21819e95205Sopenharmony_ci    void (*inquiryResultRssi)(const BtAddr *addr, uint32_t classOfDevice, int8_t rssi, void *context);
21919e95205Sopenharmony_ci    void (*extendedInquiryResult)(
22019e95205Sopenharmony_ci        const BtAddr *addr, uint32_t classOfDevice, int8_t rssi, const uint8_t eir[GAP_EIR_SIZE_MAX], void *context);
22119e95205Sopenharmony_ci    void (*remoteName)(uint8_t status, const BtAddr *addr, const uint8_t name[GAP_NAME_SIZE_MAX], void *context);
22219e95205Sopenharmony_ci    void (*inquiryComplete)(uint8_t status, void *context);
22319e95205Sopenharmony_ci} GapDiscoveryCallback;
22419e95205Sopenharmony_ci
22519e95205Sopenharmony_ci/**
22619e95205Sopenharmony_ci * @brief       Set local bluetooth device name. (Used for BR/EDR)
22719e95205Sopenharmony_ci * @param[in]   name                Bluetooth device name.
22819e95205Sopenharmony_ci * @param[in]   length              Length of the device name. (248 or less)
22919e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
23019e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
23119e95205Sopenharmony_ci */
23219e95205Sopenharmony_ciBTSTACK_API int GAPIF_SetLocalName(const char *name, int length);
23319e95205Sopenharmony_ci
23419e95205Sopenharmony_ci/**
23519e95205Sopenharmony_ci * @brief       Set local bluetooth device class.
23619e95205Sopenharmony_ci * @param[in]   cod                 Bluetooth device class.
23719e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
23819e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
23919e95205Sopenharmony_ci */
24019e95205Sopenharmony_ciBTSTACK_API int GAPIF_SetClassOfDevice(uint32_t cod);
24119e95205Sopenharmony_ci
24219e95205Sopenharmony_ci/**
24319e95205Sopenharmony_ci * @brief       Set local bluetooth device class.
24419e95205Sopenharmony_ci * @param[in]   cod                 Bluetooth device class.
24519e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
24619e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
24719e95205Sopenharmony_ci */
24819e95205Sopenharmony_ciBTSTACK_API int GAPIF_SetExtendedInquiryResponse(const uint8_t eir[GAP_EIR_SIZE_MAX]);
24919e95205Sopenharmony_ci
25019e95205Sopenharmony_ci/**
25119e95205Sopenharmony_ci * @brief       Set scan mode of bluetooth BR/EDR physical transport.
25219e95205Sopenharmony_ci * @param[in]   discoverInfo        Discoverability modes configuration parameter.
25319e95205Sopenharmony_ci * @param[in]   connectableInfo     Connectionability modes configuration parameter.
25419e95205Sopenharmony_ci * @param[in]   callback            Callback function for the result.
25519e95205Sopenharmony_ci * @param[in]   context             The context of the callback function.
25619e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
25719e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
25819e95205Sopenharmony_ci * @see         BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C
25919e95205Sopenharmony_ci *              4.1 DISCOVERABILITY MODES
26019e95205Sopenharmony_ci *              4.2 CONNECTABILITY MODES
26119e95205Sopenharmony_ci */
26219e95205Sopenharmony_ciBTSTACK_API int GAPIF_SetScanMode(const GapDiscoverModeInfo *discoverInfo,
26319e95205Sopenharmony_ci    const GapConnectableModeInfo *connectableInfo, GapSetScanModeResultCallback callback, void *context);
26419e95205Sopenharmony_ci
26519e95205Sopenharmony_ci/**
26619e95205Sopenharmony_ci * @brief       Set boneable mode of bluetooth BR/EDR physical transport.
26719e95205Sopenharmony_ci * @param[in]   isBondable          boneable mode
26819e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
26919e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
27019e95205Sopenharmony_ci * @see         BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C
27119e95205Sopenharmony_ci *              4.3 BONDABLE MODES
27219e95205Sopenharmony_ci */
27319e95205Sopenharmony_ciBTSTACK_API int GAPIF_SetBondableMode(uint8_t isBondable);
27419e95205Sopenharmony_ci
27519e95205Sopenharmony_ci/**
27619e95205Sopenharmony_ci * @brief       Service register security requirements to GAP
27719e95205Sopenharmony_ci * @param[in]   addr                outgoing attributes to remote device
27819e95205Sopenharmony_ci * @param[in]   serviceInfo         security requirements information
27919e95205Sopenharmony_ci * @param[in]   securityMode        Security attributes
28019e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
28119e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
28219e95205Sopenharmony_ci */
28319e95205Sopenharmony_ciBTSTACK_API int GAPIF_RegisterServiceSecurity(
28419e95205Sopenharmony_ci    const BtAddr *addr, const GapServiceSecurityInfo *serviceInfo, uint16_t securityMode);
28519e95205Sopenharmony_ciBTSTACK_API int GAPIF_RegisterServiceSecurityAsync(
28619e95205Sopenharmony_ci    const BtAddr *addr, const GapServiceSecurityInfo *serviceInfo, uint16_t securityMode);
28719e95205Sopenharmony_ci
28819e95205Sopenharmony_ci/**
28919e95205Sopenharmony_ci * @brief       Service deregister security requirements to GAP
29019e95205Sopenharmony_ci * @param[in]   addr                outgoing attributes to remote device
29119e95205Sopenharmony_ci * @param[in]   serviceInfo         security requirements information
29219e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
29319e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
29419e95205Sopenharmony_ci */
29519e95205Sopenharmony_ciBTSTACK_API int GAPIF_DeregisterServiceSecurity(const BtAddr *addr, const GapServiceSecurityInfo *serviceInfo);
29619e95205Sopenharmony_ciBTSTACK_API int GAPIF_DeregisterServiceSecurityAsync(const BtAddr *addr, const GapServiceSecurityInfo *serviceInfo);
29719e95205Sopenharmony_ci
29819e95205Sopenharmony_ci/**
29919e95205Sopenharmony_ci * @brief       Service request security requirements to GAP
30019e95205Sopenharmony_ci * @param[in]   addr                target device address
30119e95205Sopenharmony_ci * @param[in]   param               structure of security requirements information and result callback function
30219e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
30319e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
30419e95205Sopenharmony_ci */
30519e95205Sopenharmony_ciBTSTACK_API int GAPIF_RequestSecurity(const BtAddr *addr, const GapRequestSecurityParam *param);
30619e95205Sopenharmony_ciBTSTACK_API int GAPIF_RequestSecurityAsync(const BtAddr *addr, const GapRequestSecurityParam *param);
30719e95205Sopenharmony_ci
30819e95205Sopenharmony_ci/**
30919e95205Sopenharmony_ci * @brief       Register service security verify callback
31019e95205Sopenharmony_ci * @param[in]   callback            security verify callback
31119e95205Sopenharmony_ci * @param[in]   context             security verify callback context parameter
31219e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
31319e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
31419e95205Sopenharmony_ci */
31519e95205Sopenharmony_ciBTSTACK_API int GAPIF_RegisterSecurityCallback(const GapSecurityCallback *callback, void *context);
31619e95205Sopenharmony_ci
31719e95205Sopenharmony_ci/**
31819e95205Sopenharmony_ci * @brief       Deregister service security verify callback
31919e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
32019e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
32119e95205Sopenharmony_ci */
32219e95205Sopenharmony_ciBTSTACK_API int GAPIF_DeregisterSecurityCallback(void);
32319e95205Sopenharmony_ci
32419e95205Sopenharmony_ci/**
32519e95205Sopenharmony_ci * @brief       Set security modes of BR/EDR physical transport
32619e95205Sopenharmony_ci * @param[in]   mode                security modes
32719e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
32819e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
32919e95205Sopenharmony_ci */
33019e95205Sopenharmony_ciBTSTACK_API int GAPIF_SetSecurityMode(GAP_SecurityMode mode);
33119e95205Sopenharmony_ci
33219e95205Sopenharmony_ci/**
33319e95205Sopenharmony_ci * @brief       Service authorization verify response
33419e95205Sopenharmony_ci * @param[in]   addr                target device address
33519e95205Sopenharmony_ci * @param[in]   service             service identity
33619e95205Sopenharmony_ci * @param[in]   accept              accept or reject
33719e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
33819e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
33919e95205Sopenharmony_ci */
34019e95205Sopenharmony_ciBTSTACK_API int GAPIF_AuthorizeRes(const BtAddr *addr, GAP_Service service, uint8_t accept);
34119e95205Sopenharmony_ci
34219e95205Sopenharmony_ci/**
34319e95205Sopenharmony_ci * @brief       Register authentication callback
34419e95205Sopenharmony_ci * @param[in]   callback            authentication callback structure
34519e95205Sopenharmony_ci * @param[in]   context             authentication verify callback context parameter
34619e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
34719e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
34819e95205Sopenharmony_ci */
34919e95205Sopenharmony_ciBTSTACK_API int GAPIF_RegisterAuthenticationCallback(const GapAuthenticationCallback *callback, void *context);
35019e95205Sopenharmony_ci
35119e95205Sopenharmony_ci/**
35219e95205Sopenharmony_ci * @brief       Deregister authentication callback
35319e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
35419e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
35519e95205Sopenharmony_ci */
35619e95205Sopenharmony_ciBTSTACK_API int GAPIF_DeregisterAuthenticationCallback(void);
35719e95205Sopenharmony_ci
35819e95205Sopenharmony_ci/**
35919e95205Sopenharmony_ci * @brief       Get current pair originator
36019e95205Sopenharmony_ci * @param[in]   addr                pairing device address
36119e95205Sopenharmony_ci * @param[out]  isLocal             is local initiate
36219e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
36319e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
36419e95205Sopenharmony_ci */
36519e95205Sopenharmony_ciBTSTACK_API int GAPIF_PairIsFromLocal(const BtAddr *addr, bool *isLocal);
36619e95205Sopenharmony_ci
36719e95205Sopenharmony_ci/**
36819e95205Sopenharmony_ci * @brief       authenticate the remote device associated.
36919e95205Sopenharmony_ci * @param[in]   addr                target device address
37019e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
37119e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
37219e95205Sopenharmony_ci */
37319e95205Sopenharmony_ciBTSTACK_API int GAPIF_AuthenticationReq(const BtAddr *addr);
37419e95205Sopenharmony_ci
37519e95205Sopenharmony_ci/**
37619e95205Sopenharmony_ci * @brief       cancel authenticate the remote device associated.
37719e95205Sopenharmony_ci * @param[in]   addr                target device address
37819e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
37919e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
38019e95205Sopenharmony_ci */
38119e95205Sopenharmony_ciBTSTACK_API int GAPIF_CancelAuthenticationReq(const BtAddr *addr);
38219e95205Sopenharmony_ci
38319e95205Sopenharmony_ci/**
38419e95205Sopenharmony_ci * @brief       Respond IO capability request. Reply callback GapAuthenticationCallback::IOCapabilityReq
38519e95205Sopenharmony_ci * @param[in]   addr                target device address
38619e95205Sopenharmony_ci * @param[in]   accept              accept or reject
38719e95205Sopenharmony_ci * @param[in]   ioCapability        local device IO capability
38819e95205Sopenharmony_ci * @param[in]   oobDataPresent      OOB authentication data from remote device present
38919e95205Sopenharmony_ci * @param[in]   authReq             Authentication Requirements: MITM protection
39019e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
39119e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
39219e95205Sopenharmony_ci */
39319e95205Sopenharmony_ciBTSTACK_API int GAPIF_IOCapabilityRsp(
39419e95205Sopenharmony_ci    const BtAddr *addr, uint8_t accept, uint8_t ioCapability, uint8_t oobDataPresent, uint8_t authReq);
39519e95205Sopenharmony_ci
39619e95205Sopenharmony_ci/**
39719e95205Sopenharmony_ci * @brief       Respond user confirmation request. Reply callback GapAuthenticationCallback::userConfirmReq
39819e95205Sopenharmony_ci * @param[in]   addr                target device address
39919e95205Sopenharmony_ci * @param[in]   accept              accept or reject
40019e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
40119e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
40219e95205Sopenharmony_ci */
40319e95205Sopenharmony_ciBTSTACK_API int GAPIF_UserConfirmRsp(const BtAddr *addr, uint8_t accept);
40419e95205Sopenharmony_ci
40519e95205Sopenharmony_ci/**
40619e95205Sopenharmony_ci * @brief       Respond user passkey request. Reply callback GapAuthenticationCallback::userPasskeyReq
40719e95205Sopenharmony_ci * @param[in]   addr                target device address
40819e95205Sopenharmony_ci * @param[in]   accept              accept or reject
40919e95205Sopenharmony_ci * @param[in]   number              user input number (000000 - 999999)
41019e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
41119e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
41219e95205Sopenharmony_ci */
41319e95205Sopenharmony_ciBTSTACK_API int GAPIF_UserPasskeyRsp(const BtAddr *addr, uint8_t accept, uint32_t number);
41419e95205Sopenharmony_ci
41519e95205Sopenharmony_ci/**
41619e95205Sopenharmony_ci * @brief       Respond remote OOB data request. Reply callback GapAuthenticationCallback::remoteOobReq
41719e95205Sopenharmony_ci * @param[in]   addr                target device address
41819e95205Sopenharmony_ci * @param[in]   accept              accept or reject
41919e95205Sopenharmony_ci * @param[in]   data                OOB data
42019e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
42119e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
42219e95205Sopenharmony_ci */
42319e95205Sopenharmony_ciBTSTACK_API int GAPIF_RemoteOobRsp(const BtAddr *addr, uint8_t accept, const GapOOBData *data);
42419e95205Sopenharmony_ci
42519e95205Sopenharmony_ci/**
42619e95205Sopenharmony_ci * @brief       Respond PIN code request. Reply callback GapAuthenticationCallback::pinCodeReq
42719e95205Sopenharmony_ci * @param[in]   addr                target device address
42819e95205Sopenharmony_ci * @param[in]   accept              accept or reject
42919e95205Sopenharmony_ci * @param[in]   pinCode             PIN code data
43019e95205Sopenharmony_ci * @param[in]   pinCodeLength       PIN code data length
43119e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
43219e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
43319e95205Sopenharmony_ci */
43419e95205Sopenharmony_ciBTSTACK_API int GAPIF_PinCodeRsp(const BtAddr *addr, uint8_t accept, const uint8_t *pinCode, uint8_t pinCodeLength);
43519e95205Sopenharmony_ci
43619e95205Sopenharmony_ci/**
43719e95205Sopenharmony_ci * @brief       Respond link key request. Reply callback GapAuthenticationCallback::linkKeyReq
43819e95205Sopenharmony_ci * @param[in]   addr                target device address
43919e95205Sopenharmony_ci * @param[in]   accept              accept or reject
44019e95205Sopenharmony_ci * @param[in]   linkKey             link key
44119e95205Sopenharmony_ci * @param[in]   keyType             link key type
44219e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
44319e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
44419e95205Sopenharmony_ci */
44519e95205Sopenharmony_ciBTSTACK_API int GAPIF_LinkKeyRsp(
44619e95205Sopenharmony_ci    const BtAddr *addr, uint8_t accept, const uint8_t linkKey[GAP_LINKKEY_SIZE], uint8_t keyType);
44719e95205Sopenharmony_ci
44819e95205Sopenharmony_ci/**
44919e95205Sopenharmony_ci * @brief       Register device discover callback
45019e95205Sopenharmony_ci * @param[in]   callback            device discover callback structure
45119e95205Sopenharmony_ci * @param[in]   context             device discover callback context parameter
45219e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
45319e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
45419e95205Sopenharmony_ci */
45519e95205Sopenharmony_ciBTSTACK_API int GAPIF_RegisterDiscoveryCallback(const GapDiscoveryCallback *callback, void *context);
45619e95205Sopenharmony_ci
45719e95205Sopenharmony_ci/**
45819e95205Sopenharmony_ci * @brief       Deregister device discover callback
45919e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
46019e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
46119e95205Sopenharmony_ci */
46219e95205Sopenharmony_ciBTSTACK_API int GAPIF_DeregisterDiscoveryCallback(void);
46319e95205Sopenharmony_ci
46419e95205Sopenharmony_ci/**
46519e95205Sopenharmony_ci * @brief       discover other nearby BR/EDR Controllers
46619e95205Sopenharmony_ci * @param[in]   mode                Inquiry mode
46719e95205Sopenharmony_ci * @param[in]   inquiryLength       Maximum inquiry time.(n * 1.28s)
46819e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
46919e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
47019e95205Sopenharmony_ci */
47119e95205Sopenharmony_ciBTSTACK_API int GAPIF_Inquiry(uint8_t mode, uint8_t inquiryLength);
47219e95205Sopenharmony_ci
47319e95205Sopenharmony_ci/**
47419e95205Sopenharmony_ci * @brief       Cancel discover other nearby BR/EDR Controllers
47519e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
47619e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
47719e95205Sopenharmony_ci */
47819e95205Sopenharmony_ciBTSTACK_API int GAPIF_InquiryCancel(void);
47919e95205Sopenharmony_ci
48019e95205Sopenharmony_ci/**
48119e95205Sopenharmony_ci * @brief       Get remote device name
48219e95205Sopenharmony_ci * @param[in]   addr                target device address
48319e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
48419e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
48519e95205Sopenharmony_ci */
48619e95205Sopenharmony_ciBTSTACK_API int GAPIF_GetRemoteName(const BtAddr *addr);
48719e95205Sopenharmony_ci
48819e95205Sopenharmony_ci/**
48919e95205Sopenharmony_ci * @brief       Cancel get remote device name
49019e95205Sopenharmony_ci * @param[in]   addr                target device address
49119e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
49219e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
49319e95205Sopenharmony_ci */
49419e95205Sopenharmony_ciBTSTACK_API int GAPIF_GetRemoteNameCancel(const BtAddr *addr);
49519e95205Sopenharmony_ci
49619e95205Sopenharmony_ci/**
49719e95205Sopenharmony_ci * @brief       Get local bluetooth address from HCI.
49819e95205Sopenharmony_ci * @param[out]  addr                Bluetooth address of bluetooth chip.
49919e95205Sopenharmony_ci * @return      @c BT_SUCCESS      : The function is executed successfully.
50019e95205Sopenharmony_ci *              @c otherwise        : The function is not executed successfully.
50119e95205Sopenharmony_ci */
50219e95205Sopenharmony_ciBTSTACK_API int GAPIF_GetLocalAddr(BtAddr *addr);
50319e95205Sopenharmony_ci
50419e95205Sopenharmony_ci#ifdef __cplusplus
50519e95205Sopenharmony_ci}
50619e95205Sopenharmony_ci#endif
50719e95205Sopenharmony_ci
50819e95205Sopenharmony_ci#endif /* GAP_IF_H */
509