Automatic Curtain  MVP
Software repository for an automatic curtain using stepper motor, TMC2209 and ESP32
storage.h
Go to the documentation of this file.
1 
12 #ifndef _STORAGE_INCLUDE_GUARD
13 #define _STORAGE_INCLUDE_GUARD
14 
15 #include <Preferences.h>
16 
17 #include <memory>
18 
19 #include "../config/config.h"
20 #include "../logging/logging.h"
21 
22 class Storage {
23  public:
29  Storage(std::shared_ptr<Logging>);
30 
35  ~Storage();
36 
44  bool SaveDeviceCred(const CONFIG_SET::DEVICE_CRED* device_cred);
45 
54 
62  bool SaveCalibParam(const CONFIG_SET::CALIB_PARAMS* calib_param);
63 
72 
81 
90 
95  void Clear();
96 
97  private:
98  Preferences preferences_;
99  std::shared_ptr<Logging> logger_;
100 };
101 
102 #endif
OPERATION_MODE
Definition: config.h:75
bool SaveOperationMode(const CONFIG_SET::OPERATION_MODE *mode)
Saves the operation mode to Flash, fetching the data from the variable whose pointer is provided as a...
Definition: storage.cpp:71
~Storage()
Destroy the Storage object, closes Flash.
Definition: storage.cpp:22
bool SaveDeviceCred(const CONFIG_SET::DEVICE_CRED *device_cred)
Saves the wifi creds and device id to Flash, fetching the data from the variable whose pointer is pro...
Definition: storage.cpp:24
Definition: storage.h:22
Definition: config.h:170
Preferences preferences_
Definition: storage.h:98
std::shared_ptr< Logging > logger_
Definition: storage.h:99
bool PopulateCalibParam(CONFIG_SET::CALIB_PARAMS *calib_param)
Retrieves the calib params from the flash and populates them in variable whose pointer is provided as...
Definition: storage.cpp:60
bool PopulateOperationMode(CONFIG_SET::OPERATION_MODE *mode)
Retrieves the operation mode from the flash and populates them in variable whose pointer is provided ...
Definition: storage.cpp:81
Storage(std::shared_ptr< Logging >)
Construct a new Storage object, initializes logger and calls Storage()
Definition: storage.cpp:20
bool PopulateDeviceCred(CONFIG_SET::DEVICE_CRED *device_cred)
Retrieves the wifi creds and device id from the flash and populates them in variable whose pointer is...
Definition: storage.cpp:36
void Clear()
Clears the memory for CONFIG_SET::STORAGE_NAMESPACE workspace.
Definition: storage.cpp:93
Definition: config.h:164
bool SaveCalibParam(const CONFIG_SET::CALIB_PARAMS *calib_param)
Saves the calib params to Flash, fetching the data from the variable whose pointer is provided as an ...
Definition: storage.cpp:48