feat(cluster): feed the locator store from PSK Reporter, filtered at the broker

The store shipped without its main source. Locators came only from this
station's own WSJT-X decodes, which is what the whole MQTT discussion was
about.

PSK Reporter now feeds it through a new OnGrid callback, fired before any
geographic filtering: what the store wants is "which square is this callsign
in", and that is true whoever happened to hear the report.

The subscription filters on the RECEIVER's square, a level the v2 topic
exposes. Measured on the live feed: the four opening bands unfiltered are 83
messages a second, of which roughly one in a hundred survived the NearKm test
that already existed here — the rest was received, TLS-decrypted, JSON-parsed
and discarded. One ring of squares is 0.2 to 1.2 a second.

By square rather than by DXCC, which was the obvious alternative: one country
measured 1.2 messages a second (OH) against 72.5 (K) on a single band, because
a DXCC can be a continent. By square the same measurement is 0.2 to 1.2, so the
load follows distance — what the feed is actually about — and is the same for
every operator.

Grid chasing subscribes with the "+" band wildcard, so one subscription per
square covers every band instead of one per band per square.

The store gains a source column (decode | mqtt), migrated in place on an
existing file.
This commit is contained in:
2026-08-12 17:16:47 +02:00
parent 82a49150d2
commit 7d33379fe1
15 changed files with 352 additions and 81 deletions
+39 -5
View File
@@ -20,6 +20,8 @@ import (
"hamlog/internal/applog"
"hamlog/internal/bandopen"
"hamlog/internal/geo"
"hamlog/internal/gridcache"
"hamlog/internal/cluster"
"hamlog/internal/pskr"
)
@@ -133,18 +135,46 @@ func (a *App) startBandOpenFeed() {
// on a timer fed by spots this path no longer looks at — so they would
// hang there until the app restarted.
a.clearBandOpenings()
}
chaseGrids := a.gridStore != nil
if !s.Enabled && !chaseGrids {
return
}
// Every spot is measured from the operator's position. Without one there is
// nothing to measure, and a detector fed unmeasurable spots reports nothing
// while looking like it is working.
if !a.opSet {
applog.Printf("bandopen: no station grid set — the opening watch needs one to measure a path")
applog.Printf("pskr: no station grid set — the feed needs one to measure a path")
return
}
// Grid chasing wants every band; the opening watch wants its four. "+" is the
// MQTT single-level wildcard, so one subscription per square covers the lot.
bands := s.Bands
if chaseGrids {
bands = []string{"+"}
}
// Filter at the BROKER on the receiver's square rather than receiving the
// world and discarding it here. Measured on the live feed: the four opening
// bands unfiltered are 83 messages a second, of which roughly one in a
// hundred survived the NearKm test below. One ring of squares — about the
// same 300 km — is 0.2 to 1.2 a second, and the same for every operator,
// where filtering by DXCC ranged from 1.2 (OH) to 72.5 (K).
rxGrids := geo.NeighbourGrids(a.opLat, a.opLon, 1)
var onGrid func(call, grid string)
if chaseGrids {
onGrid = func(call, grid string) { a.rememberDecodeGrid(call, grid, gridcache.SourceMQTT) }
}
var onSpot func(pskr.Spot)
if s.Enabled {
onSpot = a.feedBandOpen
}
a.pskr = pskr.New(pskr.Config{
Bands: s.Bands,
OpLat: a.opLat, OpLon: a.opLon,
Bands: bands,
RxGrids: rxGrids,
OpLat: a.opLat, OpLon: a.opLon,
Geo: func(grid string) (int, int, bool) {
lat, lon, ok := gridToLatLon(grid)
if !ok {
@@ -156,12 +186,16 @@ func (a *App) startBandOpenFeed() {
b := int(initialBearingDeg(a.opLat, a.opLon, lat, lon) + 0.5)
return d, b, true
},
OnSpot: a.feedBandOpen,
OnSpot: onSpot,
OnGrid: onGrid,
Logf: applog.Printf,
})
if err := a.pskr.Start(); err != nil {
applog.Printf("bandopen: PSK Reporter feed did not start: %v", err)
applog.Printf("pskr: feed did not start: %v", err)
return
}
applog.Printf("pskr: feed up — bands %v, %d receiver squares (openings=%v, grids=%v)",
bands, len(rxGrids), s.Enabled, chaseGrids)
}
// feedBandOpen hands one PSK Reporter decode to the detector.