JSON-Based Configuration Manager Requirements¶
This document specifies component-level requirements for the JSON-Schema-Driven Configuration Management System. These requirements refine the high-level system requirement Non-volatile Configuration ... (REQ_SYS_CFG_1) (Non-volatile Configuration Storage).
Component Overview¶
The JSON-based configuration manager component provides centralized configuration management through a single JSON schema source of truth. Configuration is stored persistently in NVS and accessed via type-safe C API. The web interface generates forms dynamically from the schema.
Configuration Schema Definition¶
Description: The configuration manager SHALL define all configuration parameters in a single JSON schema file (config_schema.json) that serves as the authoritative source of truth for parameter definitions, default values, and UI metadata. Rationale: Single source of truth prevents duplication across C code, web forms, and documentation. Schema-driven approach enables code generation for factory defaults and dynamic UI generation. Acceptance Criteria:
|
Description: The configuration schema SHALL support logical grouping of parameters into sections for organization in the web interface. Rationale: Logical organization improves usability for configuration with many parameters. Acceptance Criteria:
|
Description: The configuration system SHALL support basic parameter types: string, password, integer, boolean, and hidden. Rationale: Covers typical IoT configuration needs while remaining simple. Separate types enable appropriate UI widgets and validation. Acceptance Criteria:
|
Configuration Generation and Defaults¶
Description: The build system SHALL automatically generate C code to initialize factory default configuration from the JSON schema during build time. Rationale: Eliminates manual default value maintenance in C code. Generated code is compiled into firmware, ensuring defaults match schema without runtime JSON parsing. Acceptance Criteria:
|
Description: The ESP32 application code SHALL NOT parse JSON at runtime. JSON parsing SHALL occur only at build time (code generation) or in browser (UI). Rationale: Eliminates runtime overhead and memory overhead of JSON parser on resource-constrained ESP32. Simplifies C code and improves performance. Acceptance Criteria:
|
NVS Storage and Access¶
Description: Configuration parameters SHALL be stored in NVS using the schema “key” field directly as the NVS key. Rationale: Direct key usage simplifies storage format and eliminates need for separate UUID system. Keys are human-readable for debugging. Acceptance Criteria:
|
Description: The configuration manager SHALL provide type-specific getter and setter functions for configuration access. Rationale: Type-specific functions enforce compile-time type checking via function signature. Different functions for different types prevent accidental type mismatches at call site. Acceptance Criteria:
|
Description: Configuration changes SHALL be immediately persisted to NVS on each config_set_xxx() call. Rationale: Ensures configuration survives power loss and system resets. Acceptance Criteria:
|
Description: The system SHALL provide config_factory_reset() function to reset all configuration to schema-defined defaults. Rationale: Users need ability to recover from misconfiguration without firmware rebuild. Acceptance Criteria:
|
Web Interface Integration¶
Description: The configuration system SHOULD provide integration points for web-based configuration interfaces. Rationale: Web servers need access to configuration schema and runtime values to provide user interfaces. Config Manager provides the data layer; Web Server provides the HTTP/UI layer. Acceptance Criteria:
Note: Detailed web interface requirements (HTML forms, REST API endpoints, validation) are specified in Web Server Requirements (Configuration REST API (REQ_WEB_CONF_1)). This requirement ensures Config Manager provides necessary integration points without knowing HTTP details. |
Error Handling¶
Description: The configuration system SHALL gracefully handle NVS errors and continue operating with default values. Rationale: NVS corruption or wear should not prevent system operation. Acceptance Criteria:
|
Description: On first boot, config_init() SHALL initialize NVS with factory defaults from schema if NVS “config” namespace is empty or uninitialized. Rationale: New devices need sensible defaults on first boot. Acceptance Criteria:
|
Development Guide¶
Description: Adding new configuration parameters SHALL require modification of only config_schema.json, with C code and web UI auto-updating. Rationale: Low friction for extending configuration reduces development time. Acceptance Criteria:
|
Description: The build system SHOULD provide optional pre-build validation script that detects type mismatches between schema and C code. Rationale: Catches developer errors early without requiring code generation. Optional to keep build simple. Acceptance Criteria:
|
Future Enhancements¶
Description: The configuration system MAY support schema versioning and automatic migration of configuration data across firmware updates. Rationale: As firmware evolves, configuration structure may change (new fields, renamed keys, changed types). Schema versioning enables detection and migration of old configurations. However, embedded devices are typically “programmed out” thoroughly before production deployment, minimizing schema changes after deployment. Acceptance Criteria (if implemented):
Note: This requirement is marked “open” as schema changes are rare in production embedded systems. Hardware constraints typically stabilize configuration structure early in development. For most deployments, factory reset on major firmware updates is acceptable alternative to complex migration logic. |
Traceability¶
All traceability is automatically generated by Sphinx-Needs based on the :links: attributes in each requirement.
ID |
Title |
Status |
Tags |
|---|---|---|---|
Certificate Handler |
implemented |
||
Config Manager |
implemented |
||
Network Tunnel |
implemented |
||
cert_handler_get_ca_cert |
implemented |
||
cert_handler_get_info |
implemented |
||
cert_handler_get_server_cert |
implemented |
||
cert_handler_get_server_key |
implemented |
||
cert_handler_init |
implemented |
||
config_commit |
implemented |
||
config_factory_reset |
implemented |
||
config_get_all_as_json |
implemented |
||
config_get_bool |
implemented |
||
config_get_int16 |
implemented |
||
config_get_int32 |
implemented |
||
config_get_schema_json |
implemented |
||
config_get_string |
implemented |
||
config_init |
implemented |
||
config_set_all_from_json |
implemented |
||
config_set_bool |
implemented |
||
config_set_bool_no_commit |
implemented |
||
config_set_int16 |
implemented |
||
config_set_int16_no_commit |
implemented |
||
config_set_int32 |
implemented |
||
config_set_string |
implemented |
||
config_set_string_no_commit |
implemented |
||
config_write_factory_defaults |
implemented |
||
netif_uart_tunnel_deinit |
implemented |
||
netif_uart_tunnel_get_handle |
implemented |
||
netif_uart_tunnel_init |
implemented |
||
netif_uart_tunnel_config_t |
implemented |
||
JSON Schema as Configuration Source of Truth |
draft |
config; schema; architecture |
|
Web Interface Integration Support |
approved |
config; integration |
|
NVS Error Graceful Handling |
draft |
config; error-handling; reliability |
|
Configuration Initialization on Boot |
draft |
config; boot |
|
Simple Process to Add Configuration Fields |
draft |
config; extensibility; developer-experience |
|
Type Safety via Optional Static Validation |
draft |
config; validation; developer-experience |
|
Configuration Schema Versioning and Migration |
open |
config; versioning; migration; future |
|
Parameter Grouping for UI Organization |
draft |
config; ui; schema |
|
Parameter Type System |
draft |
config; types |
|
Build-Time Factory Defaults Generation |
draft |
config; build; code-generation |
|
No Runtime JSON Parsing in C Code |
draft |
config; performance; memory |
|
Key-Based NVS Storage |
draft |
config; storage; nvs |
|
Type-Safe Configuration API |
draft |
config; api; type-safety |
|
Persistent Configuration Storage |
draft |
config; storage; nvs |
|
Factory Reset Capability |
draft |
config; reset |
|
QEMU UART Network Bridge |
approved |
emulation; network; qemu; uart |
|
Packet Encapsulation |
approved |
emulation; protocol |
|
Host-Side Bridge Script |
approved |
emulation; tooling; host |
|
DHCP Client Support |
approved |
emulation; network; dhcp |
|
Conditional Compilation |
approved |
emulation; build |
|
Emulation Setup Documentation |
approved |
emulation; documentation |
|
Tunnel Throughput |
approved |
emulation; performance |
|
Packet Loss Handling |
approved |
emulation; reliability |
|
Component-based Architecture |
approved |
architecture; modularity |
|
Non-volatile Configuration Storage |
approved |
storage; nvs; configuration |
|
ESP32 Hardware Platform |
approved |
hardware; platform |
|
WiFi Connectivity |
approved |
network; wifi |
|
Memory Management |
approved |
performance; memory |
|
Error Handling and Recovery |
approved |
reliability; error-handling |
|
HTTPS Support |
open |
security; https; future |
|
Emulator Support |
approved |
emulator; qemu; testing |
|
Emulator Network Connectivity |
approved |
emulator; qemu; network; development |
|
System Time and NTP Support |
open |
time; ntp; future |
|
Web-based Configuration |
approved |
web; configuration |
|
Real-time Status Display |
approved |
web; ui; monitoring |
|
Configuration Interface |
approved |
web; ui; configuration |
|
WiFi Setup Interface |
approved |
web; wifi; network |
|
Web Interface Navigation |
approved |
web; ui; navigation |
|
HTTP Server Concurrency |
approved |
web; performance |
|
Configuration REST API |
approved |
web; api; config |
|
Web UI Responsiveness |
approved |
web; performance; ux |
|
Mobile-First Design |
approved |
web; ui; mobile |
|
Schema-Driven Configuration Form |
approved |
web; ui; config |
|
ESP-IDF CMake Integration |
approved |
build; cmake |
|
Certificate Handler Component Design |
draft |
component; security |
|
GitHub Codespaces Integration |
approved |
development; devcontainer |
|
Component Communication Pattern |
approved |
dataflow; communication |
|
Configuration Manager Component Design |
approved |
component; config |
|
Configuration Data Flow |
approved |
dataflow; config |
|
Error Recovery and Reset Strategy |
approved |
error-handling; reliability; reset |
|
Flash Memory Configuration |
approved |
flash; memory |
|
HTTP Server Architecture Details |
approved |
network; http; web |
|
ESP32 Template Layered Architecture |
approved |
architecture; layering |
|
Logging and Diagnostics Strategy |
approved |
logging; diagnostics; debugging |
|
Memory Management Strategy |
approved |
memory; performance |
|
Network Tunnel Component Design |
approved |
component; qemu; network |
|
System Performance Requirements |
approved |
performance; requirements |
|
QEMU Hardware Abstraction |
approved |
qemu; emulation |
|
QEMU Component Selection |
approved |
qemu; build |
|
FreeRTOS Task Organization |
approved |
threading; rtos |
|
Web Server Component Design |
approved |
component; web; network |
|
WiFi Manager Design Details |
approved |
network; wifi |
|
Type-Safe Configuration API |
approved |
api; interface; c-api |
|
JSON Schema-Driven Architecture |
draft |
architecture; config; json-schema |
|
Bulk JSON Configuration API |
approved |
api; json; bulk-operations |
|
Factory Reset via Bulk JSON Update |
approved |
build-process; code-generation; factory-reset |
|
Adding New Configuration Fields |
approved |
development; guide; extensibility |
|
Configuration Schema Structure |
approved |
data-structure; schema |
|
JSON Schema as Single Source of Truth |
approved |
architecture; schema; design-pattern |
|
NVS Storage Format |
approved |
storage; nvs |
|
Type Safety Without Code Generation |
approved |
type-safety; best-practices |
|
JSON Schema for UI Generation |
approved |
web; ui; javascript |
|
Configuration Webpage Architecture |
open |
frontend; javascript; ui |
|
Device Reset Countdown Interface |
open |
ui; countdown; reset |
|
Error Handling and User Feedback |
open |
error-handling; feedback |
|
Configuration Data Flow |
open |
data-flow; json; api |
|
Dynamic Form Generation from Schema |
open |
form-generation; schema; javascript |
|
Complete Page Initialization Flow |
open |
initialization; lifecycle |
|
JSON Array to Form Field Mapping |
open |
data-mapping; json; form |
|
UI State Management |
open |
ui-state; javascript |
|
Web Server Architecture |
approved |
web; architecture |
|
Captive Portal Design |
approved |
web; captive-portal; wifi |
|
HTTP Server Configuration |
approved |
web; config; performance |
|
Extension Guide for Web Pages |
approved |
web; extensibility; guide |
|
Config Manager Integration Pattern |
approved |
web; integration; config |
|
WiFi Manager Integration Pattern |
approved |
web; integration; wifi |
|
Configuration API Endpoints |
approved |
web; api; config; schema |
|
System Health API Endpoint |
approved |
web; api; diagnostics |
|
WiFi Management REST API Endpoints |
approved |
web; api; wifi |
|
URI Routing Table |
approved |
web; routing |
|
CORS Configuration |
approved |
web; security; cors |
|
Static File Embedding Strategy |
approved |
web; build; embedding |
|
Web Server Testing Strategy |
approved |
web; testing |

REQ_CFG_JSON_1¶