Skip to content
Snippets Groups Projects
Commit 9db5524b authored by schneider's avatar schneider
Browse files

change(ble): Fail new pairings if there is no slot available

parent 6b91b1a7
No related branches found
No related tags found
No related merge requests found
...@@ -114,9 +114,6 @@ typedef struct ...@@ -114,9 +114,6 @@ typedef struct
/*! Database */ /*! Database */
static appDbRec_t records[APP_DB_NUM_RECS]; static appDbRec_t records[APP_DB_NUM_RECS];
/*! When all records are allocated use this index to determine which to overwrite */
static appDbRec_t *pAppDbNewRec = records;
/* clang-format on */ /* clang-format on */
/* Translate a pointer to a record into the filename to be used for it. */ /* Translate a pointer to a record into the filename to be used for it. */
static int record_to_filename(appDbRec_t *record, char *buf, size_t buf_size) static int record_to_filename(appDbRec_t *record, char *buf, size_t buf_size)
...@@ -317,7 +314,7 @@ void AppDbInit(void) ...@@ -317,7 +314,7 @@ void AppDbInit(void)
* \param addrType Address type. * \param addrType Address type.
* \param pAddr Peer device address. * \param pAddr Peer device address.
* *
* \return Database record handle. * \return Database record handle. APP_DB_HDL_NONE if none is available.
*/ */
/*************************************************************************************************/ /*************************************************************************************************/
appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr) appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr)
...@@ -337,15 +334,7 @@ appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr) ...@@ -337,15 +334,7 @@ appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr)
/* if all records were allocated */ /* if all records were allocated */
if (i == 0) if (i == 0)
{ {
/* overwrite a record */ return APP_DB_HDL_NONE;
pRec = pAppDbNewRec;
/* get next record to overwrite */
pAppDbNewRec++;
if (pAppDbNewRec == &records[APP_DB_NUM_RECS])
{
pAppDbNewRec = records;
}
} }
/* initialize record */ /* initialize record */
......
...@@ -706,6 +706,13 @@ static void appSecPairInd(dmEvt_t *pMsg, appConnCb_t *pCb) ...@@ -706,6 +706,13 @@ static void appSecPairInd(dmEvt_t *pMsg, appConnCb_t *pCb)
{ {
/* create a device record if none exists */ /* create a device record if none exists */
pCb->dbHdl = AppDbNewRecord(DmConnPeerAddrType(pCb->connId), DmConnPeerAddr(pCb->connId)); pCb->dbHdl = AppDbNewRecord(DmConnPeerAddrType(pCb->connId), DmConnPeerAddr(pCb->connId));
/* If there is no free record available, fail the pairing attempt */
if (pCb->dbHdl == APP_DB_HDL_NONE)
{
DmSecCancelReq(pCb->connId, SMP_ERR_PAIRING_NOT_SUP);
return;
}
} }
/* initialize stored keys */ /* initialize stored keys */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment