This is the documentation for the latest (main) development branch. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

NVS

Overview

After the application starts, perform the following 5 operations:

  1. String reading and writing

  2. Binary data reading and writing

  3. Floating point number reading and writing

  4. 8-bit integer reading and writing

  5. Use iterator to traverse all data

Requirements

  1. You need to configure COMPONENT_NVS_ENABLED to enable, and the default is enable

  2. There is an nvs partition in the partition table. By default, an nvs partition already exists in the partition table

Building and flashing

Sample location: examples/storage/nvs For operations such as compiling and burning, please refer to: [Quick Start] (../../../../get_started/index. html # build function)

Running result

Successfully running will output the following logs

D/dt              [0.000] add device iflash
D/ptb             [0.002] partition table base 0xe000
D/ft              [0.002] ft_0 base 0, ft_1 base 1000
D/ft              [0.002] ft init too
D/ft              [0.004] ft init 1
D/main            [0.004] boot reason 0
D/main            [0.004] heap size 272792(266.40KB)
D/main            [0.006] flash size 0x200000(2MB)
I/exam_nvs        [0.006] This example succeeds in running.
I/exam_nvs        [0.006] Read str:123456

I/exam_nvs        [0.008] Read blob:0x01,0x02,0x03,0x04,0x05

I/exam_nvs        [0.008] Read float=1.234500

I/exam_nvs        [0.008] Read I8=-120

I/exam_nvs        [0.010] Start iterator.
I/exam_nvs        [0.010] wm_sta_mac,len=6
I/exam_nvs        [0.010] wm_sap_mac,len=6
I/exam_nvs        [0.010] key3,len=8
I/exam_nvs        [0.012] key_str,len=7
I/exam_nvs        [0.012] key_blob,len=5
I/exam_nvs        [0.012] key_float,len=8
I/exam_nvs        [0.012] key_I8,len=1