bitoip

package
v0.0.0-...-f26e4ea Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright (C) 2019 Graeme Sutherland, Nodestone Limited

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const CallsignSize = 16
View Source
const MaxBitEvents = (MaxMessageSizeInBytes - 22) / 5

slightly random

View Source
const MaxChannelsPerMessage int = (MaxMessageSizeInBytes - 1) / 2

List of Channels

View Source
const MaxMessageSizeInBytes = 200

conservative UDP payload in bytes

View Source
const MaxNsPerCarrierEvent = 2 ^ 32

Variables

View Source
var RelTypeMap = map[RelType]string{
	POC:   "-pre-alpha",
	Alpha: "-alpha",
	Beta:  "-beta",
	RC:    "-rc",
	Final: "",
}

Functions

func EncodePayload

func EncodePayload(verb MessageVerb, payload Payload) []byte

func ProtocolVersionBytes

func ProtocolVersionBytes() []byte

func ProtocolVersionString

func ProtocolVersionString() string

func UDPConnection

func UDPConnection() *net.UDPConn

func UDPRx

func UDPRx(ctx context.Context, address *net.UDPAddr, messages chan RxMSG)

func UDPTx

func UDPTx(verb MessageVerb, payload Payload, resolvedAddress *net.UDPAddr)

Types

type BitEvent

type BitEvent uint8
const (
	BitOn     BitEvent = 0x01
	BitOff    BitEvent = 0x00
	LastEvent BitEvent = 0x80 // high bit set to indicate last one
)

type Callsign

type Callsign = [CallsignSize]byte

type CarrierBitEvent

type CarrierBitEvent struct {
	TimeOffset uint32
	BitEvent   BitEvent
}

Offset allows for about 4 seconds of offset

type CarrierEventPayload

type CarrierEventPayload struct {
	Channel        ChannelIdType
	CarrierKey     CarrierKeyType
	StartTimeStamp int64
	BitEvents      [MaxBitEvents]CarrierBitEvent
	SendTime       int64
}

type CarrierKeyType

type CarrierKeyType = uint16

type ChannelIdType

type ChannelIdType = uint16

type KeyValuePayload

type KeyValuePayload struct {
	Channel    ChannelIdType
	CarrierKey CarrierKeyType
	Key        [8]byte
	Value      [16]byte
}

type ListChannelsPayload

type ListChannelsPayload struct {
	Channels [MaxChannelsPerMessage]uint16
}

type ListenConfirmPayload

type ListenConfirmPayload struct {
	Channel    ChannelIdType
	CarrierKey CarrierKeyType
}

type ListenRequestPayload

type ListenRequestPayload struct {
	Channel  ChannelIdType
	Callsign [16]byte
}

type MessageVerb

type MessageVerb = byte
const (
	EnumerateChannels MessageVerb = 0x90
	ListChannels      MessageVerb = 0x91
	TimeSync          MessageVerb = 0x92
	TimeSyncResponse  MessageVerb = 0x93
	ListenRequest     MessageVerb = 0x94
	ListenConfirm     MessageVerb = 0x95
	Unlisten          MessageVerb = 0x96
	KeyValue          MessageVerb = 0x81
	CarrierEvent      MessageVerb = 0x82
	VersionInfo       MessageVerb = 0x97
)

func DecodePacket

func DecodePacket(lineBuffer []byte) (MessageVerb, interface{})

type Payload

type Payload = interface{}

type RelType

type RelType uint8
const Alpha RelType = RelType(1)
const Beta RelType = RelType(2)
const Final RelType = RelType(4)
const POC RelType = RelType(0)
const RC RelType = RelType(3)

type RxMSG

type RxMSG struct {
	Verb       MessageVerb
	Payload    Payload
	SrcAddress net.UDPAddr
	RxTime     int64
}

type TimeSyncPayload

type TimeSyncPayload struct {
	CurrentTime int64
}

TimeSync

type TimeSyncResponsePayload

type TimeSyncResponsePayload struct {
	GivenTime    int64
	ServerRxTime int64
	ServerTxTime int64
}

type UnlistenPayload

type UnlistenPayload struct {
	Channel    ChannelIdType
	CarrierKey CarrierKeyType
}

type Version

type Version struct {
	Major   uint8
	Minor   uint8
	Patch   uint8
	Release RelType
}

func (*Version) Bytes

func (v *Version) Bytes() []byte

func (*Version) String

func (v *Version) String() string

type VersionInfoPayload

type VersionInfoPayload struct {
	MyProtocolVersion   Version
	MyCodeVersion       Version
	LatestStableStation Version
}

Jump to

Keyboard shortcuts

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