TI BLE Stack API Documentation  2.03.06
gapbondmgr.h
1 /******************************************************************************
2 
3  @file gapbondmgr.h
4 
5  @brief TI BLE GAP Bond Manager
6 
7  This GAP profile manages bonded connections between devices.<BR><BR>
8 
9  When operating as a slave, this profile will automatically respond to
10  SM Pairing Requests from a connected master device. When operating as
11  a master, this profile will automatically respond to SM Slave
12  Security Requests from a connected slave device.
13 
14  After pairing, if keys were exchanged and bonding was specified, this
15  profile will save the device and key information of the connected
16  device, so that, on future connections, the bonded devices can
17  establish an encrypted link without pairing.<BR><BR>
18 
19  This GAP Bond Manager will handle all of the pairing and bonding actions
20  automatically and can be controlled by setting control parameters:<BR>
21  * GAPBondMgr_SetParameter()<BR>
22  * GAPBondMgr_GetParameter()<BR><BR>
23 
24  Reference: @ref GAPBOND_PROFILE_PARAMETERS <BR><BR>
25 
26  Group: WCS, BTS
27  $Target Device: DEVICES $
28 
29  ******************************************************************************
30  $License: BSD3 2010 $
31  ******************************************************************************
32  $Release Name: PACKAGE NAME $
33  $Release Date: PACKAGE RELEASE DATE $
34  *****************************************************************************/
35 
36 #ifndef GAPBONDMGR_H
37 #define GAPBONDMGR_H
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
44 /*-------------------------------------------------------------------
45  * INCLUDES
46  */
47 #include "gap.h"
48 
49 /*-------------------------------------------------------------------
50  * CONSTANTS
51  */
52 
53 #if !defined ( GAP_BONDINGS_MAX )
54  #define GAP_BONDINGS_MAX 10
55 #endif
56 
57 #if !defined ( GAP_CHAR_CFG_MAX )
58  #define GAP_CHAR_CFG_MAX 4
59 #endif
60 
69 #define GAPBOND_PAIRING_MODE 0x400
70 #define GAPBOND_INITIATE_WAIT 0x401
71 #define GAPBOND_MITM_PROTECTION 0x402
72 #define GAPBOND_IO_CAPABILITIES 0x403
73 #define GAPBOND_OOB_ENABLED 0x404
74 #define GAPBOND_OOB_DATA 0x405
75 #define GAPBOND_BONDING_ENABLED 0x406
76 #define GAPBOND_KEY_DIST_LIST 0x407
77 #define GAPBOND_DEFAULT_PASSCODE 0x408
78 #define GAPBOND_ERASE_ALLBONDS 0x409
79 #define GAPBOND_AUTO_FAIL_PAIRING 0x40A
80 #define GAPBOND_AUTO_FAIL_REASON 0x40B
81 #define GAPBOND_KEYSIZE 0x40C
82 #define GAPBOND_AUTO_SYNC_WL 0x40D
83 #define GAPBOND_BOND_COUNT 0x40E
84 #define GAPBOND_BOND_FAIL_ACTION 0x40F
85 #define GAPBOND_ERASE_SINGLEBOND 0x410
86 #define GAPBOND_SECURE_CONNECTION 0x411
87 #define GAPBOND_ECCKEY_REGEN_POLICY 0x412
88 #define GAPBOND_ECC_KEYS 0x413
89 #define GAPBOND_REMOTE_OOB_SC_ENABLED 0x414
90 #define GAPBOND_REMOTE_OOB_SC_DATA 0x415
91 #define GAPBOND_LOCAL_OOB_SC_ENABLED 0x416
92 #define GAPBOND_LOCAL_OOB_SC_DATA 0x417
93 #define GAPBOND_LRU_BOND_REPLACEMENT 0x418
94 
99 #define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00
100 #define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01
101 #define GAPBOND_PAIRING_MODE_INITIATE 0x02
102 
107 #define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00
108 #define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01
109 #define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02
110 #define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03
111 #define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04
112 
117 #define GAPBOND_KEYDIST_SENCKEY 0x01
118 #define GAPBOND_KEYDIST_SIDKEY 0x02
119 #define GAPBOND_KEYDIST_SSIGN 0x04
120 #define GAPBOND_KEYDIST_SLINK 0x08
121 #define GAPBOND_KEYDIST_MENCKEY 0x10
122 #define GAPBOND_KEYDIST_MIDKEY 0x20
123 #define GAPBOND_KEYDIST_MSIGN 0x40
124 #define GAPBOND_KEYDIST_MLINK 0x80
125 
131 #define GAPBOND_PAIRING_STATE_STARTED 0x00
132 #define GAPBOND_PAIRING_STATE_COMPLETE 0x01
133 #define GAPBOND_PAIRING_STATE_BONDED 0x02
134 #define GAPBOND_PAIRING_STATE_BOND_SAVED 0x03
135 #define GAPBOND_PAIRING_STATE_CAR_READ 0x04
136 
141 #define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01
142 #define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02
143 #define SMP_PAIRING_FAILED_AUTH_REQ 0x03
144 #define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04
145 #define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05
146 #define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06
147 #define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07
148 #define SMP_PAIRING_FAILED_UNSPECIFIED 0x08
149 #define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09
150 #define SMP_PAIRING_FAILED_INVALID_PARAMETERS 0x0A
151 #define SMP_PAIRING_FAILED_DHKEY_CHECK_FAILED 0x0B
152 #define SMP_PAIRING_FAILED_NUM_COMPARISON_FAILED 0x0C
153 
158 #define GAPBOND_FAIL_NO_ACTION 0x00
159 #define GAPBOND_FAIL_INITIATE_PAIRING 0x01
160 #define GAPBOND_FAIL_TERMINATE_LINK 0x02
161 #define GAPBOND_FAIL_TERMINATE_ERASE_BONDS 0x03
162 
167 #define GAPBOND_SECURE_CONNECTION_NONE 0x00
168 #define GAPBOND_SECURE_CONNECTION_ALLOW 0x01
169 #define GAPBOND_SECURE_CONNECTION_ONLY 0x02
170 
175 #define GAPBOND_REGENERATE_ALWAYS 0x00
177 #define GAPBOND_REGENERATE_NEVER 0xFF
178 
180 // ECC Key Length
181 #define ECC_KEYLEN 32
182 
183 /*-------------------------------------------------------------------
184  * TYPEDEFS
185  */
186 
190 typedef void (*pfnPasscodeCB_t)
191 (
192  uint8 *deviceAddr,
193  uint16 connectionHandle,
194  uint8 uiInputs,
195  uint8 uiOutputs,
196  uint32 numComparison
197  );
198 
202 typedef void (*pfnPairStateCB_t)
203 (
204  uint16 connectionHandle,
205  uint8 state,
206  uint8 status
207 );
208 
212 typedef struct
213 {
214  pfnPasscodeCB_t passcodeCB;
215  pfnPairStateCB_t pairStateCB;
216 } gapBondCBs_t;
217 
218 typedef struct
219 {
220  uint8 privateKey[ECC_KEYLEN];
221  uint8 publicKeyX[ECC_KEYLEN];
222  uint8 publicKeyY[ECC_KEYLEN];
224 
225 typedef struct
226 {
227  uint8 addr[B_ADDR_LEN];
228  uint8 confirm[KEYLEN];
229  uint8 oob[KEYLEN];
231 
232 /*-------------------------------------------------------------------
233  * MACROS
234  */
235 
236 /*-------------------------------------------------------------------
237  * API FUNCTIONS
238  */
239 
263 extern bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue );
264 
280 extern bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue );
281 
295 extern bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role );
296 
307 extern void GAPBondMgr_LinkTerm(uint16 connHandle);
308 
309 /*********************************************************************
310  * @brief Notify the Bond Manager that a Slave Security Request is received.
311  *
312  * NOTE: The GAP Central Role profile will call this function,
313  * if it is included in the project.
314  *
315  * @param connHandle - connection handle
316  * @param authReq - slave device's authentication requirements
317  *
318  * @return none
319  */
320 extern void GAPBondMgr_SlaveReqSecurity(uint16 connHandle, uint8 authReq);
321 
332 extern uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr );
333 
345 extern bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam );
346 
359 extern bStatus_t GAPBondMgr_UpdateCharCfg( uint16 connectionHandle, uint16 attrHandle, uint16 value );
360 
371 extern void GAPBondMgr_Register( gapBondCBs_t *pCB );
372 
384 extern bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode );
385 
402 extern bStatus_t GAPBondMgr_ReadCentAddrResChar( uint16 connectionHandle );
403 
414 extern uint8 GAPBondMgr_SupportsEnhancedPriv( uint8 *pPeerIdAddr );
415 
427 extern uint8 GAPBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg );
428 
437 extern uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len );
438 
448 
455 /*-------------------------------------------------------------------
456  * TASK FUNCTIONS - Don't call these. These are system functions.
457  */
458 
473 extern void GAPBondMgr_Init( uint8 task_id );
474 
489 extern uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events );
490 
491 /*-------------------------------------------------------------------
492 -------------------------------------------------------------------*/
493 
494 #ifdef __cplusplus
495 }
496 #endif
497 
498 #endif /* GAPBONDMGR_H */
pfnPasscodeCB_t passcodeCB
Passcode callback.
Definition: gapbondmgr.h:214
bStatus_t GAPBondMgr_PasscodeRsp(uint16 connectionHandle, uint8 status, uint32 passcode)
Respond to a passcode request.
bStatus_t GAPBondMgr_UpdateCharCfg(uint16 connectionHandle, uint16 attrHandle, uint16 value)
Update the Characteristic Configuration in a bond record.
bStatus_t GAPBondMgr_GetParameter(uint16 param, void *pValue)
Get a GAP Bond Manager parameter.
#define B_ADDR_LEN
Default Public and Random Address Length.
Definition: bcomdef.h:114
void GAPBondMgr_LinkTerm(uint16 connHandle)
Notify the Bond Manager that a connection has been terminated.
bStatus_t GAPBondMgr_ReadCentAddrResChar(uint16 connectionHandle)
Send Read By Type Request to get value attribute of Central Address Resolution characteristic. Value determines if peer supports Enhanced Privacy. Bond record will automatically be updated based on peer response.
Definition: gap.h:405
uint8 GAPBondMgr_ResolveAddr(uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr)
Resolve an address from bonding information.
bStatus_t GAPBondMgr_SetParameter(uint16 param, uint8 len, void *pValue)
Set a GAP Bond Manager parameter.
uint8 GAPBondMgr_ProcessGAPMsg(gapEventHdr_t *pMsg)
This is a bypass mechanism to allow the bond manager to process GAP messages.
Definition: gapbondmgr.h:225
bStatus_t GAPBondMgr_syncResolvingList(void)
This function will add all device address and IRK pairs from bond records to the Controller. Used with PRIVACY_1_2_CFG.
Status_t bStatus_t
BLE Generic Status return: BLE Default BLE Status Values.
Definition: bcomdef.h:244
#define KEYLEN
Default key length.
Definition: bcomdef.h:117
bStatus_t GAPBondMgr_ServiceChangeInd(uint16 connectionHandle, uint8 setParam)
Set/clear the service change indication in a bond record.
uint8 GAPBondMgr_CheckNVLen(uint8 id, uint8 len)
This function will check the length of a Bond Manager NV Item.
Definition: gapbondmgr.h:218
Definition: gapbondmgr.h:212
uint8 GAPBondMgr_SupportsEnhancedPriv(uint8 *pPeerIdAddr)
Determine if peer device supports enhanced privacy by checking the Enhanced Privacy state flag of the...
pfnPairStateCB_t pairStateCB
Pairing state callback.
Definition: gapbondmgr.h:215
bStatus_t GAPBondMgr_LinkEst(uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role)
Notify the Bond Manager that a connection has been made.
void GAPBondMgr_Register(gapBondCBs_t *pCB)
Register callback functions with the bond manager.