aprs

package module
v0.0.0-...-d16569f Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2018 License: MIT Imports: 13 Imported by: 0

README

APRS

MIT License Build Status

Go package for working with APRS string and byte packets. It can upload those packets via APRS-IS or transmit them via TNC KISS.

It fully supports creating weather observations for Citizen Weather Observer Program (CWOP).

Installation

$ go get github.com/ebarkie/aprs

Usage

See USAGE.

Example

package main

import (
	"log"

	"github.com/ebarkie/aprs"
)

func main() {
	w := aprs.Wx{
		Lat:  35.7,
		Lon:  -78.7,
		Type: "DvsVP2+",
	}
	w.Altimeter = 29.70
	w.Humidity = 90
	w.RainLastHour = 0.0
	w.RainLast24Hours = 0.10
	w.Temp = 85
	w.WindDir = 180
	w.WindSpeed = 5

	f := aprs.Frame{
		Dst:  aprs.Addr{Call: "APRS"},
		Src:  aprs.Addr{Call: "aWnnnn"},
		Path: aprs.Path{aprs.Addr{Call: "TCPIP", Repeated: true}},
		Text: w.String(),
	}
	err := f.SendIS("tcp://cwop.aprs.net:14580", -1)
	if err != nil {
		log.Printf("Upload error: %s", err)
	}

	f = aprs.Frame{}
	f.Dst.FromString("APZ001") // Experimental v0.0.1
	f.Src.FromString("N0CALL-13")
	f.Path.FromString("WIDE1-1,WIDE2-1")
	f.Text = w.String()
	err = f.SendKISS("direwolf:8001")
	if err != nil {
		log.Printf("Network TNC transmit error: %s", err)
	}
}

License

Copyright (c) 2016-2018 Eric Barkie. All rights reserved.
Use of this source code is governed by the MIT license that can be found in the LICENSE file.

Documentation

Overview

Package aprs works with APRS string and byte packets. It can upload those packets via APRS-IS or transmit them via TNC KISS.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrCallNotVerified = errors.New("Callsign not verified")
	ErrFrameBadControl = errors.New("Frame Control Field not UI-frame")
	ErrFrameBadProto   = errors.New("Frame Protocol ID not no layer 3 protocol")
	ErrFrameIncomplete = errors.New("Frame incomplete")
	ErrFrameInvalid    = errors.New("Frame is invalid")
	ErrFrameNoLast     = errors.New("Frame incomplete or last path not set")
	ErrFrameShort      = errors.New("Frame too short (16-bytes minimum)")
	ErrProtoScheme     = errors.New("Protocol scheme is unknown")
)

Errors.

View Source
var SwName = "Go"

SwName is the default software name.

View Source
var SwVers = "3"

SwVers is the default software version.

Functions

func DecToDMS

func DecToDMS(l float64, hems [2]string) (float64, float64, string)

decToDMS takes a float latitude or longitude and converts it to degrees, minutes (second as decimal), and a hemisphere string.

func GenPass

func GenPass(call string) (pass uint16)

GenPass generates a verification passcode for the given station.

func RecvIS

func RecvIS(ctx context.Context, dial string, user Addr, pass int, filters ...string) <-chan Frame

RecvIS receives APRS-IS frames over tcp from the specified server. Filter(s) are optional and use the following syntax:

http://www.aprs-is.net/javAPRSFilter.aspx

Types

type Addr

type Addr struct {
	SSID     int
	Repeated bool

	Call string
	// contains filtered or unexported fields
}

Addr represents an APRS callsign, SSID, and associated metadata.

func (Addr) Bytes

func (a Addr) Bytes() []byte

Bytes returns the address in AX.25 byte format.

func (*Addr) FromBytes

func (a *Addr) FromBytes(addr []byte) error

FromBytes sets the address from an AX.25 byte slice.

func (*Addr) FromString

func (a *Addr) FromString(addr string) (err error)

FromString sets the address from a string.

func (Addr) String

func (a Addr) String() (addr string)

String returns the address as a TNC2 formatted string.

Example
a := Addr{Call: "N0CALL", SSID: 13}
fmt.Println(a)
Output:
N0CALL-13

type Frame

type Frame struct {
	Dst  Addr
	Src  Addr
	Path Path
	Text string
}

Frame represents a complete APRS frame.

func (Frame) Bytes

func (f Frame) Bytes() []byte

Bytes returns the Frame in AX.25 byte format. This is suitable for sending to a TNC.

func (*Frame) FromBytes

func (f *Frame) FromBytes(frame []byte) error

FromBytes sets the Frame from an AX.25 byte slice.

func (*Frame) FromString

func (f *Frame) FromString(frame string) (err error)

FromString sets the Frame from a TNC2 formatted string.

This strictly enforces the AX.25 specification and will return errors if callsigns are greater than 6 characters or SSID's are not numeric values between 0 and 15.

func (Frame) SendHTTP

func (f Frame) SendHTTP(dial string, pass int) (err error)

SendHTTP sends a Frame to the specified APRS-IS host over the HTTP protocol. This scheme is the least efficient and requires a verified connection (real callsign and passcode) but is reliable and provides acknowledgement of receipt.

func (Frame) SendIS

func (f Frame) SendIS(dial string, pass int) error

SendIS sends a Frame to the specified APRS-IS dial string. The dial string should be in the form scheme://host:port with scheme being http, tcp, or udp. This is most commonly used for CWOP.

func (Frame) SendKISS

func (f Frame) SendKISS(dial string) (err error)

SendKISS sends a Frame to the specified network TNC device using the KISS protocol for transmission over RF.

func (Frame) SendTCP

func (f Frame) SendTCP(dial string, pass int) (err error)

SendTCP sends a Frame to the specified APRS-IS host over the TCP protocol. This scheme is the oldest, most compatible, and allows unverified connections.

func (Frame) SendUDP

func (f Frame) SendUDP(dial string, pass int) (err error)

SendUDP sends a Frame to the specified APRS-IS host over the UDP protocol. This scheme is the most efficient but requires a verified connection (real callsign and passcode) and has no acknowledgement of receipt.

func (Frame) String

func (f Frame) String() (frame string)

String returns the Frame as a TNC2 formatted string. This is suitable for sending to APRS-IS servers.

Example (Hello)
f := Frame{}
f.Src.FromString("N0CALL-13")
f.Dst.FromString("APZ001")
f.Path.FromString("WIDE1-1,WIDE2-1")
f.Text = "Hello world"
fmt.Println(f)
Output:
N0CALL-13>APZ001,WIDE1-1,WIDE2-1:Hello world
Example (Wx)
f := Frame{}
f.FromBytes(ax25Wx1)
fmt.Println(f)
Output:
KG4HIE>APK102,W4LBT-9,WIDE1,KD4PBS-3*,WIDE2:=3438.51N/07941.15W_120/001g004t073r   p   P000h  b     KU2k
Example (Wx2)
f := Frame{}
f.FromBytes(ax25Wx2)
fmt.Println(f)
Output:
N4MTT-2>APX209,KD4PBS-3*,WIDE2-2:@270055z3548.41N/07846.35W_360/000g000t066r000P000p000h63b10183XU2k

type Path

type Path []Addr

Path represents the APRS digipath.

func (*Path) FromString

func (p *Path) FromString(path string) (err error)

FromString sets the Path from a string of comma separated addresses.

type Wx

type Wx struct {
	Lat  float64
	Lon  float64
	Type string

	Timestamp time.Time

	Altimeter       float64
	Humidity        int
	RainLastHour    float64
	RainLast24Hours float64
	RainToday       float64
	SolarRad        int
	Temp            int
	WindDir         int
	WindGust        int
	WindSpeed       int
}

Wx represents a weather station observation.

func (Wx) String

func (w Wx) String() (s string)

String returns an APRS packet for the provided measurements.

Example
w := testWx
fmt.Println(w)

SwName = "GoTst"
SwVers = "9"
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h..b.....Go3-Stn
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h..b.....GoTst9-Stn
Example (Altimeter)
w := testWx

w.Altimeter = 29.87
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h..b10115GoTst9-Stn
Example (Humidity)
w := testWx

w.Humidity = 61
fmt.Println(w)

w.Humidity = 100
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h61b.....GoTst9-Stn
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h00b.....GoTst9-Stn
Example (Luminosity)
w := testWx

w.SolarRad = 864
fmt.Println(w)

w.SolarRad = 1864
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h..b.....L864GoTst9-Stn
@052035z3542.00N/07842.00W_.../...g...t...r...p...P...h..b.....l864GoTst9-Stn
Example (Rain)
w := testWx

w.RainLastHour = 0.0
w.RainLast24Hours = 0.0
w.RainToday = 0.0
fmt.Println(w)

w.RainLastHour = 0.54
w.RainLast24Hours = 0.23
w.RainToday = 0.21
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_.../...g...t...r000p000P000h..b.....GoTst9-Stn
@052035z3542.00N/07842.00W_.../...g...t...r054p023P021h..b.....GoTst9-Stn
Example (Temp)
w := testWx

w.Temp = -20
fmt.Println(w)

w.Temp = 0
fmt.Println(w)

w.Temp = 72
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_.../...g...t-20r...p...P...h..b.....GoTst9-Stn
@052035z3542.00N/07842.00W_.../...g...t000r...p...P...h..b.....GoTst9-Stn
@052035z3542.00N/07842.00W_.../...g...t072r...p...P...h..b.....GoTst9-Stn
Example (Wind)
w := testWx

w.WindDir = 0
w.WindSpeed = 0
w.WindGust = 0
fmt.Println(w)

w.WindDir = 180
w.WindSpeed = 8
w.WindGust = 16
fmt.Println(w)
Output:
@052035z3542.00N/07842.00W_000/000g000t...r...p...P...h..b.....GoTst9-Stn
@052035z3542.00N/07842.00W_180/008g016t...r...p...P...h..b.....GoTst9-Stn

func (*Wx) Zero

func (w *Wx) Zero()

Zero zeroes all measurements in the observation payload.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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