Checkpoint
Some checks failed
Test and build / Test and lint (push) Failing after 36s
Test and build / Build collector (push) Failing after 43s
Test and build / Build receiver (push) Failing after 42s

This commit is contained in:
2026-03-05 15:38:18 +01:00
parent 3106b2cf45
commit 13afa08e8a
108 changed files with 19509 additions and 729 deletions

View File

@@ -64,7 +64,6 @@ func run(ctx context.Context, command *cli.Command) error {
if err != nil {
return err
}
defer collector.Close()
broker, err := hamview.NewBroker(&config.Broker)
if err != nil {
@@ -79,7 +78,11 @@ func run(ctx context.Context, command *cli.Command) error {
protocol.APRS,
protocol.MeshCore,
} {
go collector.Collect(broker, proto+"/packet")
go func() {
if err := collector.Collect(broker, proto+"/packet/+"); err != nil {
logger.Fatalf("Error collecting %s packets: %v", proto, err)
}
}()
}
return cmd.WaitForInterrupt(logger, "collector")

View File

@@ -2,19 +2,22 @@ package main
import (
"context"
"encoding/base64"
"time"
"github.com/urfave/cli/v3"
"git.maze.io/go/ham/protocol/aprs/aprsis"
"git.maze.io/go/ham/radio"
"git.maze.io/ham/hamview"
"git.maze.io/ham/hamview/cmd"
)
type aprsisConfig struct {
Broker hamview.BrokerConfig `yaml:"broker"`
Receiver hamview.APRSISConfig `yaml:"receiver"`
Include []string `yaml:"include"`
Broker hamview.BrokerConfig `yaml:"broker"`
Receiver hamview.APRSISConfig `yaml:"receiver"`
Radio map[string]*radio.Info `yaml:"radio"`
Include []string `yaml:"include"`
}
func (config *aprsisConfig) Includes() []string {
@@ -43,15 +46,19 @@ func runAPRSIS(ctx context.Context, command *cli.Command) error {
}
proxy.OnClient = func(callsign string, client *aprsis.ProxyClient) {
go receiveAPRSIS(&config.Broker, callsign, client)
go receiveAPRSIS(&config.Broker, callsign, client, config.Radio[callsign])
}
return waitForInterrupt()
}
func receiveAPRSIS(config *hamview.BrokerConfig, callsign string, client *aprsis.ProxyClient) {
func receiveAPRSIS(config *hamview.BrokerConfig, callsign string, client *aprsis.ProxyClient, extra *radio.Info) {
defer func() { _ = client.Close() }()
if extra == nil {
logger.Warnf("receiver: no radio info configured for %s!", callsign)
}
broker, err := hamview.NewBroker(config)
if err != nil {
logger.Errorf("receiver: can't setup to broker: %v", err)
@@ -59,19 +66,81 @@ func receiveAPRSIS(config *hamview.BrokerConfig, callsign string, client *aprsis
}
defer func() { _ = broker.Close() }()
info := client.Info() // TODO: enrich info from config?
info := client.Info()
if extra != nil {
info.Manufacturer = pick(info.Manufacturer, extra.Manufacturer)
info.Device = pick(info.Device, extra.Device)
info.FirmwareDate = pickTime(info.FirmwareDate, extra.FirmwareDate)
info.FirmwareVersion = pick(info.FirmwareVersion, extra.FirmwareVersion)
info.Antenna = pick(info.Antenna, extra.Antenna)
info.Modulation = pick(info.Modulation, extra.Modulation)
info.Position = pickPosition(info.Position, extra.Position)
info.Frequency = pickFloat64(info.Frequency, extra.Frequency)
info.Bandwidth = pickFloat64(info.Bandwidth, extra.Bandwidth)
info.Power = pickFloat64(info.Power, extra.Power)
info.Gain = pickFloat64(info.Gain, extra.Gain)
info.LoRaSF = pickUint8(info.LoRaSF, extra.LoRaSF)
info.LoRaCR = pickUint8(info.LoRaCR, extra.LoRaCR)
}
if err = broker.StartRadio("aprs", info); err != nil {
logger.Fatalf("receiver: can't start broker: %v", err)
return
}
id := base64.RawURLEncoding.EncodeToString([]byte(callsign))
logger.Infof("receiver: start receiving packets from station: %s", callsign)
for packet := range client.RawPackets() {
logger.Debugf("aprs packet: %#+v", packet)
if err := broker.PublishPacket("aprs/packet", packet); err != nil {
if err := broker.PublishPacket("aprs/packet/"+id, packet); err != nil {
logger.Error(err)
}
}
logger.Infof("receiver: stopped receiving packets from station: %s", callsign)
}
func pick(ss ...string) string {
for _, s := range ss {
if s != "" {
return s
}
}
return ""
}
func pickFloat64(vv ...float64) float64 {
for _, v := range vv {
if v != 0 {
return v
}
}
return 0
}
func pickPosition(vv ...*radio.Position) *radio.Position {
for _, v := range vv {
if v != nil {
return v
}
}
return nil
}
func pickTime(tt ...time.Time) time.Time {
for _, t := range tt {
if !t.Equal(time.Time{}) {
return t
}
}
return time.Time{}
}
func pickUint8(vv ...uint8) uint8 {
for _, v := range vv {
if v != 0 {
return v
}
}
return 0
}

View File

@@ -2,6 +2,7 @@ package main
import (
"context"
"encoding/base64"
"github.com/urfave/cli/v3"
@@ -48,6 +49,9 @@ func runMeshCore(ctx context.Context, command *cli.Command) error {
return err
}
// Node id
id := base64.RawURLEncoding.EncodeToString([]byte(info.Name))
// Trace scheduler
//go receiver.RunTraces()
@@ -68,7 +72,7 @@ func runMeshCore(ctx context.Context, command *cli.Command) error {
payloadType,
len(packet.Raw))
}
if err = broker.PublishPacket("meshcore/packet", packet); err != nil {
if err = broker.PublishPacket("meshcore/packet/"+id, packet); err != nil {
logger.Errorf("receiver: failed to publish packet: %v", err)
}
}