Documentation
¶
Overview ¶
Package callsign provides shared parsing, N0CALL detection, resolution, and APRS-IS passcode computation for amateur-radio callsigns. It is a leaf package: it imports nothing from the rest of graywolf.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCallsignEmpty is returned by Resolve when neither the override // nor the station callsign supplies a non-empty value. ErrCallsignEmpty = errors.New("callsign: empty") // ErrCallsignN0Call is returned by Resolve when the chosen value is // N0CALL (case-insensitive, SSID-agnostic). N0CALL is the default // "unconfigured" placeholder and must never reach the air. ErrCallsignN0Call = errors.New("callsign: N0CALL") )
Sentinel errors returned by Resolve. Callers can branch on these via errors.Is to distinguish the two failure modes.
Functions ¶
func APRSPasscode ¶
APRSPasscode computes the APRS-IS verification passcode for a callsign. The SSID is stripped and only the base call (uppercased, truncated to 10 characters) is hashed. This is a direct port of the canonical JavaScript algorithm used across the APRS ecosystem.
Malformed input yields the hash of the empty string (0x73e2 & 0x7fff = 0x73e2 = 29666). This behaviour is intentionally permissive; callers that need input validation should use Parse or Resolve first.
func IsN0Call ¶
IsN0Call reports whether s refers to N0CALL, the default "unconfigured" placeholder callsign. Matching is case-insensitive and SSID-agnostic, so "N0CALL", "n0call", "N0CALL-7", and " n0call " all return true. An empty string or otherwise malformed input returns false; callers should do a separate empty-check when they care about that case.
func Parse ¶
Parse splits a callsign string of the form "CALL" or "CALL-SSID" into its base and SSID components. The input is trimmed of leading and trailing whitespace before parsing; the returned base preserves the original case (uppercasing is the caller's responsibility — see Resolve).
ok is false for obviously malformed input:
- empty or whitespace-only
- leading dash ("-9")
- trailing dash ("KE7XYZ-")
- multiple dashes ("K-E-7")
- internal whitespace ("KE7 XYZ")
The SSID is returned as a string, not an int, because SSIDs like "0", "15", and "16" all appear in real configs and numeric validity is a display/validation concern, not a parsing one.
func Resolve ¶
Resolve returns a usable station callsign or an error.
Selection rule:
- a non-empty (post-trim) override wins
- otherwise station is used
If the chosen value is empty, ErrCallsignEmpty is returned. If the chosen value is N0CALL (case-insensitive, SSID-agnostic), ErrCallsignN0Call is returned. On success, the value is returned trimmed and uppercased.
Callers can use errors.Is(err, ErrCallsignEmpty) or errors.Is(err, ErrCallsignN0Call) to distinguish the two failure modes.
Types ¶
This section is empty.