#pragma once #include #include #include "key_value_store.h" namespace roro { struct SavedNetwork { std::string ssid; std::string password; // empty for an open network bool hidden = false; // doesn't broadcast its name, so never shows up in scans }; // The Saved Networks the Wi-Fi Service may join (see CONTEXT.md), persisted in internal flash. class SavedNetworks { public: static constexpr int kMax = 8; explicit SavedNetworks(KeyValueStore& store) : store_(store) {} void load(); int count() const { return static_cast(networks_.size()); } const SavedNetwork& at(int i) const { return networks_[i]; } const SavedNetwork* find(const std::string& ssid) const; // Adds, or updates the password of an existing SSID. Empty on success, otherwise why not. std::string add(const std::string& ssid, const std::string& password, bool hidden = false); void forget(const std::string& ssid); private: void save(); KeyValueStore& store_; std::vector networks_; }; } // namespace roro