Files
roro9stack/lib/apps_model/src/settings_menu.h
T
twislaandClaude Opus 5.5 4404dd9380 VPN: a WireGuard tunnel (#8)
The device joins a WireGuard network over whatever Wi-Fi it is on: one
peer, IPv4. A client's .conf is imported from the card (/vpn/wg0.conf) and
kept in the device's settings, private key included, never shown; Settings
offers to delete the file. A switch brings the tunnel up until the next
restart, "Start with Wi-Fi" every time; it waits for the clock, which a
handshake needs. VPN shows in the Status Bar.

The protocol is esphome/wireguard 0.4.8. It calls lwIP without lwIP's lock,
which this framework checks: every call into it is made with the lock held.

What goes through the tunnel is everything (AllowedIPs 0.0.0.0/0) or the
one subnet the device's tunnel address is in: lwIP routes by an
interface's subnet or by default, nothing finer. The import says how many
ranges it can't reach.

Checked against a test peer in both directions and against a real server,
with a configuration uploaded from a phone (docs/milestones/N1.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
2026-10-08 01:49:47 +02:00

43 lines
1.3 KiB
C++

#pragma once
#include <string>
#include <vector>
#include "settings.h"
namespace roro {
// What the Settings App lists: one row per user-facing setting (plus sub-pages), with readable
// values, choice lists and validation messages. Rendering and navigation live in the App.
class SettingsMenu {
public:
enum class Row { LongName, ShortName, Region, Timezone, Brightness, DimTimeout, OffTimeout, Sound, Gnss, GnssQuiet, Coordinates, ProbeMacs, Wifi, CheckUpdates, Firmware, Vpn, DebugConsole, About };
enum class Kind { Text, Choice, Toggle, Slider, Page };
explicit SettingsMenu(Settings& settings) : settings_(settings) {}
int count() const;
Row row(int i) const;
Kind kind(int i) const;
std::string label(int i) const;
std::string value(int i) const;
// Choice rows
std::vector<std::string> choices(int i) const;
int currentChoice(int i) const; // -1 if the current value isn't one of the choices
std::string choose(int i, int choice); // empty on success, otherwise why it was refused
// Toggle and Slider rows
void toggle(int i);
void adjust(int i, int direction);
// Text rows
int maxBytes(int i) const;
std::string setText(int i, const std::string& text); // empty on success, otherwise why
private:
Settings& settings_;
};
} // namespace roro