Skip to content

Commit 7d916a9

Browse files
fix not writing version number into the file
1 parent 62ba220 commit 7d916a9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

features/FEATURE_BLE/source/generic/FileSecurityDb.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,15 @@ void FileSecurityDb::set_entry_peer_sign_counter(
267267
/* saving and loading from nvm */
268268

269269
void FileSecurityDb::restore() {
270+
/* restore if requested */
271+
bool restore_toggle = false;
272+
db_read(&restore_toggle, DB_OFFSET_RESTORE);
270273

271-
fseek(_db_file, DB_OFFSET_RESTORE, SEEK_SET);
274+
if (!restore_toggle) {
275+
erase_db_file(_db_file);
272276

273-
/* restore if requested */
274-
bool restore_toggle;
275-
if (fread(&restore_toggle, sizeof(bool), 1, _db_file) == 1) {
276-
if (!restore_toggle) {
277-
erase_db_file(_db_file);
278-
return;
279-
}
277+
db_write(&DB_VERSION, DB_OFFSET_VERSION);
278+
return;
280279
}
281280

282281
db_read(&_local_identity, DB_OFFSET_LOCAL_IDENTITY);

0 commit comments

Comments
 (0)