diff --git a/features/FEATURE_BLE/ble/generic/FileSecurityDb.h b/features/FEATURE_BLE/ble/generic/FileSecurityDb.h index 4c57d67005..82361a7c4e 100644 --- a/features/FEATURE_BLE/ble/generic/FileSecurityDb.h +++ b/features/FEATURE_BLE/ble/generic/FileSecurityDb.h @@ -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(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)]; }; diff --git a/features/FEATURE_BLE/ble/generic/MemorySecurityDb.h b/features/FEATURE_BLE/ble/generic/MemorySecurityDb.h index 6ca9c3b3b0..6ae94ed01c 100644 --- a/features/FEATURE_BLE/ble/generic/MemorySecurityDb.h +++ b/features/FEATURE_BLE/ble/generic/MemorySecurityDb.h @@ -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(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 */ diff --git a/features/FEATURE_BLE/mbed_lib.json b/features/FEATURE_BLE/mbed_lib.json index efae862cad..64601cec01 100644 --- a/features/FEATURE_BLE/mbed_lib.json +++ b/features/FEATURE_BLE/mbed_lib.json @@ -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" } } } \ No newline at end of file diff --git a/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp b/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp index 4b0db269e0..8e4b226278 100644 --- a/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp +++ b/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp @@ -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;