Cordio Stack and Cordio Profiles  r2p3-02rel0
Application Framework Database API

Content

 Application Framework Main API
 

Macros

#define APP_DB_HDL_NONE   NULL
 No device database record handle.
 

Typedefs

typedef void * appDbHdl_t
 Device database record handle type.
 

App Configuration

Build-time configuration constants

#define APP_DB_NUM_RECS   3
 Number of application database device records.
 
#define APP_DB_NUM_CCCD   10
 Number of client characteristic configuration descriptor handles per record.
 
#define APP_DB_HDL_LIST_LEN   20
 Number of ATT client cached handles per record.
 

App Database

Store known device and security information.

void AppDbInit (void)
 Initialize the device database. More...
 
appDbHdl_t AppDbNewRecord (uint8_t addrType, uint8_t *pAddr)
 Create a new device database record. More...
 
appDbHdl_t AppDbGetNextRecord (appDbHdl_t hdl)
 Get next device database record for a given database record. For the first database record, the function should be called with 'hdl' set to 'APP_DB_HDL_NONE'. More...
 
void AppDbDeleteRecord (appDbHdl_t hdl)
 Delete a new device database record. More...
 
void AppDbValidateRecord (appDbHdl_t hdl, uint8_t keyMask)
 Validate a new device database record. This function is called when pairing is successful and the devices are bonded. More...
 
void AppDbCheckValidRecord (appDbHdl_t hdl)
 Check if a record has been validated. If it has not, delete it. This function is typically called when the connection is closed. More...
 
bool_t AppDbRecordInUse (appDbHdl_t hdl)
 Check if a database record is in use. More...
 
bool_t AppDbCheckBonded (void)
 Check if there is a stored bond with any device. More...
 
void AppDbDeleteAllRecords (void)
 Delete all database records. More...
 
appDbHdl_t AppDbFindByAddr (uint8_t addrType, uint8_t *pAddr)
 Find a device database record by peer address. More...
 
appDbHdl_t AppDbFindByLtkReq (uint16_t encDiversifier, uint8_t *pRandNum)
 Find a device database record from data in an LTK request. More...
 
appDbHdl_t AppDbGetHdl (dmConnId_t connId)
 Get the device database record handle associated with an open connection. More...
 
dmSecKey_tAppDbGetKey (appDbHdl_t hdl, uint8_t type, uint8_t *pSecLevel)
 Get a key from a device database record. More...
 
void AppDbSetKey (appDbHdl_t hdl, dmSecKeyIndEvt_t *pKey)
 Set a key in a device database record. More...
 
uint16_tAppDbGetCccTbl (appDbHdl_t hdl)
 Get the client characteristic configuration descriptor table. More...
 
void AppDbSetCccTblValue (appDbHdl_t hdl, uint16_t idx, uint16_t value)
 Set a value in the client characteristic configuration table. More...
 
uint8_t AppDbGetDiscStatus (appDbHdl_t hdl)
 Get the discovery status. More...
 
void AppDbSetDiscStatus (appDbHdl_t hdl, uint8_t status)
 Set the discovery status. More...
 
uint16_tAppDbGetHdlList (appDbHdl_t hdl)
 Get the cached handle list. More...
 
void AppDbSetHdlList (appDbHdl_t hdl, uint16_t *pHdlList)
 Set the cached handle list. More...
 
char * AppDbGetDevName (uint8_t *pLen)
 Get the device name. More...
 
void AppDbSetDevName (uint8_t len, char *pStr)
 Set the device name. More...
 
bool_t AppDbGetPeerAddrRes (appDbHdl_t hdl)
 Get address resolution attribute value read from a peer device. More...
 
void AppDbSetPeerAddrRes (appDbHdl_t hdl, uint8_t addrRes)
 Set address resolution attribute value for a peer device. More...
 
uint32_t AppDbGetPeerSignCounter (appDbHdl_t hdl)
 Get sign counter for a peer device. More...
 
void AppDbSetPeerSignCounter (appDbHdl_t hdl, uint32_t signCounter)
 Set sign counter for a peer device. More...
 
bool_t AppDbGetPeerAddedToRl (appDbHdl_t hdl)
 Get the peer device added to resolving list flag value. More...
 
void AppDbSetPeerAddedToRl (appDbHdl_t hdl, bool_t peerAddedToRl)
 Set the peer device added to resolving list flag to a given value. More...
 
bool_t AppDbGetPeerRpao (appDbHdl_t hdl)
 Get resolvable private address only attribute present flag for a peer device. More...
 
void AppDbSetPeerRpao (appDbHdl_t hdl, bool_t peerRpao)
 Set resolvable private address only attribute present flag for a peer device. More...
 

Description

Function Documentation

void AppDbInit ( void  )

Initialize the device database.

Returns
None.
appDbHdl_t AppDbNewRecord ( uint8_t  addrType,
uint8_t pAddr 
)

Create a new device database record.

Parameters
addrTypeAddress type.
pAddrPeer device address.
Returns
Database record handle.
appDbHdl_t AppDbGetNextRecord ( appDbHdl_t  hdl)

Get next device database record for a given database record. For the first database record, the function should be called with 'hdl' set to 'APP_DB_HDL_NONE'.

Parameters
hdlDatabase record handle.
Returns
Next database record handle found. APP_DB_HDL_NONE, otherwise.
void AppDbDeleteRecord ( appDbHdl_t  hdl)

Delete a new device database record.

Parameters
hdlDatabase record handle.
Returns
None.
void AppDbValidateRecord ( appDbHdl_t  hdl,
uint8_t  keyMask 
)

Validate a new device database record. This function is called when pairing is successful and the devices are bonded.

Parameters
hdlDatabase record handle.
keyMaskBitmask of keys to validate.
Returns
None.
void AppDbCheckValidRecord ( appDbHdl_t  hdl)

Check if a record has been validated. If it has not, delete it. This function is typically called when the connection is closed.

Parameters
hdlDatabase record handle.
Returns
None.
bool_t AppDbRecordInUse ( appDbHdl_t  hdl)

Check if a database record is in use.

Parameters
hdlDatabase record handle.
Returns
TURE if record in use. FALSE, otherwise.
bool_t AppDbCheckBonded ( void  )

Check if there is a stored bond with any device.

Returns
TRUE if a bonded device is found, FALSE otherwise.
void AppDbDeleteAllRecords ( void  )

Delete all database records.

Returns
None.
appDbHdl_t AppDbFindByAddr ( uint8_t  addrType,
uint8_t pAddr 
)

Find a device database record by peer address.

Parameters
addrTypeAddress type.
pAddrPeer device address.
Returns
Database record handle or APP_DB_HDL_NONE if not found.
appDbHdl_t AppDbFindByLtkReq ( uint16_t  encDiversifier,
uint8_t pRandNum 
)

Find a device database record from data in an LTK request.

Parameters
encDiversifierEncryption diversifier associated with key.
pRandNumPointer to random number associated with key.
Returns
Database record handle or APP_DB_HDL_NONE if not found.
appDbHdl_t AppDbGetHdl ( dmConnId_t  connId)

Get the device database record handle associated with an open connection.

Parameters
connIdConnection identifier.
Returns
Database record handle or APP_DB_HDL_NONE.
dmSecKey_t* AppDbGetKey ( appDbHdl_t  hdl,
uint8_t  type,
uint8_t pSecLevel 
)

Get a key from a device database record.

Parameters
hdlDatabase record handle.
typeType of key to get.
pSecLevelIf the key is valid, returns the security level of the key.
Returns
Pointer to the key if the key is valid or NULL if not valid.
void AppDbSetKey ( appDbHdl_t  hdl,
dmSecKeyIndEvt_t pKey 
)

Set a key in a device database record.

Parameters
hdlDatabase record handle.
pKeyKey data.
Returns
None.
uint16_t* AppDbGetCccTbl ( appDbHdl_t  hdl)

Get the client characteristic configuration descriptor table.

Parameters
hdlDatabase record handle.
Returns
Pointer to client characteristic configuration descriptor table.
void AppDbSetCccTblValue ( appDbHdl_t  hdl,
uint16_t  idx,
uint16_t  value 
)

Set a value in the client characteristic configuration table.

Parameters
hdlDatabase record handle.
idxTable index.
valueClient characteristic configuration value.
Returns
None.
uint8_t AppDbGetDiscStatus ( appDbHdl_t  hdl)

Get the discovery status.

Parameters
hdlDatabase record handle.
Returns
Discovery status.
void AppDbSetDiscStatus ( appDbHdl_t  hdl,
uint8_t  status 
)

Set the discovery status.

Parameters
hdlDatabase record handle.
statusDiscovery status.
Returns
None.
uint16_t* AppDbGetHdlList ( appDbHdl_t  hdl)

Get the cached handle list.

Parameters
hdlDatabase record handle.
Returns
Pointer to handle list.
void AppDbSetHdlList ( appDbHdl_t  hdl,
uint16_t pHdlList 
)

Set the cached handle list.

Parameters
hdlDatabase record handle.
pHdlListPointer to handle list.
Returns
None.
char* AppDbGetDevName ( uint8_t pLen)

Get the device name.

Parameters
pLenReturned device name length.
Returns
Pointer to UTF-8 string containing the device name or NULL if not set.
void AppDbSetDevName ( uint8_t  len,
char *  pStr 
)

Set the device name.

Parameters
lenDevice name length.
pStrUTF-8 string containing the device name.
Returns
None.
bool_t AppDbGetPeerAddrRes ( appDbHdl_t  hdl)

Get address resolution attribute value read from a peer device.

Parameters
hdlDatabase record handle.
Returns
TRUE if address resolution is supported in peer device. FALSE, otherwise.
void AppDbSetPeerAddrRes ( appDbHdl_t  hdl,
uint8_t  addrRes 
)

Set address resolution attribute value for a peer device.

Parameters
hdlDatabase record handle.
addrResPeer address resolution attribue value.
Returns
None.
uint32_t AppDbGetPeerSignCounter ( appDbHdl_t  hdl)

Get sign counter for a peer device.

Parameters
hdlDatabase record handle.
Returns
Sign counter for peer device.
void AppDbSetPeerSignCounter ( appDbHdl_t  hdl,
uint32_t  signCounter 
)

Set sign counter for a peer device.

Parameters
hdlDatabase record handle.
signCounterSign counter for peer device.
Returns
None.
bool_t AppDbGetPeerAddedToRl ( appDbHdl_t  hdl)

Get the peer device added to resolving list flag value.

Parameters
hdlDatabase record handle.
Returns
TRUE if peer device's been added to resolving list. FALSE, otherwise.
void AppDbSetPeerAddedToRl ( appDbHdl_t  hdl,
bool_t  peerAddedToRl 
)

Set the peer device added to resolving list flag to a given value.

Parameters
hdlDatabase record handle.
peerAddedToRlPeer device added to resolving list flag value.
Returns
None.
bool_t AppDbGetPeerRpao ( appDbHdl_t  hdl)

Get resolvable private address only attribute present flag for a peer device.

Parameters
hdlDatabase record handle.
Returns
TRUE if RPA Only attribute is present on peer device. FALSE, otherwise.
void AppDbSetPeerRpao ( appDbHdl_t  hdl,
bool_t  peerRpao 
)

Set resolvable private address only attribute present flag for a peer device.

Parameters
hdlDatabase record handle.
peerRpaoResolvable private address only attribute present flag.
Returns
None.