12 if (!SPIFFS.begin(
true)) {
13 Serial.println(
"An error has occurred while mounting SPIFFS");
23 JsonObject loggingConfig = doc[
"logging"];
24 logging->
MinLevel = loggingConfig[
"min_level"] |
"info";
28 logging->
Serial->
Enabled = loggingConfig[
"serial"][
"enabled"] |
true;
31 JsonObject syslogConfig = loggingConfig[
"syslog"];
37 logging->
SysLog->
AppName = syslogConfig[
"appname"].as<std::string>();
39 const char *minLevel = loggingConfig[
"min_level"];
41 if (strcmp(minLevel,
"debug") == 0) {
43 }
else if (strcmp(minLevel,
"info") == 0) {
45 }
else if (strcmp(minLevel,
"warning") == 0) {
47 }
else if (strcmp(minLevel,
"error") == 0) {
49 }
else if (strcmp(minLevel,
"fatal") == 0) {
64 JsonObject wifiConfig = doc[
"wifi"];
65 wifi->
SSID = wifiConfig[
"SSID"].as<std::string>();
66 wifi->
password = wifiConfig[
"password"].as<std::string>();
67 wifi->
hostname = wifiConfig[
"hostname"].as<std::string>();
68 wifi->
otaPassword = wifiConfig[
"otaPassword"].as<std::string>();
76 JsonObject mqttConfig = doc[
"mqtt"];
79 mqtt->
KeepAlive = mqttConfig[
"keepalive"] | 10;
80 mqtt->
Ping = mqttConfig[
"ping"] | 0;
81 mqtt->
Topic =
"rocrail/service/command";
static DynamicJsonDocument ReadJsonFile(const char *jsonFilePath)
Definition MCJsonConfig.cpp:3
MCNetworkConfiguration * loadNetworkConfiguration(const char *configFilePath)
Definition loadNetworkConfiguration.h:6
Definition MCLoggingConfiguration.h:6
MCLoggingSerialConfiguration * Serial
Definition MCLoggingConfiguration.h:9
MCLoggingSyslogConfiguration * SysLog
Definition MCLoggingConfiguration.h:10
std::string MinLevel
Definition MCLoggingConfiguration.h:8
Definition MCLoggingSerialConfiguration.h:3
bool Enabled
Definition MCLoggingSerialConfiguration.h:5
Definition MCLoggingSyslogConfiguration.h:5
int mask
Definition MCLoggingSyslogConfiguration.h:10
std::string AppName
Definition MCLoggingSyslogConfiguration.h:9
std::string ServerAddress
Definition MCLoggingSyslogConfiguration.h:7
bool Enabled
Definition MCLoggingSyslogConfiguration.h:6
uint16_t ServerPort
Definition MCLoggingSyslogConfiguration.h:8
Definition MCMQTTConfiguration.h:3
const char * Topic
Definition MCMQTTConfiguration.h:10
uint16_t Ping
Definition MCMQTTConfiguration.h:9
std::string ServerAddress
Definition MCMQTTConfiguration.h:6
uint16_t KeepAlive
Definition MCMQTTConfiguration.h:8
uint16_t ServerPort
Definition MCMQTTConfiguration.h:7
Definition MCNetworkConfiguration.h:5
MCWiFiConfiguration * WiFi
Definition MCNetworkConfiguration.h:8
MCMQTTConfiguration * MQTT
Definition MCNetworkConfiguration.h:9
MCLoggingConfiguration * Logging
Definition MCNetworkConfiguration.h:7
Definition MCWiFiConfiguration.h:3
std::string otaPassword
Definition MCWiFiConfiguration.h:7
std::string hostname
Definition MCWiFiConfiguration.h:8
std::string SSID
Definition MCWiFiConfiguration.h:5
uint32_t DailyBetweenConnectAttempsInMs
Definition MCWiFiConfiguration.h:9
std::string password
Definition MCWiFiConfiguration.h:6