Config Manager API Reference

This section documents the Configuration Manager API.

Overview

The Nexus Config Manager provides a flexible configuration storage system with support for multiple data types and storage backends (RAM, Flash). It’s designed for embedded systems requiring persistent configuration management.

Usage Examples

Basic Configuration

#include "config/config.h"

/* Initialize config manager */
config_init();

/* Set configuration values */
int32_t value = 42;
config_set_int32("system.timeout", value);

config_set_string("system.name", "MyDevice");

bool enabled = true;
config_set_bool("feature.enabled", enabled);

/* Get configuration values */
int32_t timeout;
if (config_get_int32("system.timeout", &timeout) == CONFIG_OK) {
    /* Use timeout value */
}

Namespaces

#include "config/config.h"

/* Create namespace */
config_namespace_create("network");

/* Set values in namespace */
config_set_string("network.ip", "192.168.1.100");
config_set_int32("network.port", 8080);

/* Iterate namespace */
config_namespace_iterate("network", my_callback, user_data);

Flash Backend

#include "config/config.h"
#include "config/config_backend.h"

/* Initialize with Flash backend */
config_backend* flash_backend = config_flash_backend_create();
config_set_backend(flash_backend);

/* Configuration is now persisted to Flash */
config_set_int32("system.boot_count", boot_count);

/* Commit changes to Flash */
config_commit();

Import/Export

#include "config/config.h"

/* Export configuration to JSON */
char buffer[1024];
size_t size = sizeof(buffer);
config_export_json(buffer, &size);

/* Import configuration from JSON */
config_import_json(json_string, strlen(json_string));

Thread Safety

The Config Manager is thread-safe when using the Flash backend with proper locking. The RAM backend requires external synchronization for multi-threaded access.

  • Flash backend: Thread-safe with internal locking

  • RAM backend: Not thread-safe, requires external mutex

Config Core

typedef struct config_namespace *config_ns_handle_t

Namespace handle type.

config_status_t config_open_namespace(const char *name, config_ns_handle_t *handle)

Open a namespace.

Parameters:
  • name[in] Namespace name

  • handle[out] Pointer to store the namespace handle

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_close_namespace(config_ns_handle_t handle)

Close a namespace.

Parameters:

handle[in] Namespace handle

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_erase_namespace(const char *name)

Erase all keys in a namespace.

Parameters:

name[in] Namespace name

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_set_i32(config_ns_handle_t ns, const char *key, int32_t value)

Set a 32-bit signed integer in namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_get_i32(config_ns_handle_t ns, const char *key, int32_t *value, int32_t default_val)

Get a 32-bit signed integer from namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_set_u32(config_ns_handle_t ns, const char *key, uint32_t value)

Set a 32-bit unsigned integer in namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_get_u32(config_ns_handle_t ns, const char *key, uint32_t *value, uint32_t default_val)

Get a 32-bit unsigned integer from namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_set_str(config_ns_handle_t ns, const char *key, const char *value)

Set a string in namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[in] String value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_get_str(config_ns_handle_t ns, const char *key, char *buffer, size_t buf_size)

Get a string from namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • buffer[out] Buffer to store the string

  • buf_size[in] Size of the buffer

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_set_bool(config_ns_handle_t ns, const char *key, bool value)

Set a boolean in namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[in] Boolean value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_get_bool(config_ns_handle_t ns, const char *key, bool *value, bool default_val)

Get a boolean from namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_exists(config_ns_handle_t ns, const char *key, bool *exists)

Check if a key exists in namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

  • exists[out] Pointer to store the result

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_delete(config_ns_handle_t ns, const char *key)

Delete a key from namespace.

Parameters:
  • ns[in] Namespace handle

  • key[in] Configuration key

Returns:

CONFIG_OK on success, error code otherwise

typedef void (*config_change_cb_t)(const char *key, config_type_t type, const void *old_value, const void *new_value, void *user_data)

Configuration change callback function type.

Param key:

[in] Key that changed

Param type:

[in] Value type

Param old_value:

[in] Previous value (may be NULL)

Param new_value:

[in] New value

Param user_data:

[in] User-provided context

typedef struct config_callback *config_cb_handle_t

Callback handle type.

config_status_t config_register_callback(const char *key, config_change_cb_t callback, void *user_data, config_cb_handle_t *handle)

Register a callback for a specific key.

Parameters:
  • key[in] Configuration key to watch

  • callback[in] Callback function

  • user_data[in] User-provided context

  • handle[out] Pointer to store the callback handle

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_register_wildcard_callback(config_change_cb_t callback, void *user_data, config_cb_handle_t *handle)

Register a wildcard callback for all key changes.

Parameters:
  • callback[in] Callback function

  • user_data[in] User-provided context

  • handle[out] Pointer to store the callback handle

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_unregister_callback(config_cb_handle_t handle)

Unregister a callback.

Parameters:

handle[in] Callback handle

Returns:

CONFIG_OK on success, error code otherwise

typedef bool (*config_iterate_cb_t)(const config_entry_info_t *info, void *user_data)

Iteration callback function type.

Param info:

[in] Entry information

Param user_data:

[in] User-provided context

Return:

true to continue iteration, false to stop

config_status_t config_exists(const char *key, bool *exists)

Check if a key exists.

Parameters:
  • key[in] Configuration key

  • exists[out] Pointer to store the result

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_type(const char *key, config_type_t *type)

Get the type of a stored value.

Parameters:
  • key[in] Configuration key

  • type[out] Pointer to store the type

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_delete(const char *key)

Delete a configuration key.

Parameters:

key[in] Configuration key

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_count(size_t *count)

Get the number of stored keys.

Parameters:

count[out] Pointer to store the count

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_iterate(config_iterate_cb_t callback, void *user_data)

Iterate over all configuration entries.

Parameters:
  • callback[in] Iteration callback

  • user_data[in] User-provided context

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_ns_iterate(config_ns_handle_t ns, config_iterate_cb_t callback, void *user_data)

Iterate over entries in a namespace.

Parameters:
  • ns[in] Namespace handle

  • callback[in] Iteration callback

  • user_data[in] User-provided context

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_init(const config_manager_config_t *config)

Initialize the Config Manager.

Parameters:

config[in] Configuration structure, or NULL for defaults

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_deinit(void)

Deinitialize the Config Manager.

Note

Releases all resources

Returns:

CONFIG_OK on success, error code otherwise

bool config_is_initialized(void)

Check if Config Manager is initialized.

Returns:

true if initialized, false otherwise

config_status_t config_set_backend(const config_backend_t *backend)

Set the storage backend.

Parameters:

backend[in] Pointer to backend structure

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_commit(void)

Commit pending changes to storage.

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_load(void)

Load configurations from storage.

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_i32(const char *key, int32_t value)

Set a 32-bit signed integer value.

Parameters:
  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_i32(const char *key, int32_t *value, int32_t default_val)

Get a 32-bit signed integer value.

Parameters:
  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_u32(const char *key, uint32_t value)

Set a 32-bit unsigned integer value.

Parameters:
  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_u32(const char *key, uint32_t *value, uint32_t default_val)

Get a 32-bit unsigned integer value.

Parameters:
  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_i64(const char *key, int64_t value)

Set a 64-bit signed integer value.

Parameters:
  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_i64(const char *key, int64_t *value, int64_t default_val)

Get a 64-bit signed integer value.

Parameters:
  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_float(const char *key, float value)

Set a float value.

Parameters:
  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_float(const char *key, float *value, float default_val)

Get a float value.

Parameters:
  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_bool(const char *key, bool value)

Set a boolean value.

Parameters:
  • key[in] Configuration key

  • value[in] Value to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_bool(const char *key, bool *value, bool default_val)

Get a boolean value.

Parameters:
  • key[in] Configuration key

  • value[out] Pointer to store the value

  • default_val[in] Default value if key not found

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_str(const char *key, const char *value)

Set a string value.

Parameters:
  • key[in] Configuration key

  • value[in] Null-terminated string to store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_str(const char *key, char *buffer, size_t buf_size)

Get a string value.

Parameters:
  • key[in] Configuration key

  • buffer[out] Buffer to store the string

  • buf_size[in] Size of the buffer

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_str_len(const char *key, size_t *len)

Get the length of a stored string.

Parameters:
  • key[in] Configuration key

  • len[out] Pointer to store the length (excluding null terminator)

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_blob(const char *key, const void *data, size_t size)

Set a binary blob value.

Parameters:
  • key[in] Configuration key

  • data[in] Binary data to store

  • size[in] Size of the data

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_blob(const char *key, void *buffer, size_t buf_size, size_t *actual_size)

Get a binary blob value.

Parameters:
  • key[in] Configuration key

  • buffer[out] Buffer to store the data

  • buf_size[in] Size of the buffer

  • actual_size[out] Actual size of the data (optional, can be NULL)

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_blob_len(const char *key, size_t *len)

Get the size of a stored blob.

Parameters:
  • key[in] Configuration key

  • len[out] Pointer to store the size

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_default_i32(const char *key, int32_t value)

Set default value for a 32-bit signed integer.

Parameters:
  • key[in] Configuration key

  • value[in] Default value

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_default_u32(const char *key, uint32_t value)

Set default value for a 32-bit unsigned integer.

Parameters:
  • key[in] Configuration key

  • value[in] Default value

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_default_i64(const char *key, int64_t value)

Set default value for a 64-bit signed integer.

Parameters:
  • key[in] Configuration key

  • value[in] Default value

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_default_float(const char *key, float value)

Set default value for a float.

Parameters:
  • key[in] Configuration key

  • value[in] Default value

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_default_bool(const char *key, bool value)

Set default value for a boolean.

Parameters:
  • key[in] Configuration key

  • value[in] Default value

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_default_str(const char *key, const char *value)

Set default value for a string.

Parameters:
  • key[in] Configuration key

  • value[in] Default string value

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_reset_to_default(const char *key)

Reset a key to its default value.

Parameters:

key[in] Configuration key

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_reset_all_to_defaults(void)

Reset all keys to their default values.

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_register_defaults(const config_default_t *defaults, size_t count)

Register multiple default values.

Parameters:
  • defaults[in] Array of default value definitions

  • count[in] Number of defaults

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_export_size(config_format_t format, config_export_flags_t flags, size_t *size)

Get the required buffer size for export.

Parameters:
  • format[in] Export format

  • flags[in] Export flags

  • size[out] Pointer to store the required size

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_export(config_format_t format, config_export_flags_t flags, void *buffer, size_t buf_size, size_t *actual_size)

Export all configurations.

Parameters:
  • format[in] Export format

  • flags[in] Export flags

  • buffer[out] Buffer to store exported data

  • buf_size[in] Size of the buffer

  • actual_size[out] Actual size of exported data

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_export_namespace(const char *ns_name, config_format_t format, config_export_flags_t flags, void *buffer, size_t buf_size, size_t *actual_size)

Export configurations from a specific namespace.

Parameters:
  • ns_name[in] Namespace name

  • format[in] Export format

  • flags[in] Export flags

  • buffer[out] Buffer to store exported data

  • buf_size[in] Size of the buffer

  • actual_size[out] Actual size of exported data

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_import(config_format_t format, config_import_flags_t flags, const void *data, size_t size)

Import configurations.

Parameters:
  • format[in] Import format

  • flags[in] Import flags

  • data[in] Data to import

  • size[in] Size of the data

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_import_namespace(const char *ns_name, config_format_t format, config_import_flags_t flags, const void *data, size_t size)

Import configurations to a specific namespace.

Parameters:
  • ns_name[in] Namespace name

  • format[in] Import format

  • flags[in] Import flags

  • data[in] Data to import

  • size[in] Size of the data

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_encryption_key(const uint8_t *key, size_t key_len, config_crypto_algo_t algo)

Set the encryption key.

Parameters:
  • key[in] Encryption key

  • key_len[in] Key length in bytes

  • algo[in] Encryption algorithm

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_clear_encryption_key(void)

Clear the encryption key.

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_str_encrypted(const char *key, const char *value)

Set an encrypted string value.

Parameters:
  • key[in] Configuration key

  • value[in] String value to encrypt and store

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_set_blob_encrypted(const char *key, const void *data, size_t size)

Set an encrypted blob value.

Parameters:
  • key[in] Configuration key

  • data[in] Data to encrypt and store

  • size[in] Size of the data

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_is_encrypted(const char *key, bool *encrypted)

Check if a key is encrypted.

Parameters:
  • key[in] Configuration key

  • encrypted[out] Pointer to store the result

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_rotate_encryption_key(const uint8_t *new_key, size_t key_len, config_crypto_algo_t algo)

Rotate the encryption key.

Note

Re-encrypts all encrypted keys with the new key

Parameters:
  • new_key[in] New encryption key

  • key_len[in] Key length in bytes

  • algo[in] Encryption algorithm

Returns:

CONFIG_OK on success, error code otherwise

config_status_t config_get_last_error(void)

Get the last error code.

Returns:

Last error code

const char *config_error_to_str(config_status_t status)

Convert error code to string.

Parameters:

status[in] Error code

Returns:

Error string

CONFIG_MANAGER_CONFIG_DEFAULT

Default configuration initializer.

struct config_manager_config_t
#include <config.h>

Config Manager configuration structure.

Public Members

uint16_t max_keys

Maximum key count (32-256)

uint8_t max_key_len

Maximum key length (16-64)

uint16_t max_value_size

Maximum value size (64-1024)

uint8_t max_namespaces

Maximum namespace count

uint8_t max_callbacks

Maximum callback count

bool auto_commit

Auto-commit mode

struct config_default_t
#include <config.h>

Default value definition structure.

Public Members

const char *key

Configuration key

config_type_t type

Value type

int32_t i32_val

32-bit signed integer

uint32_t u32_val

32-bit unsigned integer

int64_t i64_val

64-bit signed integer

float float_val

Float value

bool bool_val

Boolean value

const char *str_val

String value

union config_default_t value

Default value

struct config_entry_info_t
#include <config.h>

Configuration entry information.

Public Members

char key[32]

Configuration key

config_type_t type

Value type

uint16_t value_size

Value size in bytes

uint8_t flags

Entry flags

Config Definitions

CONFIG_DEFAULT_MAX_KEYS

Default configuration values.

CONFIG_DEFAULT_MAX_KEY_LEN
CONFIG_DEFAULT_MAX_VALUE_SIZE
CONFIG_DEFAULT_MAX_NAMESPACES
CONFIG_DEFAULT_MAX_CALLBACKS
CONFIG_DEFAULT_MAX_DEFAULTS
CONFIG_MAX_NS_NAME_LEN
CONFIG_MIN_MAX_KEYS

Configuration limits.

CONFIG_MAX_MAX_KEYS
CONFIG_MIN_MAX_KEY_LEN
CONFIG_MAX_MAX_KEY_LEN
CONFIG_MIN_MAX_VALUE_SIZE
CONFIG_MAX_MAX_VALUE_SIZE
enum config_status_t

Config Manager status codes.

Values:

enumerator CONFIG_OK

Operation successful

enumerator CONFIG_ERROR

Generic error

enumerator CONFIG_ERROR_INVALID_PARAM

Invalid parameter

enumerator CONFIG_ERROR_NOT_INIT

Not initialized

enumerator CONFIG_ERROR_ALREADY_INIT

Already initialized

enumerator CONFIG_ERROR_NO_MEMORY

Out of memory

enumerator CONFIG_ERROR_NOT_FOUND

Key not found

enumerator CONFIG_ERROR_ALREADY_EXISTS

Key already exists

enumerator CONFIG_ERROR_TYPE_MISMATCH

Type mismatch

enumerator CONFIG_ERROR_KEY_TOO_LONG

Key name too long

enumerator CONFIG_ERROR_VALUE_TOO_LARGE

Value size too large

enumerator CONFIG_ERROR_BUFFER_TOO_SMALL

Buffer too small

enumerator CONFIG_ERROR_NO_SPACE

Storage space full

enumerator CONFIG_ERROR_NVS_READ

NVS read failure

enumerator CONFIG_ERROR_NVS_WRITE

NVS write failure

enumerator CONFIG_ERROR_INVALID_FORMAT

Invalid format

enumerator CONFIG_ERROR_NO_ENCRYPTION_KEY

Encryption key not set

enumerator CONFIG_ERROR_CRYPTO_FAILED

Encryption/decryption failed

enumerator CONFIG_ERROR_NO_BACKEND

Backend not set

enum config_type_t

Config data types.

Values:

enumerator CONFIG_TYPE_I32

32-bit signed integer

enumerator CONFIG_TYPE_U32

32-bit unsigned integer

enumerator CONFIG_TYPE_I64

64-bit signed integer

enumerator CONFIG_TYPE_FLOAT

Single precision float

enumerator CONFIG_TYPE_BOOL

Boolean

enumerator CONFIG_TYPE_STRING

Null-terminated string

enumerator CONFIG_TYPE_BLOB

Binary data

enum config_flags_t

Config entry flags.

Values:

enumerator CONFIG_FLAG_NONE

No flags

enumerator CONFIG_FLAG_ENCRYPTED

Value is encrypted

enumerator CONFIG_FLAG_READONLY

Read-only configuration

enumerator CONFIG_FLAG_PERSISTENT

Requires persistence

enum config_format_t

Export format types.

Values:

enumerator CONFIG_FORMAT_JSON

JSON format

enumerator CONFIG_FORMAT_BINARY

Compact binary format

enum config_export_flags_t

Export flags.

Values:

enumerator CONFIG_EXPORT_FLAG_NONE

No flags

enumerator CONFIG_EXPORT_FLAG_DECRYPT

Decrypt values on export

enumerator CONFIG_EXPORT_FLAG_PRETTY

Pretty print JSON

enum config_import_flags_t

Import flags.

Values:

enumerator CONFIG_IMPORT_FLAG_NONE

No flags

enumerator CONFIG_IMPORT_FLAG_CLEAR

Clear existing before import

enumerator CONFIG_IMPORT_FLAG_SKIP_ERRORS

Skip errors and continue

enum config_crypto_algo_t

Encryption algorithms.

Values:

enumerator CONFIG_CRYPTO_AES128

AES-128-CBC

enumerator CONFIG_CRYPTO_AES256

AES-256-CBC

CONFIG_IS_OK(status)

Check if status is OK.

Parameters:
  • status[in] Status to check

Returns:

true if OK, false otherwise

CONFIG_IS_ERROR(status)

Check if status is error.

Parameters:
  • status[in] Status to check

Returns:

true if error, false otherwise

CONFIG_RETURN_IF_ERROR(status)

Return if status is error.

Parameters:
  • status[in] Status to check

CONFIG_UNUSED(x)

Unused parameter macro.

Parameters:
  • x[in] Parameter to mark as unused

Backend Interface

typedef struct config_backend config_backend_t

Forward declaration of backend structure.

typedef config_status_t (*config_backend_init_fn)(void *ctx)

Backend initialization function type.

Param ctx:

[in] Backend context

Return:

CONFIG_OK on success, error code otherwise

typedef config_status_t (*config_backend_deinit_fn)(void *ctx)

Backend deinitialization function type.

Param ctx:

[in] Backend context

Return:

CONFIG_OK on success, error code otherwise

typedef config_status_t (*config_backend_read_fn)(void *ctx, const char *key, void *data, size_t *size)

Backend read function type.

Param ctx:

[in] Backend context

Param key:

[in] Key to read

Param data:

[out] Buffer to store data

Param size:

[inout] Input: buffer size, Output: actual data size

Return:

CONFIG_OK on success, error code otherwise

typedef config_status_t (*config_backend_write_fn)(void *ctx, const char *key, const void *data, size_t size)

Backend write function type.

Param ctx:

[in] Backend context

Param key:

[in] Key to write

Param data:

[in] Data to write

Param size:

[in] Data size

Return:

CONFIG_OK on success, error code otherwise

typedef config_status_t (*config_backend_erase_fn)(void *ctx, const char *key)

Backend erase function type.

Param ctx:

[in] Backend context

Param key:

[in] Key to erase

Return:

CONFIG_OK on success, error code otherwise

typedef config_status_t (*config_backend_erase_all_fn)(void *ctx)

Backend erase all function type.

Param ctx:

[in] Backend context

Return:

CONFIG_OK on success, error code otherwise

typedef config_status_t (*config_backend_commit_fn)(void *ctx)

Backend commit function type.

Param ctx:

[in] Backend context

Return:

CONFIG_OK on success, error code otherwise

struct config_backend
#include <config_backend.h>

Config backend structure.

Defines the interface for config storage backends. Each backend must implement at least read, write, and erase functions.

Public Members

const char *name

Backend name (must be unique)

config_backend_init_fn init

Initialization function (optional)

config_backend_deinit_fn deinit

Deinitialization function (optional)

config_backend_read_fn read

Read function (required)

config_backend_write_fn write

Write function (required)

config_backend_erase_fn erase

Erase function (required)

config_backend_erase_all_fn erase_all

Erase all function (optional)

config_backend_commit_fn commit

Commit function (optional)

void *ctx

Backend-specific context

RAM Backend

const config_backend_t *config_backend_ram_get(void)

Get the RAM backend instance.

Note

RAM backend is volatile - data is lost on reset

Returns:

Pointer to RAM backend structure

Flash Backend

const config_backend_t *config_backend_flash_get(void)

Get the Flash backend instance.

Note

Flash backend provides persistent storage

Returns:

Pointer to Flash backend structure

See Also