mirror of https://github.com/ARMmbed/mbed-os.git
ble security db complete sync implementation
parent
7b4d1d59f1
commit
c9d0ff8674
|
@ -361,6 +361,22 @@ void FileSecurityDb::restore()
|
|||
|
||||
void FileSecurityDb::sync(entry_handle_t db_handle)
|
||||
{
|
||||
/* if no entry is selected we will sync all entries */
|
||||
if (db_handle == invalid_entry_handle) {
|
||||
/* only write the connected devices as others are already written */
|
||||
for (size_t i = 0; i < get_entry_count(); i++) {
|
||||
entry_handle_t db_handle = get_entry_handle_by_index(i);
|
||||
SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle);
|
||||
|
||||
if (flags && flags->connected) {
|
||||
sync(db_handle);
|
||||
}
|
||||
}
|
||||
/* global sync triggers a flush */
|
||||
fflush(_db_file);
|
||||
return;
|
||||
}
|
||||
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
|
@ -333,6 +333,22 @@ void KVStoreSecurityDb::restore()
|
|||
|
||||
void KVStoreSecurityDb::sync(entry_handle_t db_handle)
|
||||
{
|
||||
/* storage synchronisation is handled by KVStore itself, no explicit flushing */
|
||||
|
||||
/* if no entry is selected we will sync all entries */
|
||||
if (db_handle == invalid_entry_handle) {
|
||||
/* only write the connected devices as others are already written */
|
||||
for (size_t i = 0; i < get_entry_count(); i++) {
|
||||
entry_handle_t db_handle = get_entry_handle_by_index(i);
|
||||
SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle);
|
||||
|
||||
if (flags && flags->connected) {
|
||||
sync(db_handle);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
|
@ -522,7 +522,11 @@ public:
|
|||
virtual void restore();
|
||||
|
||||
/**
|
||||
* Flush all values which might be stored in memory into NVM.
|
||||
* Write all values and attempt to sync persistent storage. Passing in an optional valid
|
||||
* db_handle will only write the given entry and not attempt to flush buffers.
|
||||
*
|
||||
* @param db_handle database entry to write. If invalid all entries are written and
|
||||
* persistent storage attempts to sync (flush buffers).
|
||||
*/
|
||||
virtual void sync(entry_handle_t db_handle = invalid_entry_handle);
|
||||
|
||||
|
|
Loading…
Reference in New Issue