README.rst
1.. zephyr:code-sample:: settings
2 :name: Settings API
3 :relevant-api: settings settings_rt settings_name_proc
4
5 Load and save configuration values using the settings API.
6
7Overview
8********
9
10This is a simple application demonstrating use of the settings runtime
11configuration module. In this application some configuration values are loaded
12from persistent storage and exported to persistent storage using different
13settings method. The example shows how to implement module handlers, how to
14register them.
15
16Requirements
17************
18
19* A board with settings support, for instance: nrf52840dk/nrf52840
20* Or qemu_x86 target
21
22Building and Running
23********************
24
25This sample can be found under :zephyr_file:`samples/subsys/settings` in
26the Zephyr tree.
27
28The sample can be build for several platforms, the following commands build the
29application for the qemu_x86.
30
31.. zephyr-app-commands::
32 :zephyr-app: samples/subsys/settings
33 :host-os: unix
34 :board: qemu_x86
35 :goals: run
36 :compact:
37
38After running the image to the board the output on the console shows the
39settings manipulation messages.
40
41Sample Output
42=============
43
44.. code-block:: console
45
46 ***** Booting Zephyr OS build v2.1.0-rc1-123-g41091eb1d5e0 *****
47
48 *** Settings usage example ***
49
50 settings subsys initialization: OK.
51 subtree <alpha> handler registered: OK
52 subtree <alpha/beta> has static handler
53
54 ##############
55 # iteration 0
56 ##############
57
58 =================================================
59 basic load and save using registered handlers
60
61 load all key-value pairs using registered handlers
62 loading all settings under <beta> handler is done
63 loading all settings under <alpha> handler is done
64
65 save <alpha/beta/voltage> key directly: OK.
66
67 load <alpha/beta> key-value pairs using registered handlers
68 <alpha/beta/voltage> = -3025
69 loading all settings under <beta> handler is done
70
71 save all key-value pairs using registered handlers
72 export keys under <beta> handler
73 export keys under <alpha> handler
74
75 load all key-value pairs using registered handlers
76 export keys under <beta> handler
77 export keys under <alpha> handler
78
79 =================================================
80 loading subtree to destination provided by the caller
81
82 direct load: <alpha/length/2>
83 direct load: <alpha/length/1>
84 direct load: <alpha/length>
85 direct.length = 100
86 direct.length_1 = 41
87 direct.length_2 = 59
88
89 =================================================
90 Delete a key-value pair
91
92 immediate load: OK.
93 <alpha/length> value exist in the storage
94 delete <alpha/length>: OK.
95 Can't to load the <alpha/length> value as expected
96
97 =================================================
98 Service a key-value pair without dedicated handlers
99
100 <gamma> = 0 (default)
101 save <gamma> key directly: OK.
102 ...
103