CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::os_ui::SystemSettingsBackup Class Reference

Export/import for OS-level settings that live in NVS without an owning module. More...

#include <SystemSettingsBackup.h>

Static Public Member Functions

static bool exportSystemSettings (cJSON *out)
 Writes the user-configurable NVS settings into out.
static cdc::core::IModule::BackupResult importSystemSettings (const cJSON *in)
 Restores the system settings from in best-effort.

Detailed Description

Export/import for OS-level settings that live in NVS without an owning module.

The badge has user-configurable settings (WiFi, backlight, language, sleep interval, timezone, badge text, module enable state) that are stored in NVS by their respective owners (WifiHandlers, IDisplay, I18n, ISleepController, IRtc, SettingsHandlers, ModuleRegistry) rather than under any IModule. This helper serializes those settings into the backup container's top-level "system" section and restores them best-effort, always through the owners' public APIs (never by re-encoding NVS namespaces/keys here).

Security-sensitive, device-bound data (badge PIN, duress PIN, TROPIC01 keys, attestation) is intentionally excluded - it is not a setting. WiFi credentials are included because the backup container is passphrase-encrypted.

Definition at line 25 of file SystemSettingsBackup.h.

Member Function Documentation

◆ exportSystemSettings()

bool cdc::os_ui::SystemSettingsBackup::exportSystemSettings ( cJSON * out)
static

Writes the user-configurable NVS settings into out.

Adds a schema_ver plus the individual settings as JSON fields. Reads every value via its owner's public getter; absent/unavailable services are simply omitted.

Parameters
outJSON object node for the "system" section (must be non-null).
Returns
true if at least the schema marker was written.

Definition at line 77 of file SystemSettingsBackup.cpp.

References cdc::ui::WifiConfig::gateway, cdc::hal::getDisplayInstance(), cdc::core::IService::getName(), cdc::hal::getRtcInstance(), cdc::hal::getSleepControllerInstance(), cdc::core::ModuleRegistry::instance(), cdc::ui::I18n::instance(), cdc::ui::WifiHandlers::instance(), cdc::ui::settings::loadDisplayField(), cdc::ui::LockScreenView::MAX_TEXT_LEN, cdc::ui::WifiConfig::netmask, cdc::ui::WifiConfig::password, cdc::ui::WifiConfig::security, cdc::ui::WifiConfig::ssid, cdc::ui::WifiConfig::staticIp, cdc::ui::WifiConfig::useDhcp, and cdc::ui::WifiConfig::valid.

Referenced by cdc::os_ui::BackupManager::exportTo().

◆ importSystemSettings()

cdc::core::IModule::BackupResult cdc::os_ui::SystemSettingsBackup::importSystemSettings ( const cJSON * in)
static

Restores the system settings from in best-effort.

Each field is applied independently via its owner's public setter; a missing, malformed or rejected field is skipped and counted, never aborting the whole section (no migration). Backlight and language are applied live; the rest take effect via the owners' persisted state.

Parameters
inJSON object node for the "system" section (must be non-null).
Returns
Per-field tally of applied vs. skipped settings.

Definition at line 143 of file SystemSettingsBackup.cpp.

References cdc::core::IModule::BackupResult::failed, cdc::ui::WifiWizard::gateway, cdc::hal::getDisplayInstance(), cdc::core::IService::getName(), cdc::hal::getRtcInstance(), cdc::hal::getSleepControllerInstance(), cdc::core::IModule::BackupResult::imported, cdc::core::ModuleRegistry::instance(), cdc::ui::I18n::instance(), cdc::ui::WifiHandlers::instance(), LOG_I, LOG_W, cdc::ui::WifiWizard::netmask, cdc::ui::WifiWizard::password, cdc::ui::WifiWizard::reset(), cdc::ui::settings::saveDisplayField(), cdc::ui::WifiWizard::security, cdc::ui::WifiWizard::ssid, cdc::ui::WifiWizard::staticIp, TAG, cdc::ui::WifiWizard::useDhcp, and cdc::hal::WPA2_PSK.

Referenced by cdc::os_ui::BackupManager::importFrom().


The documentation for this class was generated from the following files: