mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-11-22 06:17:03 +00:00
Both features are OPT-IN ("los" and "planner" config blocks, default
off); with them off nothing is fetched and payloads are unchanged.
Route view
- Multi-path picker discoverability: on-map "N hops shown · tap to see
all" badge, picker pulse (reduced-motion safe), one-time tip, row hover
arrow; "no GPS" hops counted apart from "unresolved".
- Line of sight for every leg of a packet route: clear / marginal /
blocked chips (first-Fresnel clearance, k=4/3), obstruction markers on
the map, docked terrain-profile panel with antenna/frequency inputs and
a &los= deep link. Backed by GET /api/elevation/profile, an Open-Meteo
proxy that only accepts known node positions, with weighted budgets,
back-off and a per-IP limit.
Repeater planner (#/tools/planner)
- Chain: LOS on every leg between any number of points or nodes.
- Relay: best single relay for A→B among known repeaters and open
terrain.
- Area: suggested new repeater sites that best join the existing
repeater backbone in a box up to 100×100 km, picked greedily to merge
clusters, then remove single points of failure, then reach unlinked
repeaters.
- Terrain: SRTM 1° tiles from AWS Open Data, in memory only (~90 m,
bounded LRU); the server stays read-only. Exact-length gunzip, fetch
budget with back-off, missing terrain reported rather than read as sea
level, fuzzed pixel maths.
- GET /api/planner/{profile,relay,coverage}: quantised cache keys, 202 +
progress then cached 200, separate compute slots, per-IP and global
limits, failed jobs remembered, unpolled jobs cancelled. Nodes pass the
same blacklist / hidden-name / geo_filter rules as /api/nodes. The Go
LOS maths matches public/los.js on shared test vectors.
Also: the per-IP client limiter is extracted from elevation.go into
client_limit.go (behaviour-preserving) so both features share it.
Perf (real SRTM): coverage cold 1.5-5.6 s (tile download), warm 10 ms;
worst real compute 545 ms; peak RSS 91 MiB; live /api/nodes and
/api/packets p95 at most 1.6x while a job computes (GOMAXPROCS=2).
Tests: Go suites for elevation, terrain (fuzz), LOS vectors, graph
(brute-force property test), search and planner API; frontend unit
suites in test-all.sh; Playwright e2e for route LOS and the planner.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: efiten <erwin.fiten@gmail.com>
78 lines
2.5 KiB
Go
78 lines
2.5 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"log"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLOSConfigDisabledByDefault(t *testing.T) {
|
|
var c *LOSConfig
|
|
if c.enabled() {
|
|
t.Fatal("nil los config must be disabled")
|
|
}
|
|
if c.clientConfig() != nil {
|
|
t.Fatal("disabled los must not appear in /api/config/client")
|
|
}
|
|
if (&LOSConfig{}).clientConfig() != nil {
|
|
t.Fatal("enabled=false must not appear in /api/config/client")
|
|
}
|
|
}
|
|
|
|
func TestLOSConfigDefaults(t *testing.T) {
|
|
cc := (&LOSConfig{Enabled: true}).clientConfig()
|
|
if cc == nil {
|
|
t.Fatal("enabled los must appear in /api/config/client")
|
|
}
|
|
if cc.FrequencyMHz != defaultLOSFrequencyMHz || cc.AntennaHeightM != defaultLOSAntennaM ||
|
|
cc.KFactor != defaultLOSKFactor || cc.MaxPoints != losMaxPoints || cc.MaxLegKm != losMaxLegKm {
|
|
t.Fatalf("unexpected defaults: %+v", *cc)
|
|
}
|
|
// The sample count varies per leg now; the client config no longer names one.
|
|
b, _ := json.Marshal(cc)
|
|
if strings.Contains(string(b), "samples") {
|
|
t.Fatalf("client config %s still carries samples", b)
|
|
}
|
|
if _, warns := (&LOSConfig{Enabled: true}).resolved(); len(warns) != 0 {
|
|
t.Fatalf("default warns: %v", warns)
|
|
}
|
|
}
|
|
|
|
func TestLOSConfigOverridesAndValidation(t *testing.T) {
|
|
r, warns := (&LOSConfig{Enabled: true, FrequencyMHz: 869.618, AntennaHeightM: 12, KFactor: 1}).resolved()
|
|
if r.FrequencyMHz != 869.618 || r.AntennaHeightM != 12 || r.KFactor != 1 || len(warns) != 0 {
|
|
t.Fatalf("valid overrides not kept: %+v %v", r, warns)
|
|
}
|
|
r, warns = (&LOSConfig{Enabled: true, FrequencyMHz: 50, AntennaHeightM: -3, KFactor: 99}).resolved()
|
|
if r.FrequencyMHz != defaultLOSFrequencyMHz || r.AntennaHeightM != defaultLOSAntennaM || r.KFactor != defaultLOSKFactor {
|
|
t.Fatalf("invalid values must fall back to defaults: %+v", r)
|
|
}
|
|
if len(warns) != 3 {
|
|
t.Fatalf("want 3 warnings, got %v", warns)
|
|
}
|
|
}
|
|
|
|
func TestLOSConfigLog(t *testing.T) {
|
|
var buf bytes.Buffer
|
|
prev, flags := log.Writer(), log.Flags()
|
|
log.SetOutput(&buf)
|
|
t.Cleanup(func() { log.SetOutput(prev); log.SetFlags(flags) })
|
|
logLOSConfig(&LOSConfig{Enabled: true, FrequencyMHz: 50})
|
|
out := buf.String()
|
|
for _, want := range []string{
|
|
"los.frequencyMhz must be within 100-6000; using the default",
|
|
"[los] enabled (910.525 MHz, antenna=5.0 m, k=1.333, up to 16 terrain tiles a request)",
|
|
} {
|
|
if !strings.Contains(out, want) {
|
|
t.Errorf("log lacks %q:\n%s", want, out)
|
|
}
|
|
}
|
|
buf.Reset()
|
|
logLOSConfig(&LOSConfig{})
|
|
if buf.Len() != 0 {
|
|
t.Fatalf("disabled los logged %q", buf.String())
|
|
}
|
|
}
|