Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
36e6bc9f
Commit
36e6bc9f
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
chore(bondings): Remove unused appDb struct
parent
9e34ea2a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!402
New pairing database
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/ble/bondings.c
+16
-21
16 additions, 21 deletions
epicardium/ble/bondings.c
with
16 additions
and
21 deletions
epicardium/ble/bondings.c
+
16
−
21
View file @
36e6bc9f
...
@@ -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
appDb
Rec_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 */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment