Skip to content

Commit d6a5bd2

Browse files
make number of db entries configurable
1 parent c7759fe commit d6a5bd2

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

features/FEATURE_BLE/ble/generic/FileSecurityDb.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class FileSecurityDb : public SecurityDb {
3434
size_t file_offset;
3535
};
3636

37-
static const size_t MAX_ENTRIES = 5;
38-
3937
static entry_t* as_entry(entry_handle_t db_handle) {
4038
return reinterpret_cast<entry_t*>(db_handle);
4139
}
@@ -146,7 +144,7 @@ class FileSecurityDb : public SecurityDb {
146144
static FILE* erase_db_file(FILE* db_file);
147145

148146
private:
149-
entry_t _entries[MAX_ENTRIES];
147+
entry_t _entries[BLE_SECURITY_DATABASE_MAX_ENTRIES];
150148
FILE *_db_file;
151149
uint8_t _buffer[sizeof(SecurityEntryKeys_t)];
152150
};

features/FEATURE_BLE/ble/generic/MemorySecurityDb.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class MemorySecurityDb : public SecurityDb {
3434
SecurityEntrySigning_t peer_signing;
3535
};
3636

37-
static const size_t MAX_ENTRIES = 5;
38-
3937
static entry_t* as_entry(entry_handle_t db_handle)
4038
{
4139
return reinterpret_cast<entry_t*>(db_handle);
@@ -150,11 +148,11 @@ class MemorySecurityDb : public SecurityDb {
150148

151149
private:
152150
virtual uint8_t get_entry_count() {
153-
return MAX_ENTRIES;
151+
return BLE_SECURITY_DATABASE_MAX_ENTRIES;
154152
}
155153

156154
virtual SecurityDistributionFlags_t* get_entry_handle_by_index(uint8_t index) {
157-
if (index < MAX_ENTRIES) {
155+
if (index < BLE_SECURITY_DATABASE_MAX_ENTRIES) {
158156
return &_entries[index].flags;
159157
} else {
160158
return NULL;
@@ -187,7 +185,7 @@ class MemorySecurityDb : public SecurityDb {
187185
};
188186

189187
private:
190-
entry_t _entries[MAX_ENTRIES];
188+
entry_t _entries[BLE_SECURITY_DATABASE_MAX_ENTRIES];
191189
};
192190

193191
} /* namespace pal */

features/FEATURE_BLE/mbed_lib.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
"help": "Include periodic advertising support, depends on the extended advertising feature.",
7272
"value": true,
7373
"macro_name": "BLE_FEATURE_PERIODIC_ADVERTISING"
74+
},
75+
"ble-security-database-max-entries": {
76+
"help": "How many entries can be stored in the db, depends on security manager.",
77+
"value": 5,
78+
"macro_name": "BLE_SECURITY_DATABASE_MAX_ENTRIES"
7479
}
7580
}
7681
}

features/FEATURE_BLE/source/generic/FileSecurityDb.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const uint16_t DB_VERSION = 1;
5454
)
5555

5656
#define DB_SIZE_STORES \
57-
(FileSecurityDb::MAX_ENTRIES * DB_SIZE_STORE)
57+
(BLE_SECURITY_DATABASE_MAX_ENTRIES * DB_SIZE_STORE)
5858

5959
#define DB_OFFSET_VERSION (0)
6060
#define DB_OFFSET_RESTORE (DB_OFFSET_VERSION + sizeof(DB_VERSION))
@@ -308,11 +308,11 @@ void FileSecurityDb::set_restore(bool reload) {
308308
/* helper functions */
309309

310310
uint8_t FileSecurityDb::get_entry_count() {
311-
return MAX_ENTRIES;
311+
return BLE_SECURITY_DATABASE_MAX_ENTRIES;
312312
}
313313

314314
SecurityDistributionFlags_t* FileSecurityDb::get_entry_handle_by_index(uint8_t index) {
315-
if (index < MAX_ENTRIES) {
315+
if (index < BLE_SECURITY_DATABASE_MAX_ENTRIES) {
316316
return &_entries[index].flags;
317317
} else {
318318
return NULL;

0 commit comments

Comments
 (0)