TI BLE5-Stack API Documentation  2.02.09.00
gapbondmgr.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: BSD3 2010 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
21 #ifndef GAPBONDMGR_H
22 #define GAPBONDMGR_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 /*-------------------------------------------------------------------
30  * INCLUDES
31  */
32 #include "gap.h"
33 
34 /*-------------------------------------------------------------------
35  * CONSTANTS
36  */
37 
43 // This is a common file for the legacy and sysconfig examples,
44 // the parameters under ifndef SYSCFG are defined in this file for
45 // the legacy examples and generated using the sysconfig tool for
46 // the sysconfig examples
47 #ifndef SYSCFG
48 #if !defined ( GAP_BONDINGS_MAX )
49 #define GAP_BONDINGS_MAX 10
51 #endif
52 
53 #if !defined ( GAP_CHAR_CFG_MAX )
54 #define GAP_CHAR_CFG_MAX 4
56 #endif
57 #endif //SYSCFG
58 
78 #define GAPBOND_PAIRING_MODE 0x400
79 
89 #define GAPBOND_MITM_PROTECTION 0x402
90 
100 #define GAPBOND_IO_CAPABILITIES 0x403
101 
111 #define GAPBOND_OOB_ENABLED 0x404
112 
123 #define GAPBOND_OOB_DATA 0x405
124 
134 #define GAPBOND_BONDING_ENABLED 0x406
135 
148 #define GAPBOND_KEY_DIST_LIST 0x407
149 
155 #define GAPBOND_ERASE_ALLBONDS 0x409
156 
158 #define GAPBOND_AUTO_FAIL_PAIRING 0x40A
159 #define GAPBOND_AUTO_FAIL_REASON 0x40B
160 
171 #define GAPBOND_KEYSIZE 0x40C
172 
186 #define GAPBOND_AUTO_SYNC_WL 0x40D
187 
195 #define GAPBOND_BOND_COUNT 0x40E
196 
207 #define GAPBOND_BOND_FAIL_ACTION 0x40F
208 
221 #define GAPBOND_ERASE_SINGLEBOND 0x410
222 
236 #define GAPBOND_SECURE_CONNECTION 0x411
237 
256 #define GAPBOND_ECCKEY_REGEN_POLICY 0x412
257 
279 #define GAPBOND_ECC_KEYS 0x413
280 
290 #define GAPBOND_SC_HOST_DEBUG 0x414
291 
308 #define GAPBOND_ERASE_BOND_IN_CONN 0x415
309 
327 #define GAPBOND_ALLOW_DEBUG_KEYS 0x416
328 
342 #define GAPBOND_LRU_BOND_REPLACEMENT 0x418
343 
352 #define GAPBOND_ERASE_LOCAL_INFO 0x41A
353 
363 #define GAPBOND_AUTHEN_PAIRING_ONLY 0x41B
364 
375 #define GAPBOND_SAME_IRK_OPTION 0x41C
376 
388 #define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00
390 #define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01
392 #define GAPBOND_PAIRING_MODE_INITIATE 0x02
394 
400 #define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00
402 #define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01
404 #define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02
406 #define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03
408 #define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04
410 
416 #define GAPBOND_KEYDIST_SENCKEY 0x01
418 #define GAPBOND_KEYDIST_SIDKEY 0x02
420 #define GAPBOND_KEYDIST_SSIGN 0x04
422 #define GAPBOND_KEYDIST_SLINK 0x08
424 #define GAPBOND_KEYDIST_MENCKEY 0x10
426 #define GAPBOND_KEYDIST_MIDKEY 0x20
428 #define GAPBOND_KEYDIST_MSIGN 0x40
430 #define GAPBOND_KEYDIST_MLINK 0x80
432 
438 #define GAPBOND_SAME_IRK_UPDATE_BOND_REC 0x00
440 #define GAPBOND_SAME_IRK_TERMINATE_LINK 0x01
442 
478 #define GAP_BOND_REC_ID_OFFSET 0
479 #define GAP_BOND_LOCAL_LTK_OFFSET 1
480 #define GAP_BOND_DEV_LTK_OFFSET 2
481 #define GAP_BOND_DEV_IRK_OFFSET 3
482 #define GAP_BOND_DEV_CSRK_OFFSET 4
483 #define GAP_BOND_DEV_SIGN_COUNTER_OFFSET 5
484 #define GAP_BOND_REC_IDS 6
485 
486 // Bonded State Flags
487 #define GAP_BONDED_STATE_AUTHENTICATED 0x01
488 #define GAP_BONDED_STATE_SERVICE_CHANGED 0x02
489 #define GAP_BONDED_STATE_CAR 0x04
490 #define GAP_BONDED_STATE_SECURECONNECTION 0x08
491 #define GAP_BONDED_STATE_RPA_ONLY 0x10
492 
510 #define GAPBOND_PAIRING_STATE_STARTED 0x00
511 
531 #define GAPBOND_PAIRING_STATE_COMPLETE 0x01
532 
550 #define GAPBOND_PAIRING_STATE_ENCRYPTED 0x02
551 #define GAPBOND_PAIRING_STATE_BOND_SAVED 0x03
553 #define GAPBOND_PAIRING_STATE_CAR_READ 0x04
555 #define GAPBOND_PAIRING_STATE_RPAO_READ 0x05
557 #define GAPBOND_GENERATE_ECC_DONE 0x06
559 
574 #define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01
575 #define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02
577 
581 #define SMP_PAIRING_FAILED_AUTH_REQ 0x03
582 #define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04
584 #define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05
586 
590 #define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06
591 #define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07
593 #define SMP_PAIRING_FAILED_UNSPECIFIED 0x08
595 
599 #define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09
600 
604 #define SMP_PAIRING_FAILED_INVALID_PARAMETERS 0x0A
605 
609 #define SMP_PAIRING_FAILED_DHKEY_CHECK_FAILED 0x0B
610 
614 #define SMP_PAIRING_FAILED_NUM_COMPARISON_FAILED 0x0C
615 
621 #define GAPBOND_FAIL_NO_ACTION 0x00
623 #define GAPBOND_FAIL_INITIATE_PAIRING 0x01
625 #define GAPBOND_FAIL_TERMINATE_LINK 0x02
627 
631 #define GAPBOND_FAIL_TERMINATE_ERASE_BONDS 0x03
632 
636 #define GAPBOND_FAIL_TERMINATE_ERASE_SINGLE_BOND 0x04
637 
643 #define GAPBOND_SECURE_CONNECTION_NONE 0x00
645 #define GAPBOND_SECURE_CONNECTION_ALLOW 0x01
647 #define GAPBOND_SECURE_CONNECTION_ONLY 0x02
649 
659 #define GAPBOND_REGENERATE_ALWAYS 0x00
661 #define GAPBOND_REGENERATE_NEVER 0xFF
663 
665 #define ECC_KEYLEN 32
667 
670 /*-------------------------------------------------------------------
671  * TYPEDEFS
672  */
673 
697 typedef void (*pfnPasscodeCB_t)
698 (
699  uint8_t *deviceAddr,
700  uint16_t connectionHandle,
701  uint8_t uiInputs,
702  uint8_t uiOutputs,
703  uint32_t numComparison
704 );
705 
717 typedef void (*pfnPairStateCB_t)
718 (
719  uint16_t connectionHandle,
720  uint8_t state,
721  uint8_t status
722 );
723 
730 typedef struct
731 {
734 } gapBondCBs_t;
735 
743 typedef struct
745 {
746  uint8_t privateKey[ECC_KEYLEN];
747  uint8_t publicKeyX[ECC_KEYLEN];
748  uint8_t publicKeyY[ECC_KEYLEN];
750 
751 //structure of OOB data
752 typedef struct gapBondOOBData
753 {
754  uint8 confirm[KEYLEN]; //calculated/received confirm value
755  uint8 rand[KEYLEN]; //calculated/received random number
756 } gapBondOOBData_t;
757 
759 typedef struct
760 {
761  uint8_t LTK[KEYLEN]; // Long Term Key (LTK)
762  uint16_t div; //lint -e754 // LTK eDiv
763  uint8_t rand[B_RANDOM_NUM_SIZE]; // LTK random number
764  uint8_t keySize; // LTK key size
765 } gapBondLTK_t;
766 
768 typedef struct
769 {
776  uint8_t addr[B_ADDR_LEN];
786  uint8_t stateFlags;
787 } gapBondRec_t;
788 
790 typedef struct
791 {
792  uint16_t attrHandle; // attribute handle
793  uint8_t value; // attribute value for this device
795 
797 typedef struct
798 {
799  uint8_t pairMode;
800  uint8_t mitm;
801  uint8_t ioCap;
802  uint8_t bonding;
803  uint8_t secureConnection;
804  uint8_t authenPairingOnly;
805  uint8_t autoSyncWL;
806  uint8_t eccReGenPolicy;
807  uint8_t KeySize;
808  uint8_t removeLRUBond;
809  uint8_t KeyDistList;
810  uint8_t eccDebugKeys;
811  uint8_t eraseBondWhileInConn;
812  uint8_t bondFailAction;
813  uint8_t sameIrkAction;
815 
817 /*-------------------------------------------------------------------
818  * API's
819  */
820 
826 extern void GAPBondMgr_Register(gapBondCBs_t *pCB);
827 
844 extern bStatus_t GAPBondMgr_SetParameter(uint16_t param, uint8_t len,
845  void *pValue);
846 
861 extern bStatus_t GAPBondMgr_GetParameter(uint16_t param, void *pValue);
862 
881 extern bStatus_t GAPBondMgr_Pair(uint16_t connHandle);
882 
911 extern bStatus_t GAPBondMgr_FindAddr(uint8_t *pDevAddr,
912  GAP_Peer_Addr_Types_t addrType,
913  uint8_t *pIdx,
914  GAP_Peer_Addr_Types_t *pIdentityAddrType,
915  uint8_t *pIdentityAddr);
916 
929 extern bStatus_t GAPBondMgr_ServiceChangeInd(uint16_t connectionHandle,
930  uint8_t setParam);
931 
946 extern bStatus_t GAPBondMgr_PasscodeRsp(uint16_t connectionHandle,
947  uint8_t status, uint32_t passcode);
948 
959 extern bStatus_t GAPBondMgr_SCGetLocalOOBParameters(gapBondOOBData_t *localOobData);
960 
973 extern bStatus_t GAPBondMgr_SCSetRemoteOOBParameters(gapBondOOBData_t *remoteOobData,
974  uint8 OOBDataFlag);
975 
985 
1002 extern uint8_t gapBondMgrReadBondRec(GAP_Peer_Addr_Types_t addrType,
1003  uint8_t *pDevAddr,
1004  gapBondRec_t *pBondRec,
1005  gapBondLTK_t *pLocalLtk,
1006  gapBondLTK_t *pDevLtk,
1007  uint8_t *pIRK,
1008  uint8_t *pSRK,
1009  uint32_t *signCount,
1010  gapBondCharCfg_t *charCfg);
1011 
1026 extern uint8_t gapBondMgrImportBond(gapBondRec_t *pBondRec,
1027  gapBondLTK_t *pLocalLtk,
1028  gapBondLTK_t *pDevLtk,
1029  uint8_t *pIRK,
1030  uint8_t *pSRK,
1031  uint32_t signCount,
1032  gapBondCharCfg_t *charCfg);
1033 
1050 extern uint8_t GapBondMgr_GetPrevAuth(uint16_t connHandle, uint8_t *pMitmReq, uint8_t *pKeySize);
1051 
1066 extern uint8_t GapBondMgr_StartEnc(uint16_t connHandle);
1067 
1068 /*-------------------------------------------------------------------
1069 -------------------------------------------------------------------*/
1070 #ifdef __cplusplus
1071 }
1072 #endif
1073 
1074 #endif /* GAPBONDMGR_H */
1075 
GAP_Peer_Addr_Types_t
Address types used for specifying peer address type.
Definition: gap.h:727
Public and Private ECC Keys.
Definition: gapbondmgr.h:744
bStatus_t GAPBondMgr_Pair(uint16_t connHandle)
#define B_RANDOM_NUM_SIZE
BLE Random Number Size.
Definition: bcomdef.h:127
Structure of NV data for the connected device's encryption information.
Definition: gapbondmgr.h:759
bStatus_t GAPBondMgr_GenerateEccKeys(void)
Generates ECC keys.
bStatus_t GAPBondMgr_GetParameter(uint16_t param, void *pValue)
bStatus_t GAPBondMgr_PasscodeRsp(uint16_t connectionHandle, uint8_t status, uint32_t passcode)
void(* pfnPairStateCB_t)(uint16_t connectionHandle, uint8_t state, uint8_t status)
Definition: gapbondmgr.h:718
bStatus_t GAPBondMgr_SCGetLocalOOBParameters(gapBondOOBData_t *localOobData)
Get local Random number and confirm value for secure connection.
Structure of NV data for the connected device's address information.
Definition: gapbondmgr.h:768
pfnPasscodeCB_t passcodeCB
Passcode callback.
Definition: gapbondmgr.h:732
bStatus_t GAPBondMgr_FindAddr(uint8_t *pDevAddr, GAP_Peer_Addr_Types_t addrType, uint8_t *pIdx, GAP_Peer_Addr_Types_t *pIdentityAddrType, uint8_t *pIdentityAddr)
Search for an address in the bonding table. If the address is a random private resolvable address...
void GAPBondMgr_Register(gapBondCBs_t *pCB)
Definition: gapbondmgr.h:730
uint8_t gapBondMgrReadBondRec(GAP_Peer_Addr_Types_t addrType, uint8_t *pDevAddr, gapBondRec_t *pBondRec, gapBondLTK_t *pLocalLtk, gapBondLTK_t *pDevLtk, uint8_t *pIRK, uint8_t *pSRK, uint32_t *signCount, gapBondCharCfg_t *charCfg)
Read bond record from NV.
void(* pfnPasscodeCB_t)(uint8_t *deviceAddr, uint16_t connectionHandle, uint8_t uiInputs, uint8_t uiOutputs, uint32_t numComparison)
Definition: gapbondmgr.h:698
uint8_t gapBondMgrImportBond(gapBondRec_t *pBondRec, gapBondLTK_t *pLocalLtk, gapBondLTK_t *pDevLtk, uint8_t *pIRK, uint8_t *pSRK, uint32_t signCount, gapBondCharCfg_t *charCfg)
Import bond record to NV.
Contains part of the GAP Bond Manager Parameters values.
Definition: gapbondmgr.h:797
uint8_t stateFlags
Definition: gapbondmgr.h:786
GAP layer interface.
bStatus_t GAPBondMgr_ServiceChangeInd(uint16_t connectionHandle, uint8_t setParam)
GAP_Peer_Addr_Types_t addrType
Definition: gapbondmgr.h:780
#define B_ADDR_LEN
Default Public and Random Address Length.
Definition: bcomdef.h:102
bStatus_t GAPBondMgr_SetParameter(uint16_t param, uint8_t len, void *pValue)
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:245
#define ECC_KEYLEN
ECC Key Length: 256 bit keys.
Definition: gapbondmgr.h:666
bStatus_t GAPBondMgr_SCSetRemoteOOBParameters(gapBondOOBData_t *remoteOobData, uint8 OOBDataFlag)
Set remote's OOB parameters for secure connection.
#define KEYLEN
Default key length.
Definition: bcomdef.h:105
pfnPairStateCB_t pairStateCB
Pairing state callback.
Definition: gapbondmgr.h:733
Structure of NV data for the connected device's characteristic configuration.
Definition: gapbondmgr.h:790
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale