File tree Expand file tree Collapse file tree
SimulatorHalImpl/wifiHandlerSim Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ std::vector<IDevice::Ptr> ActiveDeviceConfig::loadDevices() {
4848
4949 // #TODO OMOTE-Community/OMOTE-Firmware-object-oriented#72
5050 // HardwareFactory::getAbstract().debugPrint("Loaded JSON %s", content.c_str());
51- auto configPath = std::filesystem::path (ACTIVE_DEVICES_CONFIG_FILE );
51+ std::filesystem::path configPath (ACTIVE_DEVICES_CONFIG_FILE );
5252 rapidjson::Document doc = OMOTE::JSON::GetDocument (configPath);
5353
5454 if (!doc.IsArray ())
Original file line number Diff line number Diff line change 44#include < fstream>
55#include < rapidjson/document.h>
66
7- #define LOG_SETTINGS_FILE " logSettings.json"
8-
97void LoggingInterface::restoreSettings () {
108 // Default to warning for all modules before loading from file
119 // so new modules default to warning
1210 std::fill (mCurrentLogLevels .begin (), mCurrentLogLevels .end (), LogLevel::Warning);
1311
14- std::filesystem::path settingsPath (FS_PATH LOG_SETTINGS_FILE );
12+ std::filesystem::path settingsPath (LOG_SETTINGS_FILE );
1513 rapidjson::Document d = OMOTE::JSON::GetDocument (settingsPath);
1614
1715 if (!d.HasParseError () && d.IsObject ()) {
@@ -41,7 +39,7 @@ void LoggingInterface::saveSettings() {
4139 d.AddMember (key, val, d.GetAllocator ());
4240 }
4341
44- std::filesystem::path settingsPath (FS_PATH LOG_SETTINGS_FILE );
42+ std::filesystem::path settingsPath (LOG_SETTINGS_FILE );
4543 OMOTE::JSON::WriteDocumentToFile (d, settingsPath);
4644}
4745
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ class LoggingInterface {
101101 // Check level and module to see if we want to print the log
102102 static bool isPrintWanted (LogModule aModule, LogLevel aLevelToCheck);
103103 static inline std::array<LogLevel, NumLogModules> mCurrentLogLevels {};
104+ static constexpr auto LOG_SETTINGS_FILE = FS_PATH " logSettings.json" ;
104105};
105106
106107inline void LoggingInterface::setLogModule (LogModule aModule) {
Original file line number Diff line number Diff line change @@ -104,4 +104,7 @@ class wifiHandlerInterface {
104104 std::make_shared<ScanNotificationTy>();
105105 std::shared_ptr<Notification<wifiStatus>> mStatusUpdate =
106106 std::make_shared<Notification<wifiStatus>>();
107+
108+ static constexpr auto MQTT_CONFIG_FILE = FS_PATH " mqtt.json" ;
109+ static constexpr auto NTP_CONFIG_FILE = FS_PATH " ntp.json" ;
107110};
Original file line number Diff line number Diff line change @@ -209,16 +209,16 @@ void wifiHandlerSim::mqttSaveCredentials() {
209209 d.AddMember (" password" , mMqttPassword , d.GetAllocator ());
210210 d.AddMember (" client" , mMqttClientName , d.GetAllocator ());
211211
212- std::filesystem::path mqttJsonConfigPath (FS_PATH " mqtt.json " );
212+ std::filesystem::path mqttJsonConfigPath (MQTT_CONFIG_FILE );
213213 OMOTE::JSON::WriteDocumentToFile (d, mqttJsonConfigPath);
214214
215215 mMqttSaveOnConnect = false ;
216216 }
217217}
218218
219219void wifiHandlerSim::restoreCredentials () {
220- std::filesystem::path mqttJson ( FS_PATH " mqtt.json " );
221- rapidjson::Document d = OMOTE::JSON::GetDocument (mqttJson );
220+ std::filesystem::path mqttJsonConfigPath ( MQTT_CONFIG_FILE );
221+ rapidjson::Document d = OMOTE::JSON::GetDocument (mqttJsonConfigPath );
222222 if (d.HasParseError () || d.IsNull ()) {
223223 return ;
224224 }
Original file line number Diff line number Diff line change @@ -316,8 +316,8 @@ void wifiHandler::enableMqtt(bool enabled) {
316316
317317void wifiHandler::mqttRestoreCredentials () {
318318 // restore from disk
319- std::filesystem::path aMqttPath (MQTT_CONFIG_FILE );
320- rapidjson::Document d = OMOTE::JSON::GetDocument (aMqttPath );
319+ std::filesystem::path mqttConfigPath (MQTT_CONFIG_FILE );
320+ rapidjson::Document d = OMOTE::JSON::GetDocument (mqttConfigPath );
321321 if (d.HasParseError () || d.IsNull ()) {
322322 mLogger ->error (" Could not load MQTT credentials." );
323323 return ;
@@ -369,8 +369,8 @@ void wifiHandler::ntpRestoreCredentials() {
369369 mNtpDisplayMode = ntpDisplayMode::constant;
370370
371371 // restore from disk
372- std::filesystem::path ntpJsonConfig (NTP_CONFIG_FILE );
373- rapidjson::Document d = OMOTE::JSON::GetDocument (ntpJsonConfig );
372+ std::filesystem::path ntpConfigPath (NTP_CONFIG_FILE );
373+ rapidjson::Document d = OMOTE::JSON::GetDocument (ntpConfigPath );
374374
375375 if (d.HasParseError () || d.IsNull ()) {
376376 mLogger ->error (" Could not load NTP credentials." );
Original file line number Diff line number Diff line change @@ -116,7 +116,6 @@ class wifiHandler : public wifiHandlerInterface {
116116 /* *
117117 * @brief MQTT variables
118118 */
119- static constexpr auto MQTT_CONFIG_FILE = FS_PATH " mqtt.json" ;
120119 std::string mMqttBroker = " broker" ;
121120 std::string mMqttPort = " port" ;
122121 std::string mMqttUser = " user" ;
@@ -132,7 +131,6 @@ class wifiHandler : public wifiHandlerInterface {
132131 /* *
133132 * @brief NTP variables
134133 */
135- static constexpr auto NTP_CONFIG_FILE = FS_PATH " ntp.json" ;
136134 bool mNtpEnabled = false ;
137135 bool mNtpInitialised = false ;
138136 std::string mNtpServer = " pool.ntp.org" ;
You can’t perform that action at this time.
0 commit comments