119e95205Sopenharmony_ci/* 219e95205Sopenharmony_ci * Copyright (C) 2021 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#ifndef GAP_H 1719e95205Sopenharmony_ci#define GAP_H 1819e95205Sopenharmony_ci 1919e95205Sopenharmony_ci#include <stdbool.h> 2019e95205Sopenharmony_ci#include <stddef.h> 2119e95205Sopenharmony_ci#include <stdlib.h> 2219e95205Sopenharmony_ci 2319e95205Sopenharmony_ci#include "btstack.h" 2419e95205Sopenharmony_ci#include "gap_if.h" 2519e95205Sopenharmony_ci 2619e95205Sopenharmony_ci#ifdef __cplusplus 2719e95205Sopenharmony_ciextern "C" { 2819e95205Sopenharmony_ci#endif 2919e95205Sopenharmony_ci 3019e95205Sopenharmony_ci/** 3119e95205Sopenharmony_ci * @brief Get local bluetooth address from HCI. 3219e95205Sopenharmony_ci * @param[out] addr Bluetooth address of bluetooth chip. 3319e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 3419e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 3519e95205Sopenharmony_ci */ 3619e95205Sopenharmony_ciint GAP_GetLocalAddr(BtAddr *addr); 3719e95205Sopenharmony_ci 3819e95205Sopenharmony_ci/** 3919e95205Sopenharmony_ci * @brief Set local bluetooth device name. (Used for BR/EDR) 4019e95205Sopenharmony_ci * @param[in] name Bluetooth device name. 4119e95205Sopenharmony_ci * @param[in] length Length of the device name. (248 or less) 4219e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 4319e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 4419e95205Sopenharmony_ci */ 4519e95205Sopenharmony_ciint GAP_SetLocalName(const char *name, int length); 4619e95205Sopenharmony_ci 4719e95205Sopenharmony_ci/** 4819e95205Sopenharmony_ci * @brief Set local bluetooth device class. 4919e95205Sopenharmony_ci * @param[in] cod Bluetooth device class. 5019e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 5119e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 5219e95205Sopenharmony_ci */ 5319e95205Sopenharmony_ciint GAP_SetClassOfDevice(uint32_t cod); 5419e95205Sopenharmony_ci 5519e95205Sopenharmony_ci/** 5619e95205Sopenharmony_ci * @brief Set local bluetooth device class. 5719e95205Sopenharmony_ci * @param[in] cod Bluetooth device class. 5819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 5919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 6019e95205Sopenharmony_ci */ 6119e95205Sopenharmony_ciint GAP_SetExtendedInquiryResponse(const uint8_t eir[GAP_EIR_SIZE_MAX]); 6219e95205Sopenharmony_ci 6319e95205Sopenharmony_ci/** 6419e95205Sopenharmony_ci * @brief Set scan mode of bluetooth BR/EDR physical transport. 6519e95205Sopenharmony_ci * @param[in] discoverInfo Discoverability modes configuration parameter. 6619e95205Sopenharmony_ci * @param[in] connectableInfo Connectionability modes configuration parameter. 6719e95205Sopenharmony_ci * @param[in] callback Callback function for the result. 6819e95205Sopenharmony_ci * @param[in] context The context of the callback function. 6919e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 7019e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 7119e95205Sopenharmony_ci * @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C 7219e95205Sopenharmony_ci * 4.1 DISCOVERABILITY MODES 7319e95205Sopenharmony_ci * 4.2 CONNECTABILITY MODES 7419e95205Sopenharmony_ci */ 7519e95205Sopenharmony_ciint GAP_SetScanMode(const GapDiscoverModeInfo *discoverInfo, const GapConnectableModeInfo *connectableInfo, 7619e95205Sopenharmony_ci GapSetScanModeResultCallback callback, void *context); 7719e95205Sopenharmony_ci 7819e95205Sopenharmony_ci/** 7919e95205Sopenharmony_ci * @brief Set boneable mode of bluetooth BR/EDR physical transport. 8019e95205Sopenharmony_ci * @param[in] bondableMode boneable mode 8119e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 8219e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 8319e95205Sopenharmony_ci * @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C 8419e95205Sopenharmony_ci * 4.3 BONDABLE MODES 8519e95205Sopenharmony_ci */ 8619e95205Sopenharmony_ciint GAP_SetBondableMode(uint8_t bondableMode); 8719e95205Sopenharmony_ci 8819e95205Sopenharmony_ci/** 8919e95205Sopenharmony_ci * @brief Service register security requirements to GAP 9019e95205Sopenharmony_ci * @param[in] addr outgoing attributes to remote device 9119e95205Sopenharmony_ci * @param[in] serviceInfo security requirements information 9219e95205Sopenharmony_ci * @param[in] securityMode Security attributes 9319e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 9419e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 9519e95205Sopenharmony_ci */ 9619e95205Sopenharmony_ciint GAP_RegisterServiceSecurity(const BtAddr *addr, const GapServiceSecurityInfo *serviceInfo, uint16_t securityMode); 9719e95205Sopenharmony_ci 9819e95205Sopenharmony_ci/** 9919e95205Sopenharmony_ci * @brief Service deregister security requirements to GAP 10019e95205Sopenharmony_ci * @param[in] addr outgoing attributes to remote device 10119e95205Sopenharmony_ci * @param[in] serviceInfo security requirements information 10219e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 10319e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 10419e95205Sopenharmony_ci */ 10519e95205Sopenharmony_ciint GAP_DeregisterServiceSecurity(const BtAddr *addr, const GapServiceSecurityInfo *serviceInfo); 10619e95205Sopenharmony_ci 10719e95205Sopenharmony_ci/** 10819e95205Sopenharmony_ci * @brief Service request security requirements to GAP 10919e95205Sopenharmony_ci * @param[in] addr target device address 11019e95205Sopenharmony_ci * @param[in] param structure of security requirements information and result callback function 11119e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 11219e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 11319e95205Sopenharmony_ci */ 11419e95205Sopenharmony_ciint GAP_RequestSecurity(const BtAddr *addr, const GapRequestSecurityParam *param); 11519e95205Sopenharmony_ci 11619e95205Sopenharmony_ci/** 11719e95205Sopenharmony_ci * @brief Register service security verify callback 11819e95205Sopenharmony_ci * @param[in] callback security verify callback 11919e95205Sopenharmony_ci * @param[in] context security verify callback context parameter 12019e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 12119e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 12219e95205Sopenharmony_ci */ 12319e95205Sopenharmony_ciint GAP_RegisterSecurityCallback(const GapSecurityCallback *callback, void *context); 12419e95205Sopenharmony_ci 12519e95205Sopenharmony_ci/** 12619e95205Sopenharmony_ci * @brief Deregister service security verify callback 12719e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 12819e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 12919e95205Sopenharmony_ci */ 13019e95205Sopenharmony_ciint GAP_DeregisterSecurityCallback(void); 13119e95205Sopenharmony_ci 13219e95205Sopenharmony_ci/** 13319e95205Sopenharmony_ci * @brief Set security modes of BR/EDR physical transport 13419e95205Sopenharmony_ci * @param[in] mode security modes 13519e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 13619e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 13719e95205Sopenharmony_ci */ 13819e95205Sopenharmony_ciint GAP_SetSecurityMode(GAP_SecurityMode mode); 13919e95205Sopenharmony_ci 14019e95205Sopenharmony_ci/** 14119e95205Sopenharmony_ci * @brief Service authorization verify response 14219e95205Sopenharmony_ci * @param[in] addr target device address 14319e95205Sopenharmony_ci * @param[in] service service identity 14419e95205Sopenharmony_ci * @param[in] accept accept or reject 14519e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 14619e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 14719e95205Sopenharmony_ci */ 14819e95205Sopenharmony_ciint GAP_AuthorizeRes(const BtAddr *addr, GAP_Service service, uint8_t accept); 14919e95205Sopenharmony_ci 15019e95205Sopenharmony_ci/** 15119e95205Sopenharmony_ci * @brief Register authentication callback 15219e95205Sopenharmony_ci * @param[in] callback authentication callback structure 15319e95205Sopenharmony_ci * @param[in] context authentication verify callback context parameter 15419e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 15519e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 15619e95205Sopenharmony_ci */ 15719e95205Sopenharmony_ciint GAP_RegisterAuthenticationCallback(const GapAuthenticationCallback *callback, void *context); 15819e95205Sopenharmony_ci 15919e95205Sopenharmony_ci/** 16019e95205Sopenharmony_ci * @brief Deregister authentication callback 16119e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 16219e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 16319e95205Sopenharmony_ci */ 16419e95205Sopenharmony_ciint GAP_DeregisterAuthenticationCallback(void); 16519e95205Sopenharmony_ci 16619e95205Sopenharmony_ci/** 16719e95205Sopenharmony_ci * @brief Get current pair originator 16819e95205Sopenharmony_ci * @param[in] addr pairing device address 16919e95205Sopenharmony_ci * @param[out] isLocal is local initiate 17019e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 17119e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 17219e95205Sopenharmony_ci */ 17319e95205Sopenharmony_ciint GAP_PairIsFromLocal(const BtAddr *addr, bool *isLocal); 17419e95205Sopenharmony_ci 17519e95205Sopenharmony_ci/** 17619e95205Sopenharmony_ci * @brief authenticate the remote device associated. 17719e95205Sopenharmony_ci * @param[in] addr target device address 17819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 17919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 18019e95205Sopenharmony_ci */ 18119e95205Sopenharmony_ciint GAP_AuthenticationReq(const BtAddr *addr); 18219e95205Sopenharmony_ci 18319e95205Sopenharmony_ci/** 18419e95205Sopenharmony_ci * @brief cancel authenticate the remote device associated. 18519e95205Sopenharmony_ci * @param[in] addr target device address 18619e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 18719e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 18819e95205Sopenharmony_ci */ 18919e95205Sopenharmony_ciint GAP_CancelAuthenticationReq(const BtAddr *addr); 19019e95205Sopenharmony_ci 19119e95205Sopenharmony_ci/** 19219e95205Sopenharmony_ci * @brief Respond IO capability request. Reply callback GapAuthenticationCallback::IOCapabilityReq 19319e95205Sopenharmony_ci * @param[in] addr target device address 19419e95205Sopenharmony_ci * @param[in] accept accept or reject 19519e95205Sopenharmony_ci * @param[in] ioCapability local device IO capability 19619e95205Sopenharmony_ci * @param[in] oobDataPresent OOB authentication data from remote device present 19719e95205Sopenharmony_ci * @param[in] authReq Authentication Requirements: MITM protection 19819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 19919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 20019e95205Sopenharmony_ci */ 20119e95205Sopenharmony_ciint GAP_IOCapabilityRsp( 20219e95205Sopenharmony_ci const BtAddr *addr, uint8_t accept, uint8_t ioCapability, uint8_t oobDataPresent, uint8_t authReq); 20319e95205Sopenharmony_ci 20419e95205Sopenharmony_ci/** 20519e95205Sopenharmony_ci * @brief Respond user confirmation request. Reply callback GapAuthenticationCallback::userConfirmReq 20619e95205Sopenharmony_ci * @param[in] addr target device address 20719e95205Sopenharmony_ci * @param[in] accept accept or reject 20819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 20919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 21019e95205Sopenharmony_ci */ 21119e95205Sopenharmony_ciint GAP_UserConfirmRsp(const BtAddr *addr, uint8_t accept); 21219e95205Sopenharmony_ci 21319e95205Sopenharmony_ci/** 21419e95205Sopenharmony_ci * @brief Respond user passkey request. Reply callback GapAuthenticationCallback::userPasskeyReq 21519e95205Sopenharmony_ci * @param[in] addr target device address 21619e95205Sopenharmony_ci * @param[in] accept accept or reject 21719e95205Sopenharmony_ci * @param[in] number user input number (000000 - 999999) 21819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 21919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 22019e95205Sopenharmony_ci */ 22119e95205Sopenharmony_ciint GAP_UserPasskeyRsp(const BtAddr *addr, uint8_t accept, uint32_t number); 22219e95205Sopenharmony_ci 22319e95205Sopenharmony_ci/** 22419e95205Sopenharmony_ci * @brief Respond remote OOB data request. Reply callback GapAuthenticationCallback::remoteOobReq 22519e95205Sopenharmony_ci * @param[in] addr target device address 22619e95205Sopenharmony_ci * @param[in] accept accept or reject 22719e95205Sopenharmony_ci * @param[in] data OOB data 22819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 22919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 23019e95205Sopenharmony_ci */ 23119e95205Sopenharmony_ciint GAP_RemoteOobRsp(const BtAddr *addr, uint8_t accept, const GapOOBData *data); 23219e95205Sopenharmony_ci 23319e95205Sopenharmony_ci/** 23419e95205Sopenharmony_ci * @brief Respond PIN code request. Reply callback GapAuthenticationCallback::pinCodeReq 23519e95205Sopenharmony_ci * @param[in] addr target device address 23619e95205Sopenharmony_ci * @param[in] accept accept or reject 23719e95205Sopenharmony_ci * @param[in] pinCode PIN code data 23819e95205Sopenharmony_ci * @param[in] pinCodeLength PIN code data length 23919e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 24019e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 24119e95205Sopenharmony_ci */ 24219e95205Sopenharmony_ciint GAP_PinCodeRsp(const BtAddr *addr, uint8_t accept, const uint8_t *pinCode, uint8_t pinCodeLength); 24319e95205Sopenharmony_ci 24419e95205Sopenharmony_ci/** 24519e95205Sopenharmony_ci * @brief Respond link key request. Reply callback GapAuthenticationCallback::linkKeyReq 24619e95205Sopenharmony_ci * @param[in] addr target device address 24719e95205Sopenharmony_ci * @param[in] accept accept or reject 24819e95205Sopenharmony_ci * @param[in] linkKey link key 24919e95205Sopenharmony_ci * @param[in] keyType link key type 25019e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 25119e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 25219e95205Sopenharmony_ci */ 25319e95205Sopenharmony_ciint GAP_LinkKeyRsp(const BtAddr *addr, uint8_t accept, const uint8_t linkKey[GAP_LINKKEY_SIZE], uint8_t keyType); 25419e95205Sopenharmony_ci 25519e95205Sopenharmony_ci/** 25619e95205Sopenharmony_ci * @brief Get local OOB data to paired. 25719e95205Sopenharmony_ci * @param[out] oobData192 25819e95205Sopenharmony_ci * @param[out] oobData256 25919e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 26019e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 26119e95205Sopenharmony_ci */ 26219e95205Sopenharmony_ciint GAP_GetLocalExtendedOOBData(GapOOBData *oobData192, GapOOBData *oobData256); 26319e95205Sopenharmony_ci 26419e95205Sopenharmony_ci/** 26519e95205Sopenharmony_ci * @brief Register device discover callback 26619e95205Sopenharmony_ci * @param[in] callback device discover callback structure 26719e95205Sopenharmony_ci * @param[in] context device discover callback context parameter 26819e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 26919e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 27019e95205Sopenharmony_ci */ 27119e95205Sopenharmony_ciint GAP_RegisterDiscoveryCallback(const GapDiscoveryCallback *callback, void *context); 27219e95205Sopenharmony_ci 27319e95205Sopenharmony_ci/** 27419e95205Sopenharmony_ci * @brief Deregister device discover callback 27519e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 27619e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 27719e95205Sopenharmony_ci */ 27819e95205Sopenharmony_ciint GAP_DeregisterDiscoveryCallback(void); 27919e95205Sopenharmony_ci 28019e95205Sopenharmony_ci/** 28119e95205Sopenharmony_ci * @brief discover other nearby BR/EDR Controllers 28219e95205Sopenharmony_ci * @param[in] mode Inquiry mode 28319e95205Sopenharmony_ci * @param[in] inquiryLength Maximum inquiry time.(n * 1.28s) 28419e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 28519e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 28619e95205Sopenharmony_ci */ 28719e95205Sopenharmony_ciint GAP_Inquiry(uint8_t mode, uint8_t inquiryLength); 28819e95205Sopenharmony_ci 28919e95205Sopenharmony_ci/** 29019e95205Sopenharmony_ci * @brief Cancel discover other nearby BR/EDR Controllers 29119e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 29219e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 29319e95205Sopenharmony_ci */ 29419e95205Sopenharmony_ciint GAP_InquiryCancel(void); 29519e95205Sopenharmony_ci 29619e95205Sopenharmony_ci/** 29719e95205Sopenharmony_ci * @brief Get remote device name 29819e95205Sopenharmony_ci * @param[in] addr target device address 29919e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 30019e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 30119e95205Sopenharmony_ci */ 30219e95205Sopenharmony_ciint GAP_GetRemoteName(const BtAddr *addr); 30319e95205Sopenharmony_ci 30419e95205Sopenharmony_ci/** 30519e95205Sopenharmony_ci * @brief Cancel get remote device name 30619e95205Sopenharmony_ci * @param[in] addr target device address 30719e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 30819e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 30919e95205Sopenharmony_ci */ 31019e95205Sopenharmony_ciint GAP_GetRemoteNameCancel(const BtAddr *addr); 31119e95205Sopenharmony_ci 31219e95205Sopenharmony_ci/** 31319e95205Sopenharmony_ci * @brief Set configuration of retry pairing when remote device delete linkkey. 31419e95205Sopenharmony_ci * @param[in] retry do retry 31519e95205Sopenharmony_ci * @return @c BT_SUCCESS : The function is executed successfully. 31619e95205Sopenharmony_ci * @c otherwise : The function is not executed successfully. 31719e95205Sopenharmony_ci */ 31819e95205Sopenharmony_ciint GAP_SetKeyMissingRetry(bool retry); 31919e95205Sopenharmony_ci#ifdef __cplusplus 32019e95205Sopenharmony_ci} 32119e95205Sopenharmony_ci#endif 32219e95205Sopenharmony_ci 32319e95205Sopenharmony_ci#endif /* GAP_H */ 324