rewind

package
v0.0.0-...-b5243b2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package rewind implements the Simple External Application rewind protocol as described at https://wiki.brandmeister.network/index.php/Simple_External_Application

Index

Constants

View Source
const (
	Sign                     = "REWIND01"
	SignLength               = len(Sign)
	CallLength               = 10
	DefaultKeepAliveInterval = time.Second * 5
	DefaultTimeout           = time.Second * 15
	DefaultPort              = 54005
)

Defaults

View Source
const (
	ClassRewindControl = 0x0000
	ClassSystemConsole = 0x0100
	ClassServiceNotice = 0x0200
	ClassDeviceData    = 0x0800
	ClassApplication   = 0x0900
)

Packet classes

View Source
const (
	TypeKeepAlive = ClassRewindControl + iota
	TypeClose
	TypeChallenge
	TypeAuthentication
)

Control types

View Source
const (
	TypeBusyNotice = ClassServiceNotice + iota
	TypeAddressNotice
	TypeBindingNotice
)

Service Notice types

View Source
const (
	ClassKairosData = ClassDeviceData + 0x00
	ClassHyteraData = ClassDeviceData + 0x10
)

Device Data types for various vendors

View Source
const (
	TypeKairosExternalServer = ClassKairosData + iota
	TypeKairosRemoteControl
	TypeKairosSNMPTrap
)

Kairos Data types

View Source
const (
	TypeHyteraPeerData = ClassHyteraData + iota
	TypeHyteraRDACData
	TypeHyteraMediaData
)

Hytera Data types

View Source
const (
	TypeConfiguration = ClassApplication + iota
	TypeSubscription
	TypeDMRDataBase     = ClassApplication + 0x10
	TypeDMRAudioBase    = ClassApplication + 0x20
	TypeDMREmbeddedData = ClassApplication + 0x27
	TypeSuperHeader     = ClassApplication + 0x28
	TypeFailureCode     = ClassApplication + 0x29
)

Application types

View Source
const (
	FlagNone      = 0
	FlagRealTime1 = 1 << iota
	FlagRealTime2
	FlagDefaultSet = FlagNone
)

Flags

View Source
const (
	RoleRepeaterAgent = 0x10
	RoleApplication   = 0x20
)

Roles

View Source
const (
	// OptionSuperHeader enables sending of super header metadata
	OptionSuperHeader = 1 << iota

	// OptionLinearFrame enables sending of linear coded AMBE without FEC
	OptionLinearFrame
)

Options

View Source
const (
	DataLength        = SignLength + 10
	DescriptionLength = 96
	SuperHeaderLength = 12 + 2*CallLength
)

Packet sizes

View Source
const (
	ServiceSimpleApplication = RoleApplication + 0
)

Services

View Source
const (
	TypeReport = ClassSystemConsole + iota
)

System Console types

Variables

View Source
var Debug bool

Debug enables debug messages

Functions

This section is empty.

Types

type Address

type Address uint32

Address is a struct in_addr / in_addr_t

type AddressData

type AddressData struct {
	Address Address
	Port    uint16
}

AddressData contains a network address

type BindingData

type BindingData []uint16

type Call

type Call [CallLength]byte

Call is the callsign of a station

func (Call) String

func (c Call) String() string

type Client

type Client struct {
	KeepAlive time.Duration
	Timeout   time.Duration

	// Description of the client
	Description string

	// RemoteID of the client
	RemoteID uint32

	// Options
	Options uint32

	// Subscriptions is a map of Target ID and session type
	Subscriptions map[uint32]SessionType
	// contains filtered or unexported fields
}

Client implementing the Rewind protocol

func NewClient

func NewClient(addr, password string) (*Client, error)

NewClient sets up a Rewind protocol client with defaults configured.

func (*Client) Close

func (c *Client) Close() error

Close the client socket and stop the receiver loop after it has been started by ListenAndServe.

func (*Client) ListenAndServe

func (c *Client) ListenAndServe(p chan<- Payload) error

ListenAndServe starts the packet receiver and decoder. Decoded payloads that are not part of the Rewind protocol are sent to channel p.

func (*Client) Subscribe

func (c *Client) Subscribe(id uint32, typ SessionType) error

Subscribe to a destination DMR ID and Session type.

type ConfigurationData

type ConfigurationData uint32

ConfigurationData contains Options

func (ConfigurationData) Len

func (c ConfigurationData) Len() int

type DMRAudio

type DMRAudio struct {
	Type uint8
	Data []byte
}

DMRAudio is a DMR audio packet

func (DMRAudio) Len

func (a DMRAudio) Len() int

type DMRData

type DMRData struct {
	Type uint8
	Data []byte
}

DMRData is a DMR data packet

func (DMRData) Len

func (d DMRData) Len() int

type Data

type Data struct {
	// Sign of protocol
	Sign [SignLength]byte

	// Type of data
	Type uint16

	// Flags for data
	Flags uint16

	// Sequence number
	Sequence uint32

	// Length of data
	Length uint16
}

Data header

type Payload

type Payload interface {
	Len() int
}

Payload to be sent along with data

type Raw

type Raw struct {
	Type uint16
	Data []byte
}

Raw (uninterpreted) packet

func (Raw) Len

func (r Raw) Len() int

type SessionType

type SessionType uint32

SessionType type of transmission

const (
	PrivateVoice SessionType = 5
	GroupVoice   SessionType = 7
)

Session types

type SubscriptionData

type SubscriptionData struct {
	// Type of session
	Type SessionType

	// Target ID
	Target uint32
}

SubscriptionData contains Session types

func (SubscriptionData) Len

func (d SubscriptionData) Len() int

type SuperHeader

type SuperHeader struct {
	// Type of session
	Type uint32

	// Source ID
	Source uint32

	// Target ID
	Target uint32

	// SourceCall is the source call (or zeros)
	SourceCall Call

	// TargetCall is the target call (or zeros)
	TargetCall Call
}

SuperHeader contains metadata about a transmission

func (SuperHeader) Len

func (h SuperHeader) Len() int

type VersionData

type VersionData struct {
	// RemoteID is the remote application ID
	RemoteID uint32

	// Service type
	Service uint8

	// Description of software and version
	Description [DescriptionLength]byte
}

VersionData informs the server about the client

func (VersionData) Len

func (vd VersionData) Len() int

Len is the packet size

Jump to

Keyboard shortcuts

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