Config Manager API¶
JSON Schema-driven configuration manager that stores individual configuration values in NVS using keys defined by config_schema.json. The component exposes type-safe getters/setters for string, int32, int16 and boolean values and provides bulk JSON import/export helpers used by the web UI. Key features:
Architecture: Thin wrapper around ESP-IDF NVS with no runtime validation. Validation is expected to be performed by the browser UI using the embedded JSON schema. Factory defaults are generated at build-time and written by an auto-generated helper. |
Lifecycle Functions¶
Initialize configuration manager by opening the NVS namespace “config”. If the namespace is uninitialized, factory defaults are written. Signature: esp_err_t config_init(void)
Parameters:
Returns:
Note Must be called once during system startup. Implements REQ_CFG_JSON_12. |
Reset all configuration to factory defaults by erasing the NVS namespace and writing generated defaults. Signature: esp_err_t config_factory_reset(void)
Parameters:
Returns:
Note Uses auto-generated factory write helper (see config_write_factory_defaults()). |
Commit pending NVS writes to flash. Useful after multiple _no_commit updates to batch flash writes. Signature: esp_err_t config_commit(void)
Parameters:
Returns:
Note Use to reduce flash wear when performing multiple updates. |
Auto-generated helper that writes factory default values to NVS. It is
generated at build-time from config_schema.json and should not be
called directly by applications; use Signature: void config_write_factory_defaults(void)
Parameters:
Returns:
Note Generated during build - reference only. |
String Parameter Access¶
Read a null-terminated string value from NVS into a provided buffer. Signature: esp_err_t config_get_string(const char* key, char* buffer, size_t buf_len)
Parameters:
Returns:
Note No runtime validation performed; the UI should enforce schema constraints. |
Write a null-terminated string value to NVS and commit immediately. Signature: esp_err_t config_set_string(const char* key, const char* value)
Parameters:
Returns:
|
Write a string to NVS without committing. Call Signature: esp_err_t config_set_string_no_commit(const char* key, const char* value)
Parameters:
Returns:
|
Integer Parameter Access¶
Read a 32-bit signed integer from NVS. Signature: esp_err_t config_get_int32(const char* key, int32_t* value)
Parameters:
Returns:
|
Write a 32-bit signed integer to NVS and commit immediately. Signature: esp_err_t config_set_int32(const char* key, int32_t value)
Parameters:
Returns:
|
Read a 16-bit signed integer from NVS. Signature: esp_err_t config_get_int16(const char* key, int16_t* value)
Parameters:
Returns:
|
Write a 16-bit signed integer to NVS and commit immediately. Signature: esp_err_t config_set_int16(const char* key, int16_t value)
Parameters:
Returns:
|
Write an int16 value to NVS without committing; use Signature: esp_err_t config_set_int16_no_commit(const char* key, int16_t value)
Parameters:
Returns:
|
Boolean Parameter Access¶
Read a boolean value (stored as uint8) from NVS. Signature: esp_err_t config_get_bool(const char* key, bool* value)
Parameters:
Returns:
|
Write a boolean value to NVS without committing; use Signature: esp_err_t config_set_bool_no_commit(const char* key, bool value)
Parameters:
Returns:
|
Write a boolean value to NVS and commit immediately. Signature: esp_err_t config_set_bool(const char* key, bool value)
Parameters:
Returns:
|
Bulk JSON Configuration API¶
Return pointer to embedded JSON schema string. The returned pointer is owned by the binary and must not be freed by the caller. Signature: esp_err_t config_get_schema_json(char **schema_json)
Parameters:
Returns:
|
Build and return allocated JSON array string representing all configuration values. Caller must free the returned string. Signature: esp_err_t config_get_all_as_json(char **config_json)
Parameters:
Returns:
|
Parse structured JSON array and update configuration atomically. Uses _no_commit setters internally and performs a single commit. Unknown keys are ignored. Signature: esp_err_t config_set_all_from_json(const char *config_json)
Parameters:
Returns:
|