diff --git a/src/drivers/storage/SDCard.cpp b/src/drivers/storage/SDCard.cpp index e852bf0..48a5c73 100644 --- a/src/drivers/storage/SDCard.cpp +++ b/src/drivers/storage/SDCard.cpp @@ -32,6 +32,9 @@ SDCard::~SDCard() unmount(); } +/// @brief Transfer settings from config file on a SD card to the device. +/// @param nvMemory* where to save +/// @param TSettings* passing a struct is required, to save memory void SDCard::SD2nvMemory(nvMemory* nvMem, TSettings* Settings) { if (loadConfigFile(Settings)) @@ -43,6 +46,9 @@ void SDCard::SD2nvMemory(nvMemory* nvMem, TSettings* Settings) } } +/// @brief Retreives settings from a config file on a SD card. +/// @param TSettings* Struct to update with new Settings +/// @return true on success bool SDCard::loadConfigFile(TSettings* Settings) { // Load existing configuration file diff --git a/src/drivers/storage/nvMemory.cpp b/src/drivers/storage/nvMemory.cpp index cc5f997..9467a72 100644 --- a/src/drivers/storage/nvMemory.cpp +++ b/src/drivers/storage/nvMemory.cpp @@ -9,10 +9,7 @@ #include "..\devices\device.h" #include "storage.h" -nvMemory::nvMemory() -{ - Initialized_ = false; -} +nvMemory::nvMemory() : Initialized_(false){}; nvMemory::~nvMemory() { @@ -20,6 +17,9 @@ nvMemory::~nvMemory() SPIFFS.end(); }; +/// @brief Save settings to config file on SPIFFS +/// @param TSettings* Settings to be saved. +/// @return true on success bool nvMemory::saveConfig(TSettings* Settings) { if (init()) @@ -60,6 +60,9 @@ bool nvMemory::saveConfig(TSettings* Settings) return false; } +/// @brief Load settings from config file located in SPIFFS. +/// @param TSettings* Struct to update with new settings. +/// @return true on success bool nvMemory::loadConfig(TSettings* Settings) { // Uncomment if we need to format filesystem @@ -113,12 +116,16 @@ bool nvMemory::loadConfig(TSettings* Settings) return false; } +/// @brief Delete config file from SPIFFS +/// @return true on successs bool nvMemory::deleteConfig() { Serial.println("SPIFS: Erasing config file.."); return SPIFFS.remove(JSON_CONFIG_FILE); //Borramos fichero } +/// @brief Prepare and mount SPIFFS +/// @return true on success bool nvMemory::init() { if (!Initialized_)