Skip to content
Snippets Groups Projects
Commit 36e6bc9f authored by schneider's avatar schneider
Browse files

chore(bondings): Remove unused appDb struct

parent 9e34ea2a
No related branches found
No related tags found
1 merge request!402New pairing database
...@@ -77,21 +77,16 @@ typedef struct ...@@ -77,21 +77,16 @@ typedef struct
uint8_t discStatus; /*! Service discovery and configuration status */ uint8_t discStatus; /*! Service discovery and configuration status */
} appDbRec_t; } appDbRec_t;
/*! Database type */
typedef struct
{
appDbRec_t rec[APP_DB_NUM_RECS]; /*! Device database records */
} appDb_t;
/************************************************************************************************** /**************************************************************************************************
Local Variables Local Variables
**************************************************************************************************/ **************************************************************************************************/
/*! Database */ /*! Database */
static appDb_t appDb; static appDbRec_t records[APP_DB_NUM_RECS];
/*! When all records are allocated use this index to determine which to overwrite */ /*! When all records are allocated use this index to determine which to overwrite */
static appDbRec_t *pAppDbNewRec = appDb.rec; static appDbRec_t *pAppDbNewRec = records;
/*************************************************************************************************/ /*************************************************************************************************/
/*! /*!
...@@ -105,8 +100,8 @@ void AppDbInit(void) ...@@ -105,8 +100,8 @@ void AppDbInit(void)
int fd = epic_file_open("pairings.bin", "r"); int fd = epic_file_open("pairings.bin", "r");
if(fd >= 0) { if(fd >= 0) {
if(epic_file_read(fd, &appDb, sizeof(appDb)) != sizeof(appDb)) { if(epic_file_read(fd, records, sizeof(records)) != sizeof(records)) {
memset(&appDb, 0, sizeof(appDb)); memset(records, 0, sizeof(records));
} }
epic_file_close(fd); epic_file_close(fd);
} }
...@@ -114,11 +109,11 @@ void AppDbInit(void) ...@@ -114,11 +109,11 @@ void AppDbInit(void)
static void AppDbStore(void) static void AppDbStore(void)
{ {
LOG_INFO("appDb", "writing to persistent storage"); LOG_INFO("bondings", "writing to persistent storage");
int fd = epic_file_open("pairings.bin", "w"); int fd = epic_file_open("pairings.bin", "w");
if(fd >= 0) { if(fd >= 0) {
if(epic_file_write(fd, &appDb, sizeof(appDb)) != sizeof(appDb)) { if(epic_file_write(fd, records, sizeof(records)) != sizeof(records)) {
} }
epic_file_close(fd); epic_file_close(fd);
} }
...@@ -136,7 +131,7 @@ static void AppDbStore(void) ...@@ -136,7 +131,7 @@ static void AppDbStore(void)
/*************************************************************************************************/ /*************************************************************************************************/
appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr) appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr)
{ {
appDbRec_t *pRec = appDb.rec; appDbRec_t *pRec = records;
uint8_t i; uint8_t i;
/* find a free record */ /* find a free record */
...@@ -156,9 +151,9 @@ appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr) ...@@ -156,9 +151,9 @@ appDbHdl_t AppDbNewRecord(uint8_t addrType, uint8_t *pAddr)
/* get next record to overwrite */ /* get next record to overwrite */
pAppDbNewRec++; pAppDbNewRec++;
if (pAppDbNewRec == &appDb.rec[APP_DB_NUM_RECS]) if (pAppDbNewRec == &records[APP_DB_NUM_RECS])
{ {
pAppDbNewRec = appDb.rec; pAppDbNewRec = records;
} }
} }
...@@ -190,7 +185,7 @@ appDbHdl_t AppDbGetNextRecord(appDbHdl_t hdl) ...@@ -190,7 +185,7 @@ appDbHdl_t AppDbGetNextRecord(appDbHdl_t hdl)
/* if first record is requested */ /* if first record is requested */
if (hdl == APP_DB_HDL_NONE) if (hdl == APP_DB_HDL_NONE)
{ {
pRec = appDb.rec; pRec = records;
} }
/* if valid record passed in */ /* if valid record passed in */
else if (AppDbRecordInUse(hdl)) else if (AppDbRecordInUse(hdl))
...@@ -205,7 +200,7 @@ appDbHdl_t AppDbGetNextRecord(appDbHdl_t hdl) ...@@ -205,7 +200,7 @@ appDbHdl_t AppDbGetNextRecord(appDbHdl_t hdl)
} }
/* look for next valid record */ /* look for next valid record */
while (pRec < &appDb.rec[APP_DB_NUM_RECS]) while (pRec < &records[APP_DB_NUM_RECS])
{ {
/* if record is in use */ /* if record is in use */
if (pRec->inUse && pRec->valid) if (pRec->inUse && pRec->valid)
...@@ -283,7 +278,7 @@ void AppDbCheckValidRecord(appDbHdl_t hdl) ...@@ -283,7 +278,7 @@ void AppDbCheckValidRecord(appDbHdl_t hdl)
/*************************************************************************************************/ /*************************************************************************************************/
bool_t AppDbRecordInUse(appDbHdl_t hdl) bool_t AppDbRecordInUse(appDbHdl_t hdl)
{ {
appDbRec_t *pRec = appDb.rec; appDbRec_t *pRec = records;
uint8_t i; uint8_t i;
/* see if record is in database record list */ /* see if record is in database record list */
...@@ -309,7 +304,7 @@ bool_t AppDbRecordInUse(appDbHdl_t hdl) ...@@ -309,7 +304,7 @@ bool_t AppDbRecordInUse(appDbHdl_t hdl)
/*************************************************************************************************/ /*************************************************************************************************/
bool_t AppDbCheckBonded(void) bool_t AppDbCheckBonded(void)
{ {
appDbRec_t *pRec = appDb.rec; appDbRec_t *pRec = records;
uint8_t i; uint8_t i;
/* find a record */ /* find a record */
...@@ -333,7 +328,7 @@ bool_t AppDbCheckBonded(void) ...@@ -333,7 +328,7 @@ bool_t AppDbCheckBonded(void)
/*************************************************************************************************/ /*************************************************************************************************/
void AppDbDeleteAllRecords(void) void AppDbDeleteAllRecords(void)
{ {
appDbRec_t *pRec = appDb.rec; appDbRec_t *pRec = records;
uint8_t i; uint8_t i;
/* set in use to false for all records */ /* set in use to false for all records */
...@@ -355,7 +350,7 @@ void AppDbDeleteAllRecords(void) ...@@ -355,7 +350,7 @@ void AppDbDeleteAllRecords(void)
/*************************************************************************************************/ /*************************************************************************************************/
appDbHdl_t AppDbFindByAddr(uint8_t addrType, uint8_t *pAddr) appDbHdl_t AppDbFindByAddr(uint8_t addrType, uint8_t *pAddr)
{ {
appDbRec_t *pRec = appDb.rec; appDbRec_t *pRec = records;
uint8_t peerAddrType = DmHostAddrType(addrType); uint8_t peerAddrType = DmHostAddrType(addrType);
uint8_t i; uint8_t i;
...@@ -383,7 +378,7 @@ appDbHdl_t AppDbFindByAddr(uint8_t addrType, uint8_t *pAddr) ...@@ -383,7 +378,7 @@ appDbHdl_t AppDbFindByAddr(uint8_t addrType, uint8_t *pAddr)
/*************************************************************************************************/ /*************************************************************************************************/
appDbHdl_t AppDbFindByLtkReq(uint16_t encDiversifier, uint8_t *pRandNum) appDbHdl_t AppDbFindByLtkReq(uint16_t encDiversifier, uint8_t *pRandNum)
{ {
appDbRec_t *pRec = appDb.rec; appDbRec_t *pRec = records;
uint8_t i; uint8_t i;
/* find matching record */ /* find matching record */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment