feat(cv): add CVTuning struct and NVS persistence scaffolding

Adds CVTuning to CVState, populates defaults from existing file-scope
constants in cv_init, and introduces config_load_tuning/config_save_tuning
backed by the doorcounter NVS namespace. No runtime behavior change yet;
CV code still reads the existing constants (Task 2 will migrate reads).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 15:45:53 -07:00
parent 9d5b588231
commit e28a4c1863
5 changed files with 92 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
// firmware/src/config.h
#pragma once
#include <Arduino.h>
#include "cv.h"
struct DeviceConfig {
String device_id; // e.g. "dc-0042"
@@ -22,3 +23,10 @@ bool config_has_wifi();
// Erase WiFi credentials only (factory reset — preserves device_id etc).
void config_clear_wifi();
// Load CV tuning from NVS. Returns true only if all keys present (cfg_version sentinel).
// If any key missing, tuning is NOT modified (caller keeps its defaults).
bool config_load_tuning(CVTuning& tuning);
// Save CV tuning to NVS atomically. Returns true if all writes succeeded.
bool config_save_tuning(const CVTuning& tuning);