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#

Defined key ranges

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

Macros#

#define
sl_bt_cmd_nvm_save_id 0x020d0020
#define
sl_bt_cmd_nvm_load_id 0x030d0020
#define
sl_bt_cmd_nvm_erase_id 0x040d0020
#define
sl_bt_cmd_nvm_erase_all_id 0x010d0020
#define
sl_bt_rsp_nvm_save_id 0x020d0020
#define
sl_bt_rsp_nvm_load_id 0x030d0020
#define
sl_bt_rsp_nvm_erase_id 0x040d0020
#define
sl_bt_rsp_nvm_erase_all_id 0x010d0020

Function Documentation#

sl_bt_nvm_save#

sl_status_t sl_bt_nvm_save (uint16_t key, size_t value_len, const uint8_t * value)
Parameters
TypeDirectionArgument NameDescription
uint16_t[in]key

The NVM3 key in the Bluetooth region

size_t[in]value_len

Length of data in value

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)
Parameters
TypeDirectionArgument NameDescription
uint16_t[in]key

The NVM3 key in the Bluetooth region

size_t[in]max_value_size

Size of output buffer passed in value

size_t *[out]value_len

On return, set to the length of output data written to value

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)
Parameters
TypeDirectionArgument NameDescription
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.