diff --git a/features/FEATURE_BLE/ble/pal/MemorySecurityDB.h b/features/FEATURE_BLE/ble/pal/MemorySecurityDB.h index c6c627b66b..afb63f418d 100644 --- a/features/FEATURE_BLE/ble/pal/MemorySecurityDB.h +++ b/features/FEATURE_BLE/ble/pal/MemorySecurityDB.h @@ -187,6 +187,22 @@ public: } } + virtual void get_identity_list( + IdentitylistDbCb_t cb, + ArrayView& entries + ) { + size_t count = 0; + for (size_t i = 0; i < MAX_ENTRIES && count < entries.size(); ++i) { + entry_t& e = _entries[i]; + + if (e.state == ENTRY_WRITTEN && e.flags.irk_stored) { + entries[count] = &e.peer_identity; + ++count; + } + } + + cb(entries, count); + } /* set */ diff --git a/features/FEATURE_BLE/ble/pal/SecurityDb.h b/features/FEATURE_BLE/ble/pal/SecurityDb.h index 7c6e77637e..bc790ccfb1 100644 --- a/features/FEATURE_BLE/ble/pal/SecurityDb.h +++ b/features/FEATURE_BLE/ble/pal/SecurityDb.h @@ -107,6 +107,8 @@ public: SecurityEntryCsrkDbCb_t; typedef mbed::Callback SecurityEntryIdentityDbCb_t; + typedef mbed::Callback&, size_t count)> + IdentitylistDbCb_t; typedef mbed::Callback WhitelistDbCb_t; @@ -274,6 +276,20 @@ public: entry_handle_t db_entry ) = 0; + /** + * Asynchronously return the identity list stored in NVM through a callback. + * Function takes ownership of the memory. The identity list and the + * ownership will be returned in the callback. + * + * @param[in] cb callback that will receive the whitelist + * @param[in] identity_list preallocated identity_list that will be filled + * in. + */ + virtual void get_identity_list( + IdentitylistDbCb_t cb, + ArrayView& identity_list + ) = 0; + /** * Update peer signing key. *