NVM#
NVM.
Modules |
Functions | |
sl_status_t | sl_bt_nvm_save (uint16_t key, size_t value_len, const uint8_t *value) |
sl_status_t | sl_bt_nvm_load (uint16_t key, size_t max_value_size, size_t *value_len, uint8_t *value) |
sl_status_t | sl_bt_nvm_erase (uint16_t key) |
sl_status_t | |
Detailed Description#
NVM.
Provide an interface to manage user data objects (key/value pairs) in the flash memory. User data stored within the flash memory is persistent across reset and power cycling of the device. Because Bluetooth bondings are also stored in the flash area, in addition to the flash storage size, the space available for user data also depends on the number of bondings the device has at the time.
On EFR32[B|M]G1x devices, either PS Store or NVM3 data storage driver can be used. PS Store is supported by the Bluetooth stack only. Using NVM3 is recommended if the device needs to support Dynamic Multiple Protocol (DMP). On EFR32[B|M]G2x devices, only NVM3 is supported. When NVM3 is used, applications can also use the NVM3 APIs directly.
In PS Store, the flash storage size is fixed at 2048 bytes. The maximum data object size associated to a key is 56 bytes. A Bluetooth bonding uses at maximum 138 bytes for secure connections and 174 bytes for legacy pairing.
In NVM3, the flash store size is configurable and the minimum is 3 flash pages. The maximum data object size is configurable up to 4096 bytes. A Bluetooth bonding uses maximum 110 bytes for secure connections and 138 bytes for legacy pairing. For more details, see AN1135 "Using Third Generation NonVolatile Memory (NVM3) Data Storage".
Function Documentation#
◆sl_bt_nvm_save()#
sl_status_t sl_bt_nvm_save | ( | uint16_t |
|
size_t |
| ||
const uint8_t * |
| ||
) |
Store a value into the specified NVM key. Allowed NVM keys are in range from 0x4000 to 0x407F. At most, 56 bytes user data can be stored in one NVM key. The error code 0x018a (command_too_long) is returned if the value data is more than 56 bytes.
Parameters
[in] |
| NVM key |
[in] |
| Length of data in |
[in] |
| Value to store into the specified NVM key |
ReturnsSL_STATUS_OK if successful. Error code otherwise.
◆sl_bt_nvm_load()#
sl_status_t sl_bt_nvm_load | ( | uint16_t |
|
size_t |
| ||
size_t * |
| ||
uint8_t * |
| ||
) |
Retrieve the value of the specified NVM key.
Parameters
[in] |
| NVM key of the value to be retrieved |
[in] |
| Size of output buffer passed in |
[out] |
| On return, set to the length of output data written to |
[out] |
| The returned value of the specified NVM key |
ReturnsSL_STATUS_OK if successful. Error code otherwise.
◆sl_bt_nvm_erase()#
sl_status_t sl_bt_nvm_erase | ( | uint16_t |
| ) |
Delete a single NVM key and its value from the persistent store.
Parameters
[in] |
| NVM key to delete |
ReturnsSL_STATUS_OK if successful. Error code otherwise.
◆sl_bt_nvm_erase_all()#
sl_status_t sl_bt_nvm_erase_all | ( | ) |
Delete all NVM keys and their corresponding values.
ReturnsSL_STATUS_OK if successful. Error code otherwise.