Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
settings.h File Reference
#include <sys/types.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/slist.h>
#include <zephyr/sys/iterable_sections.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  settings_handler
 Config handlers for subtree implement a set of handler functions. More...
 
struct  settings_handler_static
 Config handlers without the node element, used for static handlers. More...
 
struct  settings_store
 Backend handler node for storage handling. More...
 
struct  settings_load_arg
 Arguments for data loading. More...
 
struct  settings_store_itf
 Backend handler functions. More...
 

Macros

#define SETTINGS_MAX_DIR_DEPTH   8 /* max depth of settings tree */
 
#define SETTINGS_MAX_NAME_LEN   (8 * SETTINGS_MAX_DIR_DEPTH)
 
#define SETTINGS_MAX_VAL_LEN   256
 
#define SETTINGS_NAME_SEPARATOR   '/'
 
#define SETTINGS_NAME_END   '='
 
#define SETTINGS_EXTRA_LEN   ((SETTINGS_MAX_DIR_DEPTH - 1) + 2)
 
#define SETTINGS_STATIC_HANDLER_DEFINE(_hname, _tree, _get, _set, _commit, _export)
 Define a static handler for settings items.
 

Typedefs

typedef ssize_t(* settings_read_cb) (void *cb_arg, void *data, size_t len)
 Function used to read the data from the settings storage in h_set handler implementations.
 
typedef int(* settings_load_direct_cb) (const char *key, size_t len, settings_read_cb read_cb, void *cb_arg, void *param)
 Callback function used for direct loading.
 

Functions

int settings_subsys_init (void)
 Initialization of settings and backend.
 
int settings_register (struct settings_handler *cf)
 Register a handler for settings items stored in RAM.
 
int settings_load (void)
 Load serialized items from registered persistence sources.
 
int settings_load_subtree (const char *subtree)
 Load limited set of serialized items from registered persistence sources.
 
int settings_load_subtree_direct (const char *subtree, settings_load_direct_cb cb, void *param)
 Load limited set of serialized items using given callback.
 
int settings_save (void)
 Save currently running serialized items.
 
int settings_save_subtree (const char *subtree)
 Save limited set of currently running serialized items.
 
int settings_save_one (const char *name, const void *value, size_t val_len)
 Write a single serialized value to persisted storage (if it has changed value).
 
int settings_delete (const char *name)
 Delete a single serialized in persisted storage.
 
int settings_commit (void)
 Call commit for all settings handler.
 
int settings_commit_subtree (const char *subtree)
 Call commit for settings handler that belong to subtree.
 
void settings_src_register (struct settings_store *cs)
 Register a backend handler acting as source.
 
void settings_dst_register (struct settings_store *cs)
 Register a backend handler acting as destination.
 
struct settings_handler_staticsettings_parse_and_lookup (const char *name, const char **next)
 Parses a key to an array of elements and locate corresponding module handler.
 
int settings_call_set_handler (const char *name, size_t len, settings_read_cb read_cb, void *read_cb_arg, const struct settings_load_arg *load_arg)
 Calls settings handler.
 
int settings_name_steq (const char *name, const char *key, const char **next)
 Compares the start of name with a key.
 
int settings_name_next (const char *name, const char **next)
 determine the number of characters before the first separator
 
int settings_runtime_set (const char *name, const void *data, size_t len)
 Set a value with a specific key to a module handler.
 
int settings_runtime_get (const char *name, void *data, size_t len)
 Get a value corresponding to a key from a module handler.
 
int settings_runtime_commit (const char *name)
 Apply settings in a module handler.
 
int settings_storage_get (void **storage)
 Get the storage instance used by zephyr.
 

Function Documentation

◆ settings_storage_get()

int settings_storage_get ( void **  storage)

Get the storage instance used by zephyr.

The type of storage object instance depends on the settings backend used. It might pointer to: struct nvs_fs, struct fcb or string witch file name depends on settings backend type used.

Return values
Pointerto which reference to the storage object can be stored.
0on success, negative error code on failure.