diff --git a/features/FEATURE_BLE/ble/generic/FileSecurityDb.h b/features/FEATURE_BLE/ble/generic/FileSecurityDb.h index 2dcdb05843..700b8b427c 100644 --- a/features/FEATURE_BLE/ble/generic/FileSecurityDb.h +++ b/features/FEATURE_BLE/ble/generic/FileSecurityDb.h @@ -17,6 +17,8 @@ #ifndef GENERIC_FILE_SECURITY_DB_H_ #define GENERIC_FILE_SECURITY_DB_H_ +#if BLE_SECURITY_DATABASE_FILESYSTEM + #include "SecurityDb.h" #include @@ -167,4 +169,6 @@ private: } /* namespace pal */ } /* namespace ble */ +#endif // BLE_SECURITY_DATABASE_FILESYSTEM + #endif /*GENERIC_FILE_SECURITY_DB_H_*/ diff --git a/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp b/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp index abefb7f209..5d28f94d04 100644 --- a/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp +++ b/features/FEATURE_BLE/source/generic/FileSecurityDb.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#if BLE_SECURITY_DATABASE_FILESYSTEM + #include "FileSecurityDb.h" namespace ble { @@ -408,4 +410,7 @@ SecurityEntrySigning_t* FileSecurityDb::read_in_entry_peer_signing(entry_handle_ }; } /* namespace pal */ -} /* namespace ble */ \ No newline at end of file +} /* namespace ble */ + +#endif // BLE_SECURITY_DATABASE_FILESYSTEM + diff --git a/features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp b/features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp index e08a6f575c..673651e261 100644 --- a/features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp +++ b/features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp @@ -21,6 +21,7 @@ #include "ble/generic/GenericSecurityManager.h" #include "ble/generic/MemorySecurityDb.h" #include "ble/generic/FileSecurityDb.h" +#include "ble/generic/KVStoreSecurityDb.h" using ble::pal::advertising_peer_address_type_t; using ble::pal::AuthenticationMask; @@ -884,11 +885,19 @@ ble_error_t GenericSecurityManager::init_da ) { delete _db; +#if BLE_SECURITY_DATABASE_FILESYSTEM FILE* db_file = FileSecurityDb::open_db_file(db_path); if (db_file) { _db = new (std::nothrow) FileSecurityDb(db_file); - } else { + } else +#endif +#if BLE_SECURITY_DATABASE_KVSTORE + if (KVStoreSecurityDb::open_db()) { + _db = new (std::nothrow) KVStoreSecurityDb(); + } else +#endif + { _db = new (std::nothrow) MemorySecurityDb(); }