45 lines
983 B
C++
45 lines
983 B
C++
#include <LittleFS.h>
|
|
|
|
#include "Config.h"
|
|
|
|
Config::Config()
|
|
{}
|
|
|
|
void Config::load(void)
|
|
{
|
|
// load WLANs
|
|
File wlanFile = LittleFS.open("/etc/wlan", "r");
|
|
|
|
while(wlanFile.available()) {
|
|
String ssid = wlanFile.readStringUntil('\n');
|
|
|
|
if(!wlanFile.available()) {
|
|
Serial.println("/etc/wlan terminated early. Last entry ignored.");
|
|
break;
|
|
}
|
|
|
|
String passwd = wlanFile.readStringUntil('\n');
|
|
|
|
m_wlans.emplace_back(WLAN{ssid.c_str(), passwd.c_str()});
|
|
}
|
|
|
|
wlanFile.close();
|
|
|
|
// load Challenge-Response data
|
|
File authFile = LittleFS.open("/etc/auth", "r");
|
|
|
|
if(authFile.available()) {
|
|
String passwd = authFile.readStringUntil('\n');
|
|
m_crPassword = passwd.c_str();
|
|
|
|
if(!authFile.available()) {
|
|
m_crSalt = "";
|
|
} else {
|
|
String salt = authFile.readStringUntil('\n');
|
|
m_crSalt = salt.c_str();
|
|
}
|
|
}
|
|
|
|
authFile.close();
|
|
}
|