radioreference

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package radioreference is a read-only client for RadioReference.com's SOAP web service, used by `gophertrunk hunt` to check whether a discovered trunked system already exists in RadioReference before an operator submits it. RadioReference has no public write API — new systems go through a manual web form reviewed by administrators — so this package never writes anything; it only reads, to avoid duplicate submissions.

Index

Constants

View Source
const DefaultEndpoint = "http://api.radioreference.com/soap2/"

DefaultEndpoint is the RadioReference SOAP web-service endpoint (v3.1).

Variables

View Source
var ErrNoCredentials = errors.New("radioreference: no API key configured")

ErrNoCredentials is returned by NewClient when no API key is configured, so callers can cleanly skip the (optional) duplicate check.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	AppKey   string
	Username string
	Password string
	Version  string // defaults to "latest"
}

Auth carries the RadioReference web-service credentials.

type Candidate

type Candidate struct {
	WACN            uint32
	SystemID        uint16
	Name            string
	ControlChannels []uint32
}

Candidate is the discovered system's identifying fields, passed to MatchAgainst. It mirrors the parts of hunt.DiscoveredSystem relevant to duplicate detection without importing that package (avoiding a dependency cycle — the hunt CLI builds this from its DiscoveredSystem).

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a read-only RadioReference SOAP client. It is safe for sequential use; create one per hunt run.

func NewClient

func NewClient(auth Auth) (*Client, error)

NewClient builds a client. It returns ErrNoCredentials when auth.AppKey is empty so the hunt can degrade gracefully to "no duplicate check".

func (*Client) GetCountyInfo

func (c *Client) GetCountyInfo(ctx context.Context, ctid int) ([]System, error)

GetCountyInfo fetches the trunked systems registered in a RadioReference county (by ctid). Only the brief identity of each system is returned; call GetTrsDetails to enrich a candidate with its SYSID/WACN before matching.

func (*Client) GetTrsDetails

func (c *Client) GetTrsDetails(ctx context.Context, sid int) (System, error)

GetTrsDetails fetches a single trunked system by RadioReference system id. The response is parsed namespace-agnostically (the RR WSDL wraps the return in method-specific elements that vary by SOAP style), pulling the leaf fields used for duplicate detection.

func (*Client) SetEndpoint

func (c *Client) SetEndpoint(url string)

SetEndpoint overrides the SOAP endpoint (used by tests).

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(h *http.Client)

SetHTTPClient overrides the HTTP client (used by tests).

type Hint

type Hint struct {
	SID        int
	Name       string
	Reason     string
	Confidence float64
}

Hint is a possible duplicate match between a discovered system and an existing RadioReference system.

func MatchAgainst

func MatchAgainst(c Candidate, existing []System) []Hint

MatchAgainst compares a discovered system against a list of existing RadioReference systems and returns ranked duplicate hints. The strongest signal is a WACN+SYSID match (a P25 system's globally-unique identity); failing that, an overlapping control-channel frequency; failing that, an exact (case-insensitive) name match. Systems that match nothing are omitted.

type System

type System struct {
	SID      int    // RadioReference system id
	Name     string // system name (sName)
	Type     string // system type (sType), e.g. "Project 25 Phase II"
	SystemID uint16 // decoded SYSID (0 when unknown)
	WACN     uint32 // decoded WACN (0 when unknown)
	// ControlChannels are control-channel frequencies in Hz across the
	// system's sites (best-effort; may be empty if not fetched).
	ControlChannels []uint32
}

System is the subset of a RadioReference trunked-system record this package reads for duplicate detection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL