TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
linkdb.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: TISD 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
21 #ifndef LINKDB_H
22 #define LINKDB_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 /*********************************************************************
30  * INCLUDES
31  */
32 
33 /*********************************************************************
34  * MACROS
35  */
36 
37 /*********************************************************************
38  * CONSTANTS
39  */
40 
44 // Special case connection handles
45 #define INVALID_CONNHANDLE 0xFFFF
46 #define LOOPBACK_CONNHANDLE 0xFFFE
47 
48 
51 // Link state flags
52 #define LINK_NOT_CONNECTED 0x00
53 #define LINK_CONNECTED 0x01
54 #define LINK_AUTHENTICATED 0x02
55 #define LINK_BOUND 0x04
56 #define LINK_ENCRYPTED 0x10
57 #define LINK_SECURE_CONNECTIONS 0x20
58 #define LINK_IN_UPDATE 0x40
59 
61 // Link Database Status callback changeTypes
62 #define LINKDB_STATUS_UPDATE_NEW 0
63 #define LINKDB_STATUS_UPDATE_REMOVED 1
64 #define LINKDB_STATUS_UPDATE_STATEFLAGS 2
65 
66 // Link Authentication Errors
67 #define LINKDB_ERR_INSUFFICIENT_AUTHEN 0x05
68 #define LINBDB_ERR_INSUFFICIENT_KEYSIZE 0x0c
69 #define LINKDB_ERR_INSUFFICIENT_ENCRYPTION 0x0f
70 
72 /*********************************************************************
73  * TYPEDEFS
74  */
75 
82 typedef struct
83 {
84  uint8 srk[KEYLEN];
85  uint32 signCounter;
86 } linkSec_t;
87 
91 typedef struct
92 {
93  uint8 ltk[KEYLEN];
94  uint16 div;
95  uint8 rand[B_RANDOM_NUM_SIZE];
96  uint8 keySize;
97 } encParams_t;
98 
102 typedef struct
103 {
104  uint8 taskID;
106  uint8 stateFlags;
107  uint8 addrType;
108  uint8 addr[B_ADDR_LEN];
109  uint8 addrPriv[B_ADDR_LEN];
110  uint8 connRole;
111  uint16 connInterval;
112  uint16 MTU;
115 } linkDBItem_t;
116 
120 typedef struct
121 {
122  uint8 stateFlags;
123  uint8 addrType;
124  uint8 addr[B_ADDR_LEN];
125  uint8 addrPriv[B_ADDR_LEN];
126  uint8 connRole;
127  uint16 connInterval;
128  uint16 MTU;
129 } linkDBInfo_t;
135 typedef void (*pfnLinkDBCB_t)( uint16 connectionHandle, uint8 changeType );
137 
139 typedef void (*pfnPerformFuncCB_t)( linkDBItem_t *pLinkItem );
142 /*********************************************************************
143  * GLOBAL VARIABLES
144  */
145 
147 
148 extern uint8 linkDBNumConns;
149 
151 
152 /*********************************************************************
153  * PUBLIC FUNCTIONS
154  */
155 
159  extern void linkDB_Init( void );
160  extern uint8 linkDB_Register( pfnLinkDBCB_t pFunc );
174 
194  extern uint8 linkDB_Add( uint8 taskID, uint16 connectionHandle,
195  uint8 stateFlags, uint8 addrType, uint8 *pAddr,
196  uint8 *pAddrPriv, uint8 connRole, uint16 connInterval,
197  uint16 MTU );
198 
208  extern uint8 linkDB_Remove( uint16 connectionHandle );
209 
222  extern uint8 linkDB_Update( uint16 connectionHandle, uint8 newState,
223  uint8 add );
224 
225 
232  extern uint8 linkDB_NumActive( void );
233 
240  extern uint8 linkDB_NumConns( void );
241 
251  extern uint8 linkDB_UpdateMTU( uint16 connectionHandle, uint16 newMtu );
252 
260  extern uint16 linkDB_MTU( uint16 connectionHandle );
261 
273  extern uint8 linkDB_GetInfo( uint16 connectionHandle, linkDBInfo_t * pInfo );
274 
286  extern linkDBItem_t *linkDB_Find( uint16 connectionHandle );
287 
296  extern linkDBItem_t *linkDB_FindFirst( uint8 taskID );
297 
307  extern uint8 linkDB_State( uint16 connectionHandle, uint8 state );
308 
322  extern uint8 linkDB_Authen( uint16 connectionHandle, uint8 keySize,
323  uint8 mitmRequired );
324 
333  extern uint8 linkDB_Role( uint16 connectionHandle );
334 
340  extern void linkDB_PerformFunc( pfnPerformFuncCB_t cb );
341 
348  extern void linkDB_SecurityModeSCOnly( uint8 state );
349 
350 /*********************************************************************
351  * LINK STATE MACROS
352  * Developer note: Call from Application only. Do not call from Stack,
353  * not supported for ROM patching!
354  */
355 
364  #define linkDB_Up( connectionHandle ) linkDB_State( (connectionHandle), LINK_CONNECTED )
365 
374  #define linkDB_Encrypted( connectionHandle ) linkDB_State( (connectionHandle), LINK_ENCRYPTED )
375 
384  #define linkDB_Authenticated( connectionHandle ) linkDB_State( (connectionHandle), LINK_AUTHENTICATED )
385 
394  #define linkDB_Bonded( connectionHandle ) linkDB_State( (connectionHandle), LINK_BOUND )
395 
396 /*********************************************************************
397 *********************************************************************/
398 
399 #ifdef __cplusplus
400 }
401 #endif
402 
403 #endif /* LINKDB_H */
404 
#define B_RANDOM_NUM_SIZE
BLE Random Number Size.
Definition: bcomdef.h:130
Encryption Params.
Definition: linkdb.h:91
#define B_ADDR_LEN
Default Public and Random Address Length.
Definition: bcomdef.h:112
uint16 div
Diversifier.
Definition: linkdb.h:94
#define KEYLEN
Default key length.
Definition: bcomdef.h:115
uint8 keySize
LTK Key Size.
Definition: linkdb.h:96
Copyright 2017, Texas Instruments Incorporated