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.
-
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
-
const char *keyΒΆ
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
-
enumerator CONFIG_OKΒΆ
-
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
-
enumerator CONFIG_TYPE_I32ΒΆ
-
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
-
enumerator CONFIG_FLAG_NONEΒΆ
-
enum config_format_tΒΆ
Export format types.
Values:
-
enumerator CONFIG_FORMAT_JSONΒΆ
JSON format
-
enumerator CONFIG_FORMAT_BINARYΒΆ
Compact binary format
-
enumerator CONFIG_FORMAT_JSONΒΆ
-
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
-
enumerator CONFIG_EXPORT_FLAG_NONEΒΆ
-
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
-
enumerator CONFIG_IMPORT_FLAG_NONEΒΆ
-
enum config_crypto_algo_tΒΆ
Encryption algorithms.
Values:
-
enumerator CONFIG_CRYPTO_AES128ΒΆ
AES-128-CBC
-
enumerator CONFIG_CRYPTO_AES256ΒΆ
AES-256-CBC
-
enumerator CONFIG_CRYPTO_AES128ΒΆ
-
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
-
const char *nameΒΆ
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