sapient

package
v0.0.0-...-19ce36a Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package sapient implements the SAPIENT protocol (BSI Flex 335 v2.0).

It provides a TCP transport layer with the length-prefixed framing specified in AEDP-4869 §6.3, and typed client connections for the Child (edge node/GCS), Peer (fusion node/C2), and Parent (higher echelon) roles.

Index

Constants

View Source
const ICDVersion = "BSI Flex 335 v2.0"

Variables

This section is empty.

Functions

func Ack

func Ack(conn *Conn, middlewareID, destinationID string, accept bool, reasons ...string) error

Ack sends a RegistrationAck to a node that just registered.

func AckV1

func AckV1(conn *Conn, middlewareID, destinationID string, accept bool, reason string) error

AckV1 sends a v1-compatible RegistrationAck.

func ContentType

func ContentType(msg *pb.SapientMessage) string

ContentType returns the name of the content oneof field set on a message, or "none" if no content is set.

func IsConnectionClosed

func IsConnectionClosed(err error) bool

IsConnectionClosed returns true if the error indicates a closed connection.

func IsV1

func IsV1(icdVersion string) bool

IsV1 returns true if the registration's icd_version indicates v1 or v7.

func Msg

func Msg(nodeID string) *pb.SapientMessage

Msg creates a new SapientMessage with timestamp and node_id pre-filled.

func NewAlert

func NewAlert(alertType pb.Alert_AlertType, status pb.Alert_AlertStatus, priority pb.Alert_DiscretePriority, description string) *pb.Alert

NewAlert creates an Alert with a generated alert_id.

func NewAlertAck

func NewAlertAck(alertID string, status pb.AlertAck_AlertAckStatus, reasons ...string) *pb.AlertAck

NewAlertAck creates an AlertAck for the given alert_id.

func NewTaskAck

func NewTaskAck(taskID string, status pb.TaskAck_TaskStatus, reasons ...string) *pb.TaskAck

NewTaskAck creates a TaskAck for the given task_id.

func NewULID

func NewULID() string

NewULID generates a new ULID string.

func NewUUID

func NewUUID() string

NewUUID generates a new random UUID v4 string.

func Now

func Now() *timestamppb.Timestamp

Now returns the current time as a protobuf Timestamp.

func Register

func Register(conn *Conn, reg *pb.Registration) (nodeID string, err error)

Register sends a Registration on conn and waits for a RegistrationAck. Returns the assigned node_id on success.

Types

type Conn

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

Conn wraps a TCP connection with SAPIENT length-prefixed framing. Messages are serialized as: [4-byte little-endian length][protobuf bytes].

func Dial

func Dial(addr string) (*Conn, error)

Dial connects to a SAPIENT node at addr (host:port) and returns a Conn.

func NewConn

func NewConn(conn net.Conn) *Conn

NewConn wraps an existing net.Conn for SAPIENT message exchange.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the underlying TCP connection.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local address of the connection.

func (*Conn) Recv

func (c *Conn) Recv() (*pb.SapientMessage, error)

Recv reads and deserializes the next message as a v2 SapientMessage.

func (*Conn) RecvRaw

func (c *Conn) RecvRaw() ([]byte, error)

RecvRaw reads the next framed message and returns the raw protobuf bytes.

func (*Conn) RecvV1

func (c *Conn) RecvV1() (*v1.SapientMessage, error)

RecvV1 reads a message as v1. Only needed if you specifically need v1 struct access. Recv() works for both versions in most cases.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote address of the connection.

func (*Conn) Send

func (c *Conn) Send(msg *pb.SapientMessage) error

Send serializes and sends a v2 SapientMessage.

func (*Conn) SendAlert

func (c *Conn) SendAlert(nodeID string, a *pb.Alert) error

SendAlert sends an Alert from nodeID.

func (*Conn) SendAlertAck

func (c *Conn) SendAlertAck(nodeID, destinationID string, aa *pb.AlertAck) error

SendAlertAck sends an AlertAck from nodeID to destinationID.

func (*Conn) SendAlertAckV1

func (c *Conn) SendAlertAckV1(nodeID, destinationID string, alertID string, status v1.AlertAck_AlertStatus, reason string) error

SendAlertAckV1 sends a v1-compatible AlertAck.

func (*Conn) SendDetection

func (c *Conn) SendDetection(nodeID string, dr *pb.DetectionReport) error

SendDetection sends a DetectionReport from nodeID.

func (*Conn) SendRaw

func (c *Conn) SendRaw(data []byte) error

SendRaw sends pre-serialized protobuf bytes with the length-prefix header.

func (*Conn) SendStatus

func (c *Conn) SendStatus(nodeID string, sr *pb.StatusReport) error

SendStatus sends a StatusReport from nodeID.

func (*Conn) SendTask

func (c *Conn) SendTask(nodeID, destinationID string, t *pb.Task) error

SendTask sends a Task from nodeID to destinationID.

func (*Conn) SendTaskAck

func (c *Conn) SendTaskAck(nodeID string, ta *pb.TaskAck) error

SendTaskAck sends a TaskAck from nodeID.

func (*Conn) SendTaskAckV1

func (c *Conn) SendTaskAckV1(nodeID string, taskID string, status v1.TaskAck_TaskStatus, reason string) error

SendTaskAckV1 sends a v1-compatible TaskAck.

func (*Conn) SendV1

func (c *Conn) SendV1(msg *v1.SapientMessage) error

SendV1 sends an arbitrary v1 SapientMessage.

type DetectionBuilder

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

DetectionBuilder helps construct DetectionReport messages.

func NewDetection

func NewDetection(objectID string) *DetectionBuilder

NewDetection starts building a DetectionReport. objectID should be consistent for the same tracked object across updates.

func (*DetectionBuilder) Behaviour

func (b *DetectionBuilder) Behaviour(typ string, confidence float32) *DetectionBuilder

func (*DetectionBuilder) Build

func (b *DetectionBuilder) Build() *pb.DetectionReport

func (*DetectionBuilder) Classification

func (b *DetectionBuilder) Classification(typ string, confidence float32) *DetectionBuilder

func (*DetectionBuilder) Confidence

func (b *DetectionBuilder) Confidence(c float32) *DetectionBuilder

func (*DetectionBuilder) Location

func (b *DetectionBuilder) Location(lat, lng, alt float64) *DetectionBuilder

func (*DetectionBuilder) ObjectInfo

func (b *DetectionBuilder) ObjectInfo(typ, value string) *DetectionBuilder

func (*DetectionBuilder) RangeBearing

func (b *DetectionBuilder) RangeBearing(az, el, rng float64) *DetectionBuilder

func (*DetectionBuilder) Signal

func (b *DetectionBuilder) Signal(amplitude, centreFreq float32) *DetectionBuilder

func (*DetectionBuilder) SubClassification

func (b *DetectionBuilder) SubClassification(typ string, confidence float32, subType string, subConf float32, level int32) *DetectionBuilder

func (*DetectionBuilder) TaskID

func (b *DetectionBuilder) TaskID(taskID string) *DetectionBuilder

func (*DetectionBuilder) TrackInfo

func (b *DetectionBuilder) TrackInfo(typ, value string) *DetectionBuilder

func (*DetectionBuilder) Velocity

func (b *DetectionBuilder) Velocity(east, north, up float64) *DetectionBuilder

type Listener

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

Listener accepts incoming SAPIENT TCP connections.

func Listen

func Listen(addr string) (*Listener, error)

Listen starts a SAPIENT TCP listener on addr (e.g. ":5020").

func (*Listener) Accept

func (l *Listener) Accept() (*Conn, error)

Accept waits for and returns the next SAPIENT connection.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address (useful when using ":0" for a random port).

func (*Listener) Close

func (l *Listener) Close() error

Close stops the listener.

type StatusReportBuilder

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

StatusReportBuilder helps construct StatusReport messages.

func NewStatusReport

func NewStatusReport(system pb.StatusReport_System, info pb.StatusReport_Info, mode string) *StatusReportBuilder

NewStatusReport starts building a StatusReport with required fields.

func (*StatusReportBuilder) ActiveTask

func (b *StatusReportBuilder) ActiveTask(taskID string) *StatusReportBuilder

func (*StatusReportBuilder) Build

func (b *StatusReportBuilder) Build() *pb.StatusReport

func (*StatusReportBuilder) FieldOfView

func (b *StatusReportBuilder) FieldOfView(az, el, hExtent, vExtent float64) *StatusReportBuilder

func (*StatusReportBuilder) Location

func (b *StatusReportBuilder) Location(lat, lng, alt float64) *StatusReportBuilder

func (*StatusReportBuilder) Power

func (*StatusReportBuilder) Status

type TaskBuilder

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

TaskBuilder helps construct Task messages.

func NewTask

func NewTask(control pb.Task_Control) *TaskBuilder

NewTask starts building a Task with a generated task_id.

func (*TaskBuilder) Build

func (b *TaskBuilder) Build() *pb.Task

func (*TaskBuilder) Follow

func (b *TaskBuilder) Follow(objectID string) *TaskBuilder

func (*TaskBuilder) LookAt

func (b *TaskBuilder) LookAt(lat, lng, alt float64) *TaskBuilder

func (*TaskBuilder) ModeChange

func (b *TaskBuilder) ModeChange(mode string) *TaskBuilder

func (*TaskBuilder) Name

func (b *TaskBuilder) Name(name string) *TaskBuilder

func (*TaskBuilder) Region

func (b *TaskBuilder) Region(name string, typ pb.Task_RegionType, lat, lng, alt float64) *TaskBuilder

func (*TaskBuilder) Request

func (b *TaskBuilder) Request(req string) *TaskBuilder

func (*TaskBuilder) TimeRange

func (b *TaskBuilder) TimeRange(start, end *timestamppb.Timestamp) *TaskBuilder

Jump to

Keyboard shortcuts

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