mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-04-08 07:55:20 +00:00
add clang-format and format all source files
This commit is contained in:
parent
fd4e34bb6c
commit
ff25ad4696
41 changed files with 1664 additions and 1808 deletions
|
|
@ -1,65 +1,55 @@
|
|||
#include "configuration.h"
|
||||
#include <SPIFFS.h>
|
||||
#include <logger.h>
|
||||
#include "configuration.h"
|
||||
|
||||
ConfigurationManagement::ConfigurationManagement(String FilePath)
|
||||
: mFilePath(FilePath)
|
||||
{
|
||||
if(!SPIFFS.begin(true))
|
||||
{
|
||||
logPrintlnE("Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
||||
SPIFFS.format();
|
||||
if(!SPIFFS.begin())
|
||||
{
|
||||
logPrintlnE("Formating SPIFFS was not okay!");
|
||||
}
|
||||
}
|
||||
ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(FilePath) {
|
||||
if (!SPIFFS.begin(true)) {
|
||||
logPrintlnE("Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
||||
SPIFFS.format();
|
||||
if (!SPIFFS.begin()) {
|
||||
logPrintlnE("Formating SPIFFS was not okay!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationManagement::~ConfigurationManagement()
|
||||
{
|
||||
ConfigurationManagement::~ConfigurationManagement() {
|
||||
}
|
||||
|
||||
std::shared_ptr<Configuration> ConfigurationManagement::readConfiguration()
|
||||
{
|
||||
File file = SPIFFS.open(mFilePath);
|
||||
if(!file)
|
||||
{
|
||||
logPrintlnE("Failed to open file for reading...");
|
||||
return 0;
|
||||
}
|
||||
DynamicJsonDocument data(2048);
|
||||
DeserializationError error = deserializeJson(data, file);
|
||||
if(error)
|
||||
{
|
||||
logPrintlnW("Failed to read file, using default configuration.");
|
||||
}
|
||||
//serializeJson(data, Serial);
|
||||
//Serial.println();
|
||||
file.close();
|
||||
std::shared_ptr<Configuration> ConfigurationManagement::readConfiguration() {
|
||||
File file = SPIFFS.open(mFilePath);
|
||||
if (!file) {
|
||||
logPrintlnE("Failed to open file for reading...");
|
||||
return 0;
|
||||
}
|
||||
DynamicJsonDocument data(2048);
|
||||
DeserializationError error = deserializeJson(data, file);
|
||||
if (error) {
|
||||
logPrintlnW("Failed to read file, using default configuration.");
|
||||
}
|
||||
// serializeJson(data, Serial);
|
||||
// Serial.println();
|
||||
file.close();
|
||||
|
||||
std::shared_ptr<Configuration> conf = readProjectConfiguration(data);
|
||||
std::shared_ptr<Configuration> conf = readProjectConfiguration(data);
|
||||
|
||||
// update config in memory to get the new fields:
|
||||
writeConfiguration(conf);
|
||||
// update config in memory to get the new fields:
|
||||
writeConfiguration(conf);
|
||||
|
||||
return conf;
|
||||
return conf;
|
||||
}
|
||||
|
||||
void ConfigurationManagement::writeConfiguration(std::shared_ptr<Configuration> conf)
|
||||
{
|
||||
File file = SPIFFS.open(mFilePath, "w");
|
||||
if(!file)
|
||||
{
|
||||
logPrintlnE("Failed to open file for writing...");
|
||||
return;
|
||||
}
|
||||
DynamicJsonDocument data(2048);
|
||||
void ConfigurationManagement::writeConfiguration(std::shared_ptr<Configuration> conf) {
|
||||
File file = SPIFFS.open(mFilePath, "w");
|
||||
if (!file) {
|
||||
logPrintlnE("Failed to open file for writing...");
|
||||
return;
|
||||
}
|
||||
DynamicJsonDocument data(2048);
|
||||
|
||||
writeProjectConfiguration(conf, data);
|
||||
writeProjectConfiguration(conf, data);
|
||||
|
||||
serializeJson(data, file);
|
||||
//serializeJson(data, Serial);
|
||||
//Serial.println();
|
||||
file.close();
|
||||
serializeJson(data, file);
|
||||
// serializeJson(data, Serial);
|
||||
// Serial.println();
|
||||
file.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue