Public Access
The SSH App opens one session to a shell, over libssh (LibSSH-ESP32 5.10.0) on mbedTLS. A server is trusted the first time on its fingerprint, and a changed key is a warning with Cancel selected. The password is typed each time and kept nowhere; or the device makes itself an Ed25519 key, whose public half is shown, written to /ssh/id_ed25519.pub and printed by `ssh status`. lib/term is the terminal: what a shell, less, top, nano and vim send, with sixteen colours, scroll regions, the alternate screen and 100 lines of scrollback. Five text sizes with Ctrl and + or -, from 60x20 to 26x8, told to the far end. The session goes on when the App is left; SSH shows in the Status Bar. `ssh user@host` in the Shell opens the App. Also: - Keys that aren't characters carry Shift, Ctrl and Alt. The terminal needs it, and it makes Ctrl+Fn+up/down in a note and Shift+Tab in Gemini work from the real keyboard. - IRC doesn't try to connect under 60 KB free: started with a session open, its TLS handshake took the heap down to 236 bytes. - libssh's own curve25519 is left out of the build (scripts/libssh_filter.py): libsodium's has the same names. Costs 292 KB of flash and about 50 KB of heap while a session is open; not started under 75 KB free. Docs: guide page, how-to, FAQ, home page, Status Bar, SD card folders, the memory how-to, README, glossary, N1 notes with Q254 to Q266 and the checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
84 lines
3.8 KiB
C++
84 lines
3.8 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
|
|
#include "event_bus.h"
|
|
#include "key_value_store.h"
|
|
|
|
namespace roro {
|
|
|
|
enum class Setting : uint8_t {
|
|
SetupDone, // bool: first-boot wizard completed
|
|
LongName, // string, 1..39 bytes
|
|
ShortName, // string, 1..4 bytes
|
|
Region, // string, a known Region ("EU868")
|
|
RegionConfirmed, // bool: nothing transmits until true
|
|
Timezone, // string, POSIX TZ
|
|
Brightness, // int, 10..100 %
|
|
DimTimeoutS, // int, 5..600, below OffTimeoutS
|
|
OffTimeoutS, // int, 10..3600, above DimTimeoutS
|
|
Sound, // bool
|
|
ProbeMacRaw, // bool: probe-request Logs keep raw MAC addresses
|
|
WifiEnabled, // bool: the Wi-Fi Service stays Connected when a Saved Network is in range
|
|
GnssEnabled, // bool: the GNSS Service reads the receiver (M2, Q58)
|
|
CoordinatesDms, // bool: show degrees, minutes and seconds instead of decimal degrees (Q64)
|
|
LoraPreset, // int: the LoRa Scanner's Meshtastic preset, an index into the EU868 list (M3, Q95)
|
|
Dns1, // string: the first DNS server, an IPv4 address (S1, Q108, Q109)
|
|
Dns2, // string: the second, or empty
|
|
DnsAlways, // bool: use them on Automatic (DHCP) networks too, instead of DHCP's
|
|
Ntp1, // string: the first NTP server, a host name or an IPv4 address (S1, Q110)
|
|
Ntp2, // string: the second, or empty
|
|
GnssQuietForLora, // bool: put the GNSS receiver in standby while the LoRa radio listens (issue #20)
|
|
CheckUpdates, // bool: look for a newer release on Gitea once a day (R1, Q165)
|
|
DebugConsole, // bool: the Debug Console listens on Wi-Fi (ADR 0010, Q189: off unless switched on)
|
|
DebugToken, // string: its token, tidied (debug_auth.h); empty until the console is first switched on
|
|
HelpTold, // bool: this device has been told about the help key once (issue #69, Q201)
|
|
VpnConfig, // string: the WireGuard tunnel as a .conf (wg_config.h), private key included: never shown (issue #8)
|
|
VpnAuto, // bool: the tunnel starts whenever Wi-Fi is connected (Q247: off unless switched on)
|
|
SshHosts, // string: the SSH App's saved hosts, one user@host[:port] a line (issue #2, ssh_hosts.h)
|
|
SshKnown, // string: the fingerprint each server showed first, one "host:port fingerprint" a line
|
|
SshKey, // string: this device's own SSH private key, as OpenSSH writes one: never shown
|
|
SshPublic, // string: its public half, the line to put in a server's authorized_keys
|
|
SshFont, // int: the terminal's font, 0 (smallest) to 4
|
|
Count
|
|
};
|
|
|
|
// Typed, validated settings in internal flash. Every accepted change is persisted immediately and
|
|
// announced with a SettingChanged event; rejected values leave the current value untouched.
|
|
class Settings {
|
|
public:
|
|
Settings(KeyValueStore& store, EventBus& bus);
|
|
|
|
// Reads every setting; missing or invalid stored values fall back to defaults.
|
|
void load();
|
|
|
|
int32_t getInt(Setting s) const;
|
|
bool getBool(Setting s) const;
|
|
const std::string& getString(Setting s) const;
|
|
|
|
bool setInt(Setting s, int32_t value);
|
|
bool setBool(Setting s, bool value);
|
|
bool setString(Setting s, const std::string& value);
|
|
|
|
bool canTransmit() const { return getBool(Setting::RegionConfirmed); }
|
|
|
|
static const char* key(Setting s);
|
|
|
|
private:
|
|
struct Value {
|
|
int32_t i = 0;
|
|
std::string str;
|
|
};
|
|
|
|
bool validInt(Setting s, int32_t value) const;
|
|
bool validString(Setting s, const std::string& value) const;
|
|
void changed(Setting s);
|
|
|
|
KeyValueStore& store_;
|
|
EventBus& bus_;
|
|
std::array<Value, static_cast<size_t>(Setting::Count)> values_;
|
|
};
|
|
|
|
} // namespace roro
|