homebrew

package
v0.0.0-...-344dc5b Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package homebrew implements the Home Brew DMR IPSC protocol

Index

Constants

This section is empty.

Variables

View Source
var (
	DMRData         = []byte("DMRD")
	MasterNAK       = []byte("MSTNAK")
	MasterACK       = []byte("MSTACK")
	RepeaterLogin   = []byte("RPTL")
	RepeaterKey     = []byte("RPTK")
	MasterPing      = []byte("MSTPING")
	RepeaterPong    = []byte("RPTPONG")
	MasterClosing   = []byte("MSTCL")
	RepeaterClosing = []byte("RPTCL")
)

Messages as documented by DL5DI, G4KLX and DG1HT, see "DMRplus IPSC Protocol for HB repeater (20150726).pdf".

View Source
var (
	AuthTimeout  = time.Second * 5
	PingInterval = time.Second * 5
	PingTimeout  = time.Second * 15
	SendInterval = time.Millisecond * 30
)

We ping the peers every minute

Functions

func BuildData

func BuildData(p *dmr.Packet, repeaterID uint32) []byte

BuildData converts DMR packet format to Homebrew packet format.

func ParseData

func ParseData(data []byte) (*dmr.Packet, error)

ParseData converts Homebrew packet format to DMR packet format.

Types

type AuthStatus

type AuthStatus uint8
const (
	AuthNone AuthStatus = iota
	AuthBegin
	AuthDone
	AuthFailed
)

func (*AuthStatus) String

func (a *AuthStatus) String() string

type Config

type Config struct {
	// ID is the local DMR ID.
	ID uint32

	// PeerID is the remote DMR ID.
	PeerID uint32

	// AuthKey is the shared secret.
	AuthKey string
}

type ConfigFunc

type ConfigFunc func() *RepeaterConfiguration

ConfigFunc returns an actual RepeaterConfiguration instance when called. This is used by the DMR repeater to poll for current configuration, statistics and metrics.

type Homebrew

type Homebrew struct {
	Config *RepeaterConfiguration
	Peer   map[string]*Peer
	PeerID map[uint32]*Peer
	// contains filtered or unexported fields
}

Homebrew is implements the Homebrew IPSC DMR Air Interface protocol

func New

func New(config *RepeaterConfiguration, addr *net.UDPAddr) (*Homebrew, error)

New creates a new Homebrew repeater

func (*Homebrew) Active

func (h *Homebrew) Active() bool

func (*Homebrew) Close

func (h *Homebrew) Close() error

Close stops the active listeners

func (*Homebrew) GetPacketFunc

func (h *Homebrew) GetPacketFunc() dmr.PacketFunc
func (h *Homebrew) Link(peer *Peer) error

Link establishes a new link with a peer

func (*Homebrew) ListenAndServe

func (h *Homebrew) ListenAndServe() error

func (*Homebrew) Send

func (h *Homebrew) Send(p *dmr.Packet) error

Send a packet to the peers. Will block until the packet is sent.

func (*Homebrew) SetPacketFunc

func (h *Homebrew) SetPacketFunc(f dmr.PacketFunc)
func (h *Homebrew) Unlink(id uint32) error

func (*Homebrew) WritePacketToPeer

func (h *Homebrew) WritePacketToPeer(p *dmr.Packet, peer *Peer) error

func (*Homebrew) WriteToPeer

func (h *Homebrew) WriteToPeer(b []byte, peer *Peer) error

func (*Homebrew) WriteToPeerWithID

func (h *Homebrew) WriteToPeerWithID(b []byte, id uint32) error

type Peer

type Peer struct {
	ID                  uint32
	Addr                *net.UDPAddr
	AuthKey             []byte
	Status              AuthStatus
	Nonce               []byte
	Token               []byte
	Incoming            bool
	UnlinkOnAuthFailure bool
	PacketReceived      dmr.PacketFunc
	Last                struct {
		PacketSent     time.Time
		PacketReceived time.Time
		PingSent       time.Time
		PingReceived   time.Time
		PongReceived   time.Time
	}
	// contains filtered or unexported fields
}

Peer is a remote repeater that also speaks the Homebrew protocol

func (*Peer) CheckRepeaterID

func (p *Peer) CheckRepeaterID(id []byte) bool

func (*Peer) UpdateToken

func (p *Peer) UpdateToken(nonce []byte)

type RepeaterConfiguration

type RepeaterConfiguration struct {
	Callsign    string
	ID          uint32 // Our RepeaterID
	RXFreq      uint32
	TXFreq      uint32
	TXPower     uint8
	ColorCode   uint8
	Latitude    float32
	Longitude   float32
	Height      uint16
	Location    string
	Description string
	URL         string
	SoftwareID  string
	PackageID   string
}

RepeaterConfiguration holds information about the current repeater. It should be returned by a callback in the implementation, returning actual information about the current repeater status.

func (*RepeaterConfiguration) Bytes

func (r *RepeaterConfiguration) Bytes() []byte

Bytes returns the configuration as bytes.

func (*RepeaterConfiguration) String

func (r *RepeaterConfiguration) String() string

String returns the configuration as string.

Jump to

Keyboard shortcuts

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