7uint64_t
inline MurmurOAAT64(
const char* key) {
8 uint64_t h(525201411107845655ull);
9 for (; *key !=
'\0'; ++key) {
11 h *= 0x5bd1e9955bd1e995;
17void ToSsiPwdKey(
const std::string& ssid,
char* result) {
18 uint64_t hash = MurmurOAAT64(ssid.c_str());
23 for (
int i = 0; i < 11; i++) {
24 *result++ = (hash & 0x3F) + 48;
33 : collection_(
"roo/wifi"),
34 is_interface_enabled_(collection_,
"enabled", false),
35 default_ssid_(collection_,
"ssid",
"") {}
38 return is_interface_enabled_.get();
42 is_interface_enabled_.set(enabled);
46 return default_ssid_.get();
50 default_ssid_.set(ssid);
54 roo_prefs::Transaction t(collection_);
55 t.store().clear(
"ssid");
59 std::string& password) {
60 roo_prefs::Transaction t(collection_,
true);
62 ToSsiPwdKey(ssid, pwkey);
63 return (t.store().readString(pwkey, password) == roo_prefs::ReadResult::kOk);
67 roo::string_view password) {
68 roo_prefs::Transaction t(collection_);
70 ToSsiPwdKey(ssid, pwkey);
71 t.store().writeString(pwkey, password);
75 roo_prefs::Transaction t(collection_);
77 ToSsiPwdKey(ssid, pwkey);
78 t.store().clear(pwkey);
bool getIsInterfaceEnabled() override
Returns whether the Wi-Fi interface is enabled.
void setPassword(const std::string &ssid, roo::string_view password) override
Stores a password for an SSID.
bool getPassword(const std::string &ssid, std::string &password) override
Retrieves a stored password for an SSID.
void clearPassword(const std::string &ssid) override
Clears a stored password for an SSID.
void setIsInterfaceEnabled(bool enabled) override
Sets whether the Wi-Fi interface is enabled.
void clearDefaultSSID() override
Clears the default SSID.
ArduinoPreferencesStore()
void setDefaultSSID(const std::string &ssid) override
Sets the default SSID.
std::string getDefaultSSID() override
Returns the default SSID, if any.