42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <Preferences.h>
|
|
|
|
struct Config {
|
|
String wifi_ssid;
|
|
String wifi_password;
|
|
String api_url;
|
|
String display_id;
|
|
String api_token;
|
|
int refresh_sec;
|
|
|
|
void load() {
|
|
Preferences prefs;
|
|
prefs.begin("epaper", true); // read-only
|
|
wifi_ssid = prefs.getString("wifi_ssid", "");
|
|
wifi_password = prefs.getString("wifi_password", "");
|
|
api_url = prefs.getString("api_url", "");
|
|
display_id = prefs.getString("display_id", "1");
|
|
api_token = prefs.getString("api_token", "");
|
|
refresh_sec = prefs.getInt ("refresh_sec", 300);
|
|
prefs.end();
|
|
}
|
|
|
|
void save() const {
|
|
Preferences prefs;
|
|
prefs.begin("epaper", false); // read-write
|
|
prefs.putString("wifi_ssid", wifi_ssid);
|
|
prefs.putString("wifi_password", wifi_password);
|
|
prefs.putString("api_url", api_url);
|
|
prefs.putString("display_id", display_id);
|
|
prefs.putString("api_token", api_token);
|
|
prefs.putInt ("refresh_sec", refresh_sec);
|
|
prefs.end();
|
|
}
|
|
|
|
bool isConfigured() const {
|
|
return wifi_ssid.length() > 0 && api_url.length() > 0;
|
|
}
|
|
};
|