feat: persistent config
This commit is contained in:
@@ -291,6 +291,51 @@ The system includes automatic WiFi fallback for robust operation:
|
||||
|
||||
## Configuration Management
|
||||
|
||||
SPORE implements a persistent configuration system that manages device settings across reboots and provides runtime reconfiguration capabilities.
|
||||
|
||||
### Configuration Architecture
|
||||
|
||||
The configuration system consists of several key components:
|
||||
|
||||
- **`Config` Class**: Central configuration management with default constants
|
||||
- **LittleFS Storage**: Persistent file-based storage (`/config.json`)
|
||||
- **Runtime Updates**: Live configuration changes via HTTP API
|
||||
- **Automatic Persistence**: Configuration changes are automatically saved
|
||||
|
||||
### Configuration Categories
|
||||
|
||||
| Category | Description | Examples |
|
||||
|----------|-------------|----------|
|
||||
| **WiFi Configuration** | Network connection settings | SSID, password, timeouts |
|
||||
| **Network Configuration** | Network service settings | UDP port, API server port |
|
||||
| **Cluster Configuration** | Cluster management settings | Discovery intervals, heartbeat timing |
|
||||
| **Node Status Thresholds** | Health monitoring thresholds | Active/inactive/dead timeouts |
|
||||
| **System Configuration** | Core system settings | Restart delay, JSON document size |
|
||||
| **Memory Management** | Resource management settings | Memory thresholds, HTTP request limits |
|
||||
|
||||
### Configuration Lifecycle
|
||||
|
||||
1. **Boot Process**: Load configuration from `/config.json` or use defaults
|
||||
2. **Runtime Updates**: Configuration changes via HTTP API
|
||||
3. **Persistent Storage**: Changes automatically saved to LittleFS
|
||||
4. **Service Integration**: Configuration applied to all system services
|
||||
|
||||
### Default Value Management
|
||||
|
||||
All default values are defined as `constexpr` constants in the `Config` class:
|
||||
|
||||
```cpp
|
||||
static constexpr const char* DEFAULT_WIFI_SSID = "shroud";
|
||||
static constexpr uint16_t DEFAULT_UDP_PORT = 4210;
|
||||
static constexpr unsigned long DEFAULT_HEARTBEAT_INTERVAL_MS = 5000;
|
||||
```
|
||||
|
||||
This ensures:
|
||||
- **Single Source of Truth**: All defaults defined once
|
||||
- **Type Safety**: Compile-time type checking
|
||||
- **Maintainability**: Easy to update default values
|
||||
- **Consistency**: Same defaults used in `setDefaults()` and `loadFromFile()`
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```bash
|
||||
@@ -380,6 +425,8 @@ pio device monitor
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- **[Configuration Management](./ConfigurationManagement.md)** - Persistent configuration system
|
||||
- **[WiFi Configuration](./WiFiConfiguration.md)** - WiFi setup and reconfiguration process
|
||||
- **[Task Management](./TaskManagement.md)** - Background task system
|
||||
- **[API Reference](./API.md)** - REST API documentation
|
||||
- **[TaskManager API](./TaskManager.md)** - TaskManager class reference
|
||||
|
||||
Reference in New Issue
Block a user