Config Manager API ReferenceΒΆ

This section documents the Configuration Manager API.

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