add documentation
This commit is contained in:
parent
7c5ec51abb
commit
45dacd4f78
@ -32,6 +32,9 @@ SDCard::~SDCard()
|
|||||||
unmount();
|
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)
|
void SDCard::SD2nvMemory(nvMemory* nvMem, TSettings* Settings)
|
||||||
{
|
{
|
||||||
if (loadConfigFile(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)
|
bool SDCard::loadConfigFile(TSettings* Settings)
|
||||||
{
|
{
|
||||||
// Load existing configuration file
|
// Load existing configuration file
|
||||||
|
@ -9,10 +9,7 @@
|
|||||||
#include "..\devices\device.h"
|
#include "..\devices\device.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
|
||||||
nvMemory::nvMemory()
|
nvMemory::nvMemory() : Initialized_(false){};
|
||||||
{
|
|
||||||
Initialized_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nvMemory::~nvMemory()
|
nvMemory::~nvMemory()
|
||||||
{
|
{
|
||||||
@ -20,6 +17,9 @@ nvMemory::~nvMemory()
|
|||||||
SPIFFS.end();
|
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)
|
bool nvMemory::saveConfig(TSettings* Settings)
|
||||||
{
|
{
|
||||||
if (init())
|
if (init())
|
||||||
@ -60,6 +60,9 @@ bool nvMemory::saveConfig(TSettings* Settings)
|
|||||||
return false;
|
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)
|
bool nvMemory::loadConfig(TSettings* Settings)
|
||||||
{
|
{
|
||||||
// Uncomment if we need to format filesystem
|
// Uncomment if we need to format filesystem
|
||||||
@ -113,12 +116,16 @@ bool nvMemory::loadConfig(TSettings* Settings)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Delete config file from SPIFFS
|
||||||
|
/// @return true on successs
|
||||||
bool nvMemory::deleteConfig()
|
bool nvMemory::deleteConfig()
|
||||||
{
|
{
|
||||||
Serial.println("SPIFS: Erasing config file..");
|
Serial.println("SPIFS: Erasing config file..");
|
||||||
return SPIFFS.remove(JSON_CONFIG_FILE); //Borramos fichero
|
return SPIFFS.remove(JSON_CONFIG_FILE); //Borramos fichero
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Prepare and mount SPIFFS
|
||||||
|
/// @return true on success
|
||||||
bool nvMemory::init()
|
bool nvMemory::init()
|
||||||
{
|
{
|
||||||
if (!Initialized_)
|
if (!Initialized_)
|
||||||
|
Loading…
Reference in New Issue
Block a user