Merged setDefaultPreferences with loadPreferences
This commit is contained in:
parent
b2506fb589
commit
e991577a77
34
src/main.ino
34
src/main.ino
@ -136,7 +136,6 @@ void setup() {
|
|||||||
displayXBM();
|
displayXBM();
|
||||||
|
|
||||||
// Initialize the preferences
|
// Initialize the preferences
|
||||||
setDefaultPreferences();
|
|
||||||
loadPreferences();
|
loadPreferences();
|
||||||
|
|
||||||
// Setup the WiFi
|
// Setup the WiFi
|
||||||
@ -233,60 +232,49 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setDefaultPreferences() {
|
void loadPreferences() {
|
||||||
preferences.begin("config", false);
|
preferences.begin("config", false);
|
||||||
|
|
||||||
// IRC preferences
|
// IRC preferences
|
||||||
if (!preferences.isKey("irc_nickname"))
|
if (!preferences.isKey("irc_nickname"))
|
||||||
preferences.putString("irc_nickname", "ACID_" + String(random(1000, 10000)));
|
preferences.putString("irc_nickname", "ACID_" + String(random(1000, 10000)));
|
||||||
|
irc_nickname = preferences.getString("irc_nickname");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_username"))
|
if (!preferences.isKey("irc_username"))
|
||||||
preferences.putString("irc_username", "tdeck");
|
preferences.putString("irc_username", "tdeck");
|
||||||
|
irc_username = preferences.getString("irc_username");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_realname"))
|
if (!preferences.isKey("irc_realname"))
|
||||||
preferences.putString("irc_realname", "ACID DROP Firmware");
|
preferences.putString("irc_realname", "ACID DROP Firmware");
|
||||||
|
irc_realname = preferences.getString("irc_realname");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_server"))
|
if (!preferences.isKey("irc_server"))
|
||||||
preferences.putString("irc_server", "irc.supernets.org");
|
preferences.putString("irc_server", "irc.supernets.org");
|
||||||
|
irc_server = preferences.getString("irc_server");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_port"))
|
if (!preferences.isKey("irc_port"))
|
||||||
preferences.putInt("irc_port", 6667);
|
preferences.putInt("irc_port", 6667);
|
||||||
|
irc_port = preferences.getInt("irc_port");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_tls"))
|
if (!preferences.isKey("irc_tls"))
|
||||||
preferences.putBool("irc_tls", false);
|
preferences.putBool("irc_tls", false);
|
||||||
|
irc_tls = preferences.getBool("irc_tls");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_channel"))
|
if (!preferences.isKey("irc_channel"))
|
||||||
preferences.putString("irc_channel", "#comms");
|
preferences.putString("irc_channel", "#comms");
|
||||||
|
irc_channel = preferences.getString("irc_channel");
|
||||||
|
|
||||||
if (!preferences.isKey("irc_nickserv"))
|
if (!preferences.isKey("irc_nickserv"))
|
||||||
preferences.putString("irc_nickserv", "");
|
preferences.putString("irc_nickserv", "");
|
||||||
|
irc_nickserv = preferences.getString("irc_nickserv");
|
||||||
|
|
||||||
// WiFi preferences
|
// WiFi preferences
|
||||||
if (!preferences.isKey("wifi_ssid"))
|
if (!preferences.isKey("wifi_ssid"))
|
||||||
preferences.putString("wifi_ssid", "");
|
preferences.putString("wifi_ssid", "");
|
||||||
|
wifi_ssid = preferences.getString("wifi_ssid");
|
||||||
|
|
||||||
if (!preferences.isKey("wifi_password"))
|
if (!preferences.isKey("wifi_password"))
|
||||||
preferences.putString("wifi_password", "");
|
preferences.putString("wifi_password", "");
|
||||||
|
|
||||||
preferences.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void loadPreferences() {
|
|
||||||
preferences.begin("config", true);
|
|
||||||
|
|
||||||
// IRC preferences
|
|
||||||
irc_nickname = preferences.getString("irc_nickname");
|
|
||||||
irc_username = preferences.getString("irc_username");
|
|
||||||
irc_realname = preferences.getString("irc_realname");
|
|
||||||
irc_server = preferences.getString("irc_server");
|
|
||||||
irc_port = preferences.getInt("irc_port");
|
|
||||||
irc_tls = preferences.getBool("irc_tls");
|
|
||||||
irc_channel = preferences.getString("irc_channel");
|
|
||||||
irc_nickserv = preferences.getString("irc_nickserv");
|
|
||||||
|
|
||||||
// WiFi preferences
|
|
||||||
wifi_ssid = preferences.getString("wifi_ssid");
|
|
||||||
wifi_password = preferences.getString("wifi_password");
|
wifi_password = preferences.getString("wifi_password");
|
||||||
|
|
||||||
preferences.end();
|
preferences.end();
|
||||||
@ -382,7 +370,7 @@ void randomizeMacAddress() {
|
|||||||
|
|
||||||
|
|
||||||
// Need to utilize this function still
|
// Need to utilize this function still
|
||||||
String get_encryption_type(wifi_auth_mode_t encryptionType) {
|
String getEncryptionType(wifi_auth_mode_t encryptionType) {
|
||||||
switch (encryptionType) {
|
switch (encryptionType) {
|
||||||
case (WIFI_AUTH_OPEN):
|
case (WIFI_AUTH_OPEN):
|
||||||
return "Open";
|
return "Open";
|
||||||
|
Loading…
Reference in New Issue
Block a user