cot

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalFrom      = "local"
	LocalScope     = "local"
	BroadcastScope = "broadcast"
)
View Source
const NotNum = 999999

Variables

View Source
var (
	Root = new(CotType)
)

Functions

func BasicMsg

func BasicMsg(typ string, uid string, stale time.Duration) *cotproto.TakMessage

func CloneMessageNoCoords added in v0.14.0

func CloneMessageNoCoords(msg *cotproto.TakMessage) *cotproto.TakMessage

func GetMsgType added in v0.12.5

func GetMsgType(t string) string

func MakeDpMsg

func MakeDpMsg(uid string, typ string, name string, lat float64, lon float64) *cotproto.TakMessage

func MakeOfflineMsg

func MakeOfflineMsg(uid string, typ string) *cotproto.TakMessage

func MakePing

func MakePing(uid string) *cotproto.TakMessage

func MakePong

func MakePong() *cotproto.TakMessage

func MakeProtoPacket

func MakeProtoPacket(msg *cotproto.TakMessage) ([]byte, error)

func MatchAnyPattern added in v0.13.0

func MatchAnyPattern(a string, patterns ...string) bool

func MatchPattern added in v0.12.4

func MatchPattern(a, pattern string) bool

func ReadProto

func ReadProto(r *bufio.Reader) (*cotproto.TakMessage, error)

func TimeFromMillis

func TimeFromMillis(ms uint64) time.Time

func TimeToMillis

func TimeToMillis(t time.Time) uint64

Types

type CotMessage

type CotMessage struct {
	From       string               `json:"from,omitempty"`
	Scope      string               `json:"scope"`
	TakMessage *cotproto.TakMessage `json:"tak_message"`
	Detail     *Node                `json:"-"`
}

func CotFromProto added in v0.14.4

func CotFromProto(msg *cotproto.TakMessage, from, scope string) (*CotMessage, error)

func EventToProto

func EventToProto(ev *Event) (*CotMessage, error)

func EventToProtoExt added in v0.14.6

func EventToProtoExt(ev *Event, from, scope string) (*CotMessage, error)

func LocalCotMessage added in v0.16.4

func LocalCotMessage(msg *cotproto.TakMessage) *CotMessage

func (*CotMessage) GetCallsign

func (m *CotMessage) GetCallsign() string

func (*CotMessage) GetColor added in v0.14.7

func (m *CotMessage) GetColor() string

func (*CotMessage) GetDetail added in v0.15.0

func (m *CotMessage) GetDetail() *Node

func (*CotMessage) GetEndpoint

func (m *CotMessage) GetEndpoint() string
func (m *CotMessage) GetFirstLink(relation string) *Node

func (*CotMessage) GetIconsetPath added in v0.15.0

func (m *CotMessage) GetIconsetPath() string

func (*CotMessage) GetLat

func (m *CotMessage) GetLat() float64

func (*CotMessage) GetLatLon

func (m *CotMessage) GetLatLon() (float64, float64)

func (*CotMessage) GetLon

func (m *CotMessage) GetLon() float64

func (*CotMessage) GetParent

func (m *CotMessage) GetParent() (string, string)

func (*CotMessage) GetRole

func (m *CotMessage) GetRole() string

func (*CotMessage) GetSendTime added in v0.13.0

func (m *CotMessage) GetSendTime() time.Time

func (*CotMessage) GetStale

func (m *CotMessage) GetStale() time.Time

func (*CotMessage) GetStaleTime added in v0.13.0

func (m *CotMessage) GetStaleTime() time.Time

func (*CotMessage) GetStartTime added in v0.13.0

func (m *CotMessage) GetStartTime() time.Time

func (*CotMessage) GetTakMessage added in v0.15.0

func (m *CotMessage) GetTakMessage() *cotproto.TakMessage

func (*CotMessage) GetTeam

func (m *CotMessage) GetTeam() string

func (*CotMessage) GetType

func (m *CotMessage) GetType() string

func (*CotMessage) GetUID added in v0.14.7

func (m *CotMessage) GetUID() string

func (*CotMessage) GetUpdatedTakMessage added in v0.15.1

func (m *CotMessage) GetUpdatedTakMessage() *cotproto.TakMessage

func (*CotMessage) IsChat

func (m *CotMessage) IsChat() bool

func (*CotMessage) IsChatReceipt

func (m *CotMessage) IsChatReceipt() bool

func (*CotMessage) IsContact

func (m *CotMessage) IsContact() bool

func (*CotMessage) IsControl added in v0.16.4

func (m *CotMessage) IsControl() bool

func (*CotMessage) IsLocal added in v0.16.4

func (m *CotMessage) IsLocal() bool

func (*CotMessage) IsMapItem added in v0.16.1

func (m *CotMessage) IsMapItem() bool

func (*CotMessage) IsPing added in v0.16.1

func (m *CotMessage) IsPing() bool

type CotType

type CotType struct {
	Code string     `json:"code"`
	Name string     `json:"name"`
	Next []*CotType `json:"next"`
}

func GetNext

func GetNext(s string) []*CotType

func (*CotType) Level

func (t *CotType) Level() int

type Event

type Event struct {
	XMLName xml.Name  `xml:"event"`
	Version string    `xml:"version,attr"`
	Type    string    `xml:"type,attr"`
	Access  string    `xml:"access,attr,omitempty"`
	Qos     string    `xml:"qos,attr,omitempty"`
	Opex    string    `xml:"opex,attr,omitempty"`
	UID     string    `xml:"uid,attr"`
	Time    time.Time `xml:"time,attr"`
	Start   time.Time `xml:"start,attr"`
	Stale   time.Time `xml:"stale,attr"`
	How     string    `xml:"how,attr"`
	Detail  *Node     `xml:"detail"`
	Point   Point     `xml:"point"`
}

func CotToEvent added in v0.15.0

func CotToEvent(c *cotproto.CotEvent) *Event

func ProtoChangeOkMsg

func ProtoChangeOkMsg() *Event

func ProtoToEvent

func ProtoToEvent(msg *cotproto.TakMessage) *Event

func VersionReqMsg

func VersionReqMsg(ver int8) *Event

func VersionSupportMsg

func VersionSupportMsg(ver int8) *Event

func XMLBasicMsg added in v0.14.7

func XMLBasicMsg(typ string, uid string, stale time.Duration) *Event

func (*Event) AddCallsign

func (e *Event) AddCallsign(callsign, endpoint string, addDroid bool)

func (*Event) AddDetail

func (e *Event) AddDetail() *Node

func (*Event) AddGroup

func (e *Event) AddGroup(group, role string)

func (*Event) AddTrack

func (e *Event) AddTrack(speed, course string)

func (*Event) AddVersion

func (e *Event) AddVersion(device, platform, os, version string)

func (*Event) String

func (e *Event) String() string

type Node

type Node struct {
	XMLName xml.Name
	Attrs   []xml.Attr `xml:",any,attr"`
	Content string     `xml:",chardata"`
	Nodes   []*Node    `xml:",any"`
}

func DetailsFromString

func DetailsFromString(s string) (*Node, error)

func GetXMLDetails added in v0.14.7

func GetXMLDetails(d *Node, withContacts bool) (*Node, error)

func NewNode

func NewNode(name string, attrs map[string]string) *Node

func NewXMLDetails added in v0.14.7

func NewXMLDetails() *Node

func (*Node) AddChild

func (n *Node) AddChild(name string, params map[string]string, text string) *Node

func (*Node) AddOrChangeChild added in v0.14.6

func (n *Node) AddOrChangeChild(name string, params map[string]string) *Node
func (n *Node) AddPpLink(uid, typ, callsign string)

func (*Node) AsXMLString

func (n *Node) AsXMLString() string

func (*Node) GetAll

func (n *Node) GetAll(name string) []*Node

func (*Node) GetAttr

func (n *Node) GetAttr(name string) string

func (*Node) GetAttrs added in v0.14.7

func (n *Node) GetAttrs() map[string]string

func (*Node) GetDestCallsign added in v0.14.7

func (n *Node) GetDestCallsign() []string

func (*Node) GetDestMission added in v0.14.7

func (n *Node) GetDestMission() []string

func (*Node) GetFirst

func (n *Node) GetFirst(name string) *Node

func (*Node) GetText

func (n *Node) GetText() string

func (*Node) Has

func (n *Node) Has(name string) bool

func (*Node) RemoveTags

func (n *Node) RemoveTags(tags ...string)

func (*Node) String

func (n *Node) String() string

type Point

type Point struct {
	XMLName xml.Name `xml:"point"`
	Lat     float64  `xml:"lat,attr"`
	Lon     float64  `xml:"lon,attr"`
	Hae     float64  `xml:"hae,attr"`
	Ce      float64  `xml:"ce,attr"`
	Le      float64  `xml:"le,attr"`
}

type ProtoReader

type ProtoReader struct {
	// contains filtered or unexported fields
}

func NewProtoReader

func NewProtoReader(r io.Reader) *ProtoReader

func (*ProtoReader) ReadProtoBuf

func (er *ProtoReader) ReadProtoBuf() (*cotproto.TakMessage, error)

type TagReader

type TagReader struct {
	// contains filtered or unexported fields
}

func NewTagReader

func NewTagReader(r io.Reader) *TagReader

func (*TagReader) ReadTag

func (er *TagReader) ReadTag() (string, []byte, error)

Jump to

Keyboard shortcuts

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