make number of db entries configurable

pull/13037/head
Paul Szczeanek 2020-06-03 17:07:47 +01:00
parent c7759fe505
commit d6a5bd2825
4 changed files with 12 additions and 11 deletions

View File

@ -34,8 +34,6 @@ private:
size_t file_offset;
};
static const size_t MAX_ENTRIES = 5;
static entry_t* as_entry(entry_handle_t db_handle) {
return reinterpret_cast<entry_t*>(db_handle);
}
@ -146,7 +144,7 @@ private:
static FILE* erase_db_file(FILE* db_file);
private:
entry_t _entries[MAX_ENTRIES];
entry_t _entries[BLE_SECURITY_DATABASE_MAX_ENTRIES];
FILE *_db_file;
uint8_t _buffer[sizeof(SecurityEntryKeys_t)];
};

View File

@ -34,8 +34,6 @@ private:
SecurityEntrySigning_t peer_signing;
};
static const size_t MAX_ENTRIES = 5;
static entry_t* as_entry(entry_handle_t db_handle)
{
return reinterpret_cast<entry_t*>(db_handle);
@ -150,11 +148,11 @@ public:
private:
virtual uint8_t get_entry_count() {
return MAX_ENTRIES;
return BLE_SECURITY_DATABASE_MAX_ENTRIES;
}
virtual SecurityDistributionFlags_t* get_entry_handle_by_index(uint8_t index) {
if (index < MAX_ENTRIES) {
if (index < BLE_SECURITY_DATABASE_MAX_ENTRIES) {
return &_entries[index].flags;
} else {
return NULL;
@ -187,7 +185,7 @@ private:
};
private:
entry_t _entries[MAX_ENTRIES];
entry_t _entries[BLE_SECURITY_DATABASE_MAX_ENTRIES];
};
} /* namespace pal */

View File

@ -71,6 +71,11 @@
"help": "Include periodic advertising support, depends on the extended advertising feature.",
"value": true,
"macro_name": "BLE_FEATURE_PERIODIC_ADVERTISING"
},
"ble-security-database-max-entries": {
"help": "How many entries can be stored in the db, depends on security manager.",
"value": 5,
"macro_name": "BLE_SECURITY_DATABASE_MAX_ENTRIES"
}
}
}

View File

@ -54,7 +54,7 @@ const uint16_t DB_VERSION = 1;
)
#define DB_SIZE_STORES \
(FileSecurityDb::MAX_ENTRIES * DB_SIZE_STORE)
(BLE_SECURITY_DATABASE_MAX_ENTRIES * DB_SIZE_STORE)
#define DB_OFFSET_VERSION (0)
#define DB_OFFSET_RESTORE (DB_OFFSET_VERSION + sizeof(DB_VERSION))
@ -308,11 +308,11 @@ void FileSecurityDb::set_restore(bool reload) {
/* helper functions */
uint8_t FileSecurityDb::get_entry_count() {
return MAX_ENTRIES;
return BLE_SECURITY_DATABASE_MAX_ENTRIES;
}
SecurityDistributionFlags_t* FileSecurityDb::get_entry_handle_by_index(uint8_t index) {
if (index < MAX_ENTRIES) {
if (index < BLE_SECURITY_DATABASE_MAX_ENTRIES) {
return &_entries[index].flags;
} else {
return NULL;