Public Access
The plan and decisions Q105 to Q116 (docs/milestones/S1.md). lib/net: strict IPv4 parsing, prefix and mask, and the checks a Fixed setting must pass, each refusal with its reason. A Saved Network is Automatic or Fixed (address/prefix and an optional gateway), kept with it in flash. Settings: two DNS servers (9.9.9.9, 1.1.1.1), "Always use my DNS", two NTP servers (pool.ntp.org, time.cloudflare.com). Host-tested: 383 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "ipv4.h"
|
|
#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
|
|
bool fixed = false; // S1, Q105: Fixed address (`ip`), or Automatic (DHCP)
|
|
net::FixedIp ip;
|
|
};
|
|
|
|
// 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<int>(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);
|
|
// The IP setting: Fixed with these values, or Automatic (DHCP) for nullptr. Empty, or why not.
|
|
std::string setIp(const std::string& ssid, const net::FixedIp* fixed);
|
|
|
|
private:
|
|
void save();
|
|
|
|
KeyValueStore& store_;
|
|
std::vector<SavedNetwork> networks_;
|
|
};
|
|
|
|
} // namespace roro
|