Files
roro9stack/lib/services/src/settings.h
T
twislaandClaude Opus 5.5 70fb37ebb5 The radio's noise: the GNSS receiver costs 8 dB; a setting pauses it (#20)
Debug Builds: `lora noise test` changes one thing at a time, Sweeps the
band, and reports the floor under each condition; it runs on the device
by itself, since one condition pauses Wi-Fi (not saved, so a restart
brings it back). Result, at 125 kHz: -117 dBm with the antenna switched
off, -106 with the GNSS receiver in standby, -98 with it running. The
receiver's serial line isn't it (one sentence a second changes nothing),
and neither are the main loop, the CPU frequency, Wi-Fi, the screen or
the radio's own regulator, all within 1 dB.

Settings > "Pause GNSS for LoRa", off by default: the receiver waits in
standby while the radio listens or sweeps, except during a Track, and
has a Fix again about 7 s after. The GNSS App says it's paused.

11 dB remain between the antenna with GNSS quiet and the chip alone,
untouched by anything that can be switched from the firmware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
2026-10-06 03:41:15 +02:00

73 lines
2.7 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)
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