BLE: Added call to delete the security database object upon SM reset. #11831
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (required)
This patch deletes the security database object upon calling
SecurityManager::reset()
.Resolves #11768 (for now...)
Summary of change (What the change is for and why)
Previously, there was no normal method to have the security manager close the security database file (if using a file-based security database, as the Mbed SM does if not using a volatile, RAM-based database).
In some cases, this prevented the file from ever being fully flushed to flash if using a block device or filesystem that buffers write operations. The result of this was that for some applications/targets there was no official way to get BLE bonding persistence to work.
This fix allows the file to be closed by the OS and flushed to disk upon calling
SecurityManager::reset()
.Users should note that if calling
SecurityManager::reset()
to flush the database file to flash, they will also have to reinitialize the SecurityManager (set up an event handler, configure settings, etc).Documentation (Details of any document updates required)
See issue #11768 for details.
Pull request type (required)
Test results (required)
I identified the problem and fix through the following method:
Tested on target:
EP_AGORA
but should be same for all nRF52840-based targets.1.) Upon startup, application initializes
SPIFBlockDevice
and FATFileSystem (also used LittleFileSystem with same results)2.) BLE was initialized and SecurityManager configured to write to a file --
/fs/sec.dat
3.) nRFConnect and an nRF52840_DK were used to connect and pair/bond with the target -- triggering the SecurityManager to store keys related to the connection
4.) Upon disconnection, a USBMSD object was created to present the FATFileSystem as a mass storage device to my laptop
5.) While the file existed in both cases, when I inspected the size and content of the file I found that with the code currently in master the file was never written to -- size of 0 bytes. With this fix, the file is correctly written to and is 568 or so bytes in size.
Reviewers (optional)
@paul-szczepanek-arm
Release Notes (required for feature/major PRs)
Summary of changes
Impact of changes
Migration actions required