Skip to content

Commit d3683c1

Browse files
committed
Merge pull request #1803 from petermm/fix-nvs-docs
Fix: nvs docs Programmers guide These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 1a4840d + f068122 commit d3683c1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

doc/src/programmers-guide.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,36 +1085,36 @@ storage, as the flash storage may degrade more rapidly with repeated writes to t
10851085
10861086
NVS entries are stored under a namespace and key, both of which are expressed as atoms. AtomVM uses the namespace `atomvm` for entries under its control. Applications may read from and write to the `atomvm` namespace, but they are strongly discouraged from doing so, except when explicitly stated otherwise.
10871087
1088-
To set a value in non-volatile storage, use the [`esp:nvs_set_binary/3`](./apidocs/erlang/eavmlib/esp.md#nvs_set_binary3) function, and specify a namespace, key, and value:
1088+
To set a value in non-volatile storage, use the [`esp:nvs_put_binary/3`](./apidocs/erlang/eavmlib/esp.md#nvs_put_binary3) function, and specify a namespace, key, and value:
10891089
10901090
```erlang
1091-
Namespace = <<"my-namespace">>,
1092-
Key = <<"my-key">>,
1093-
esp:set_binary(Namespace, Key, <<"some-value">>).
1091+
Namespace = my_namespace_atom,
1092+
Key = my_key_atom,
1093+
esp:nvs_put_binary(Namespace, Key, <<"some-value">>).
10941094
```
10951095
10961096
To retrieve a value in non-volatile storage, use the [`esp:nvs_get_binary/2`](./apidocs/erlang/eavmlib/esp.md#nvs_get_binary2) function, and specify a namespace and key. You can optionally specify a default value (of any desired type), if an entry does not exist in non-volatile storage:
10971097
10981098
```erlang
1099-
Value = esp:get_binary(Namespace, Key, <<"default-value">>).
1099+
Value = esp:nvs_get_binary(Namespace, Key, <<"default-value">>).
11001100
```
11011101
11021102
To delete an entry, use the [`esp:nvs_erase_key/2`](./apidocs/erlang/eavmlib/esp.md#nvs_erase_key2) function, and specify a namespace and key:
11031103
11041104
```erlang
1105-
ok = esp:erase_key(Namespace, Key).
1105+
ok = esp:nvs_erase_key(Namespace, Key).
11061106
```
11071107
11081108
You can delete all entries in a namespace via the [`esp:nvs_erase_all/1`](./apidocs/erlang/eavmlib/esp.md#nvs_erase_all1) function:
11091109
11101110
```erlang
1111-
ok = esp:erase_all(Namespace).
1111+
ok = esp:nvs_erase_all(Namespace).
11121112
```
11131113
11141114
Finally, you can delete all entries in all namespaces on the NVS partition via the [`esp:nvs_reformat/0`](./apidocs/erlang/eavmlib/esp.md#nvs_reformat0) function:
11151115
11161116
```erlang
1117-
ok = esp:reformat().
1117+
ok = esp:nvs_reformat().
11181118
```
11191119
11201120
Applications should use the `esp:nvs_reformat/0` function with caution, in case other applications are making using the non-volatile storage.

0 commit comments

Comments
 (0)