44 lines
976 B
C++
44 lines
976 B
C++
|
#include <SPIFFS.h>
|
||
|
|
||
|
#include "Config.h"
|
||
|
|
||
|
Config::Config()
|
||
|
{}
|
||
|
|
||
|
void Config::load(void)
|
||
|
{
|
||
|
// load WLANs
|
||
|
File wlanFile = SPIFFS.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 = SPIFFS.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();
|
||
|
}
|