NVM3 Access in NCP mode#
NVM3 Access in NCP mode.
Provide convenient methods for applications in NCP mode to manage user data in the Bluetooth region of NVM3. User data stored in NVM3 is persistent across reset and power cycling of the device. Because Bluetooth bondings are also stored in NVM3, the space available for user data also depends on the number of bondings the device has at the time.
It is recommended to use NVM3 APIs directly whenever it is possible, especially for applications in SoC mode.
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".
Modules#
Functions#
Macros#
Function Documentation#
sl_bt_nvm_save#
sl_status_t sl_bt_nvm_save (uint16_t key, size_t value_len, const uint8_t * value)
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | key | The NVM3 key in the Bluetooth region |
size_t | [in] | value_len | Length of data in |
const uint8_t * | [in] | value | Value to store into the NVM3 key |
Store a value into the specified NVM3 key in the Bluetooth region. Allowed keys are in the range from SL_BT_NVM_KEY_RANGE_USER_MIN (0x4000) to SL_BT_NVM_KEY_RANGE_USER_MAX (0x5FFF). The maximum value length is the lesser of NVM3_DEFAULT_MAX_OBJECT_SIZE configuration in the application and 253 bytes which is the maximum amount this command can accept.
Returns
SL_STATUS_OK if successful. Error code otherwise.
sl_bt_nvm_load#
sl_status_t sl_bt_nvm_load (uint16_t key, size_t max_value_size, size_t * value_len, uint8_t * value)
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | key | The NVM3 key in the Bluetooth region |
size_t | [in] | max_value_size | Size of output buffer passed in |
size_t * | [out] | value_len | On return, set to the length of output data written to |
uint8_t * | [out] | value | The value of the NVM3 key |
Retrieve the value of the specified NVM3 key in the Bluetooth region. Allowed keys are in the range from SL_BT_NVM_KEY_RANGE_USER_MIN (0x4000) to SL_BT_NVM_KEY_RANGE_USER_MAX (0x5FFF).
Returns
SL_STATUS_OK if successful. Error code otherwise.
sl_bt_nvm_erase#
sl_status_t sl_bt_nvm_erase (uint16_t key)
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | key | The NVM3 key to delete |
Delete a single NVM3 key and its value from the Bluetooth region. Allowed keys are in the range from SL_BT_NVM_KEY_RANGE_USER_MIN (0x4000) to SL_BT_NVM_KEY_RANGE_USER_MAX (0x5FFF).
Returns
SL_STATUS_OK if successful. Error code otherwise.
sl_bt_nvm_erase_all#
sl_status_t sl_bt_nvm_erase_all ()
Delete all NVMs keys and their corresponding values in the Bluetooth region of NVM3. All bluetooth bondings and associated data in NVM3 are deleted too.
Returns
SL_STATUS_OK if successful. Error code otherwise.