/** * @file nvs_driver.h * @brief Non-Volatile Storage abstraction for persistent state * * Handles reading and writing system state to flash memory. * Used for tracking first-boot status and other persistent flags. */ #ifndef NVS_DRIVER_H #define NVS_DRIVER_H #include "esp_err.h" #include #include #ifdef __cplusplus extern "C" { #endif /** * @brief Initialize NVS flash * * Must be called before any other NVS operations. * Handles partition initialization and potential recovery. * * @return true on success, false on failure */ bool nvsDriverInit(void); /** * @brief Check if this is the device's first boot * * Checks for the existence of a "provisioned" flag. * * @return true if first boot (flag not found), false otherwise */ bool nvsDriverIsFirstBoot(void); /** * @brief Mark the device as provisioned (not first boot) * * Writes the persistent flag to storage. * * @return true on success */ bool nvsDriverMarkProvisioned(void); /** * @brief Get the total boot count * * @return Number of times device has booted (defaults to 1 if read fails) */ uint32_t nvsDriverGetBootCount(void); /** * @brief Increment the total boot count */ void nvsDriverIncrementBootCount(void); /** * @brief Save IMU calibration data to NVS * * @param x X-axis baseline value * @param y Y-axis baseline value * @param z Z-axis baseline value * @return true on success, false on failure */ bool nvsDriverSaveImuCalibration(float x, float y, float z); /** * @brief Load IMU calibration data from NVS * * @param x Pointer to store X-axis baseline * @param y Pointer to store Y-axis baseline * @param z Pointer to store Z-axis baseline * @return true if calibration data exists and was loaded, false otherwise */ bool nvsDriverLoadImuCalibration(float *x, float *y, float *z); #ifdef __cplusplus } #endif #endif // NVS_DRIVER_H