BLE-Stack APIs  3.00.00
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gapbondmgr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @defgroup GAPBondMgr GAPBondMgr
34  * @brief This module implements the GAP Bond Manager
35  * @{
36  * @file gapbondmgr.h
37  * @brief GAPBondMgr layer interface
38  */
39 
40 #ifndef GAPBONDMGR_H
41 #define GAPBONDMGR_H
42 
43 #ifdef __cplusplus
44 extern "C"
45 {
46 #endif
47 
48 /*-------------------------------------------------------------------
49  * INCLUDES
50  */
51 #include "gap.h"
52 
53 /*-------------------------------------------------------------------
54  * CONSTANTS
55  */
56 
60 #if !defined ( GAP_BONDINGS_MAX )
61  #define GAP_BONDINGS_MAX 10
62 #endif
63 
64 #if !defined ( GAP_CHAR_CFG_MAX )
65  #define GAP_CHAR_CFG_MAX 4
66 #endif
67 
82 #define GAPBOND_PAIRING_MODE 0x400
83 
94 #define GAPBOND_INITIATE_WAIT 0x401
95 
105 #define GAPBOND_MITM_PROTECTION 0x402
106 
116 #define GAPBOND_IO_CAPABILITIES 0x403
117 
127 #define GAPBOND_OOB_ENABLED 0x404
128 
138 #define GAPBOND_OOB_DATA 0x405
139 
149 #define GAPBOND_BONDING_ENABLED 0x406
150 
163 #define GAPBOND_KEY_DIST_LIST 0x407
164 
176 #define GAPBOND_DEFAULT_PASSCODE 0x408
177 
183 #define GAPBOND_ERASE_ALLBONDS 0x409
184 
186 #define GAPBOND_AUTO_FAIL_PAIRING 0x40A
187 #define GAPBOND_AUTO_FAIL_REASON 0x40B
188 
199 #define GAPBOND_KEYSIZE 0x40C
200 
213 #define GAPBOND_AUTO_SYNC_WL 0x40D
214 
222 #define GAPBOND_BOND_COUNT 0x40E
223 
233 #define GAPBOND_BOND_FAIL_ACTION 0x40F
234 
245 #define GAPBOND_ERASE_SINGLEBOND 0x410
246 
256 #define GAPBOND_SECURE_CONNECTION 0x411
257 
276 #define GAPBOND_ECCKEY_REGEN_POLICY 0x412
277 
295 #define GAPBOND_ECC_KEYS 0x413
296 
310 #define GAPBOND_REMOTE_OOB_SC_ENABLED 0x414
311 
327 #define GAPBOND_REMOTE_OOB_SC_DATA 0x415
328 
344 #define GAPBOND_LOCAL_OOB_SC_ENABLED 0x416
345 
358 #define GAPBOND_LOCAL_OOB_SC_DATA 0x417
359 
372 #define GAPBOND_LRU_BOND_REPLACEMENT 0x418
373 
379 #define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00
380 #define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01
381 #define GAPBOND_PAIRING_MODE_INITIATE 0x02
382 
387 #define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00
388 #define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01
389 #define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02
390 #define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03
391 #define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04
392 
397 #define GAPBOND_KEYDIST_SENCKEY 0x01
398 #define GAPBOND_KEYDIST_SIDKEY 0x02
399 #define GAPBOND_KEYDIST_SSIGN 0x04
400 #define GAPBOND_KEYDIST_SLINK 0x08
401 #define GAPBOND_KEYDIST_MENCKEY 0x10
402 #define GAPBOND_KEYDIST_MIDKEY 0x20
403 #define GAPBOND_KEYDIST_MSIGN 0x40
404 #define GAPBOND_KEYDIST_MLINK 0x80
405 
420 #define GAPBOND_PAIRING_STATE_STARTED 0x00
421 
441 #define GAPBOND_PAIRING_STATE_COMPLETE 0x01
442 
454 #define GAPBOND_PAIRING_STATE_BONDED 0x02
455 #define GAPBOND_PAIRING_STATE_BOND_SAVED 0x03
456 #define GAPBOND_PAIRING_STATE_CAR_READ 0x04
457 
462 #define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01
463 #define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02
464 #define SMP_PAIRING_FAILED_AUTH_REQ 0x03
465 #define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04
466 #define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05
467 #define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06
468 #define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07
469 #define SMP_PAIRING_FAILED_UNSPECIFIED 0x08
470 #define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09
471 #define SMP_PAIRING_FAILED_INVALID_PARAMETERS 0x0A
472 #define SMP_PAIRING_FAILED_DHKEY_CHECK_FAILED 0x0B
473 #define SMP_PAIRING_FAILED_NUM_COMPARISON_FAILED 0x0C
474 
479 #define GAPBOND_FAIL_NO_ACTION 0x00
480 #define GAPBOND_FAIL_INITIATE_PAIRING 0x01
481 #define GAPBOND_FAIL_TERMINATE_LINK 0x02
482 #define GAPBOND_FAIL_TERMINATE_ERASE_BONDS 0x03
483 
488 #define GAPBOND_SECURE_CONNECTION_NONE 0x00
489 #define GAPBOND_SECURE_CONNECTION_ALLOW 0x01
490 #define GAPBOND_SECURE_CONNECTION_ONLY 0x02
491 
497 #define GAPBOND_REGENERATE_ALWAYS 0x00
498 #define GAPBOND_REGENERATE_NEVER 0xFF
499 
501 // ECC Key Length
502 #define ECC_KEYLEN 32
503 
504 
506 /*-------------------------------------------------------------------
507  * TYPEDEFS
508  */
509 
529 typedef void (*pfnPasscodeCB_t)
530 (
531  uint8 *deviceAddr,
532  uint16 connectionHandle,
533  uint8 uiInputs,
534  uint8 uiOutputs,
535  uint32 numComparison
536  );
537 
548 typedef void (*pfnPairStateCB_t)
549 (
550  uint16 connectionHandle,
551  uint8 state,
552  uint8 status
553 );
554 
555 /*
556  * @brief GAPBondMgr Callback Structure
557  *
558  * This must be setup by the application and passed to the GAPRole when
559  * @ref GAPBondMgr_Register is called.
560  */
561 typedef struct
562 {
563  pfnPasscodeCB_t passcodeCB;
564  pfnPairStateCB_t pairStateCB;
565 } gapBondCBs_t;
566 
573 typedef struct
575 {
576  uint8 privateKey[ECC_KEYLEN];
577  uint8 publicKeyX[ECC_KEYLEN];
578  uint8 publicKeyY[ECC_KEYLEN];
580 
582 typedef struct
583 {
584  uint8 addr[B_ADDR_LEN];
585  uint8 confirm[KEYLEN];
586  uint8 oob[KEYLEN];
588 
591 /*-------------------------------------------------------------------
592  * MACROS
593  */
594 
595 /*-------------------------------------------------------------------
596  * API FUNCTIONS
597  */
598 
616 extern bStatus_t GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue );
617 
633 extern bStatus_t GAPBondMgr_GetParameter( uint16 param, void *pValue );
634 
649 extern bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role );
650 
659 extern void GAPBondMgr_LinkTerm(uint16 connHandle);
660 
670 extern void GAPBondMgr_SlaveReqSecurity(uint16 connHandle, uint8 authReq);
671 
682 extern uint8 GAPBondMgr_ResolveAddr( uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr );
683 
695 extern bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam );
696 
709 extern bStatus_t GAPBondMgr_UpdateCharCfg( uint16 connectionHandle, uint16 attrHandle, uint16 value );
710 
720 extern void GAPBondMgr_Register( gapBondCBs_t *pCB );
721 
735 extern bStatus_t GAPBondMgr_PasscodeRsp( uint16 connectionHandle, uint8 status, uint32 passcode );
736 
755 extern bStatus_t GAPBondMgr_ReadCentAddrResChar( uint16 connectionHandle );
756 
767 extern uint8 GAPBondMgr_SupportsEnhancedPriv( uint8 *pPeerIdAddr );
768 
781 extern uint8 GAPBondMgr_ProcessGAPMsg( gapEventHdr_t *pMsg );
782 
792 extern uint8 GAPBondMgr_CheckNVLen( uint8 id, uint8 len );
793 
802 
804 
805 /*-------------------------------------------------------------------
806  * TASK FUNCTIONS - Don't call these. These are system functions.
807  */
808 
821 extern void GAPBondMgr_Init( uint8 task_id );
822 
837 extern uint16 GAPBondMgr_ProcessEvent( uint8 task_id, uint16 events );
838 
840 
841 /*-------------------------------------------------------------------
842 -------------------------------------------------------------------*/
843 
844 #ifdef __cplusplus
845 }
846 #endif
847 
848 #endif /* GAPBONDMGR_H */
849 
bStatus_t GAPBondMgr_PasscodeRsp(uint16 connectionHandle, uint8 status, uint32 passcode)
Respond to a passcode request.
Public and Private ECC Keys.
Definition: gapbondmgr.h:574
bStatus_t GAPBondMgr_UpdateCharCfg(uint16 connectionHandle, uint16 attrHandle, uint16 value)
Update the Characteristic Configuration in a bond record.
GAP event header format.
Definition: gap.h:709
bStatus_t GAPBondMgr_LinkEst(uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role)
Notify the Bond Manager that a connection has been made.
uint8 GAPBondMgr_ProcessGAPMsg(gapEventHdr_t *pMsg)
This is a bypass mechanism to allow the bond manager to process GAP messages.
Secure Connections Out of Band.
Definition: gapbondmgr.h:582
uint8 GAPBondMgr_ResolveAddr(uint8 addrType, uint8 *pDevAddr, uint8 *pResolvedAddr)
Resolve an address from bonding information.
void GAPBondMgr_Register(gapBondCBs_t *pCB)
Register callback functions with the bond manager.
bStatus_t GAPBondMgr_ServiceChangeInd(uint16 connectionHandle, uint8 setParam)
Set/clear the service change indication in a bond record.
uint8 GAPBondMgr_SupportsEnhancedPriv(uint8 *pPeerIdAddr)
Determine if peer device supports enhanced privacy by checking the Enhanced Privacy state flag of the...
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.
void GAPBondMgr_LinkTerm(uint16 connHandle)
Notify the Bond Manager that a connection has been terminated.
void(* pfnPasscodeCB_t)(uint8 *deviceAddr, uint16 connectionHandle, uint8 uiInputs, uint8 uiOutputs, uint32 numComparison)
Passcode and Numeric Comparison Callback Function.
Definition: gapbondmgr.h:530
GAP layer interface.
uint8 GAPBondMgr_CheckNVLen(uint8 id, uint8 len)
This function will check the length of a Bond Manager NV Item.
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:131
bStatus_t GAPBondMgr_SetParameter(uint16 param, uint8 len, void *pValue)
Set a GAP Bond Manager parameter.
void(* pfnPairStateCB_t)(uint16 connectionHandle, uint8 state, uint8 status)
Pairing State Callback Function.
Definition: gapbondmgr.h:549
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:243
#define ECC_KEYLEN
256 bit keys
Definition: gapbondmgr.h:502
bStatus_t GAPBondMgr_ReadCentAddrResChar(uint16 connectionHandle)
Read Central Address Resolution Characteristic.
void GAPBondMgr_SlaveReqSecurity(uint16 connHandle, uint8 authReq)
Notify the Bond Manager that a Slave Security Request is received.
#define KEYLEN
Default key length.
Definition: bcomdef.h:134
Copyright 2016, Texas Instruments Incorporated