TI BLE-Stack for Bluetooth API Documentation  3.03.08.00
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 
48 #define LINKDB_CONNHANDLE_ALL LL_CONNHANDLE_ALL
50 #define LINKDB_CONNHANDLE_LOOPBACK LL_CONNHANDLE_LOOPBACK
52 #define LINKDB_CONNHANDLE_INVALID LL_CONNHANDLE_INVALID
54 
57 // Special case connection handles
58 #define INVALID_CONNHANDLE 0xFFFF
59 #define LOOPBACK_CONNHANDLE 0xFFFE
60 
61 
64 // Link state flags
65 #define LINK_NOT_CONNECTED 0x00
66 #define LINK_CONNECTED 0x01
67 #define LINK_AUTHENTICATED 0x02
68 #define LINK_BOUND 0x04
69 #define LINK_ENCRYPTED 0x10
70 #define LINK_SECURE_CONNECTIONS 0x20
71 #define LINK_IN_UPDATE 0x40
72 
74 // Link Database Status callback changeTypes
75 #define LINKDB_STATUS_UPDATE_NEW 0
76 #define LINKDB_STATUS_UPDATE_REMOVED 1
77 #define LINKDB_STATUS_UPDATE_STATEFLAGS 2
78 
79 // Link Authentication Errors
80 #define LINKDB_ERR_INSUFFICIENT_AUTHEN 0x05
81 #define LINBDB_ERR_INSUFFICIENT_KEYSIZE 0x0c
82 #define LINKDB_ERR_INSUFFICIENT_ENCRYPTION 0x0f
83 
85 /*********************************************************************
86  * TYPEDEFS
87  */
88 
95 typedef struct
96 {
97  uint8 srk[KEYLEN];
98  uint32 signCounter;
99 } linkSec_t;
100 
104 typedef struct
105 {
106  uint8 ltk[KEYLEN];
107  uint16 div;
108  uint8 rand[B_RANDOM_NUM_SIZE];
109  uint8 keySize;
110 } encParams_t;
111 
115 typedef struct
116 {
117  uint8 taskID;
119  uint8 stateFlags;
120  uint8 addrType;
121  uint8 addr[B_ADDR_LEN];
122  uint8 addrPriv[B_ADDR_LEN];
123  uint8 connRole;
124  uint16 connInterval;
125  uint16 MTU;
128 } linkDBItem_t;
129 
133 typedef struct
134 {
135  uint8 stateFlags;
136  uint8 addrType;
137  uint8 addr[B_ADDR_LEN];
138  uint8 addrPriv[B_ADDR_LEN];
139  uint8 connRole;
140  uint16 connInterval;
141  uint16 MTU;
142 } linkDBInfo_t;
148 typedef void (*pfnLinkDBCB_t)( uint16 connectionHandle, uint8 changeType );
150 
152 typedef void (*pfnPerformFuncCB_t)( linkDBItem_t *pLinkItem );
155 /*********************************************************************
156  * GLOBAL VARIABLES
157  */
158 
160 
161 extern uint8 linkDBNumConns;
162 
164 
165 /*********************************************************************
166  * PUBLIC FUNCTIONS
167  */
168 
172  extern void linkDB_Init( void );
173  extern uint8 linkDB_Register( pfnLinkDBCB_t pFunc );
187 
207  extern uint8 linkDB_Add( uint8 taskID, uint16 connectionHandle,
208  uint8 stateFlags, uint8 addrType, uint8 *pAddr,
209  uint8 *pAddrPriv, uint8 connRole, uint16 connInterval,
210  uint16 MTU );
211 
221  extern uint8 linkDB_Remove( uint16 connectionHandle );
222 
235  extern uint8 linkDB_Update( uint16 connectionHandle, uint8 newState,
236  uint8 add );
237 
238 
245  extern uint8 linkDB_NumActive( void );
246 
253  extern uint8 linkDB_NumConns( void );
254 
264  extern uint8 linkDB_UpdateMTU( uint16 connectionHandle, uint16 newMtu );
265 
273  extern uint16 linkDB_MTU( uint16 connectionHandle );
274 
286  extern uint8 linkDB_GetInfo( uint16 connectionHandle, linkDBInfo_t * pInfo );
287 
299  extern linkDBItem_t *linkDB_Find( uint16 connectionHandle );
300 
309  extern linkDBItem_t *linkDB_FindFirst( uint8 taskID );
310 
320  extern uint8 linkDB_State( uint16 connectionHandle, uint8 state );
321 
335  extern uint8 linkDB_Authen( uint16 connectionHandle, uint8 keySize,
336  uint8 mitmRequired );
337 
346  extern uint8 linkDB_Role( uint16 connectionHandle );
347 
353  extern void linkDB_PerformFunc( pfnPerformFuncCB_t cb );
354 
361  extern void linkDB_SecurityModeSCOnly( uint8 state );
362 
363 /*********************************************************************
364  * LINK STATE MACROS
365  * Developer note: Call from Application only. Do not call from Stack,
366  * not supported for ROM patching!
367  */
368 
377  #define linkDB_Up( connectionHandle ) linkDB_State( (connectionHandle), LINK_CONNECTED )
378 
387  #define linkDB_Encrypted( connectionHandle ) linkDB_State( (connectionHandle), LINK_ENCRYPTED )
388 
397  #define linkDB_Authenticated( connectionHandle ) linkDB_State( (connectionHandle), LINK_AUTHENTICATED )
398 
407  #define linkDB_Bonded( connectionHandle ) linkDB_State( (connectionHandle), LINK_BOUND )
408 
409 /*********************************************************************
410 *********************************************************************/
411 
412 #ifdef __cplusplus
413 }
414 #endif
415 
416 #endif /* LINKDB_H */
417 
#define B_RANDOM_NUM_SIZE
BLE Random Number Size.
Definition: bcomdef.h:133
Encryption Params.
Definition: linkdb.h:104
#define B_ADDR_LEN
Default Public and Random Address Length.
Definition: bcomdef.h:115
uint16 div
Diversifier.
Definition: linkdb.h:107
#define KEYLEN
Default key length.
Definition: bcomdef.h:118
uint8 keySize
LTK Key Size.
Definition: linkdb.h:109
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale