network

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package network provides network streaming capabilities for NMEA sentences

Package network provides network streaming capabilities for NMEA sentences

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseServer

type BaseServer struct {
	Config Config
	Mu     sync.RWMutex
	Done   chan struct{}
}

BaseServer provides common functionality for TCP and WebSocket servers

func NewBaseServer

func NewBaseServer(cfg Config) *BaseServer

NewBaseServer creates a new base server with the given configuration

type Config

type Config struct {
	Host            string
	Port            int
	UpdateInterval  time.Duration
	Logger          zerolog.Logger
	SentenceOptions SentenceOptions
	BaudRate        int
	Protocol        string // "nmea0183" or "nmea2000"
}

Config holds server configuration

type NMEA2000Server added in v1.1.0

type NMEA2000Server interface {
	Server
	SendPGN(msg pgn.Message) error
}

NMEA2000Server represents a server that can stream NMEA 2000 messages

type SentenceOptions

type SentenceOptions struct {
	EnablePosition    bool // GGA, GLL
	EnableNavigation  bool // RMC, HDT, VTG, XTE
	EnableEnvironment bool // DBT, MTW, MWV, VHW, DPT
}

SentenceOptions configures which NMEA sentences to generate

type Server

type Server interface {
	Start(ctx context.Context) error
	Stop() error
}

Server represents a network server interface that can stream NMEA sentences

type TCP2000Server added in v1.1.0

type TCP2000Server struct {
	*BaseServer
	// contains filtered or unexported fields
}

TCP2000Server implements NMEA 2000 message streaming over TCP

func NewTCP2000Server added in v1.1.0

func NewTCP2000Server(cfg Config) *TCP2000Server

NewTCP2000Server creates a new TCP server instance for NMEA 2000

func (*TCP2000Server) SendPGN added in v1.1.0

func (s *TCP2000Server) SendPGN(msg pgn.Message) error

SendPGN sends a NMEA 2000 message to all connected clients

func (*TCP2000Server) Start added in v1.1.0

func (s *TCP2000Server) Start(ctx context.Context) error

Start begins the TCP server

func (*TCP2000Server) Stop added in v1.1.0

func (s *TCP2000Server) Stop() error

Stop terminates the TCP server

type TCPServer

type TCPServer struct {
	*BaseServer
	// contains filtered or unexported fields
}

TCPServer implements NMEA sentence streaming over TCP

func NewTCPServer

func NewTCPServer(cfg Config) *TCPServer

NewTCPServer creates a new TCP server instance

func (*TCPServer) Start

func (s *TCPServer) Start(ctx context.Context) error

Start begins the TCP server

func (*TCPServer) Stop

func (s *TCPServer) Stop() error

Stop closes all client connections and stops the server

type WebSocket2000Server added in v1.1.0

type WebSocket2000Server struct {
	*BaseServer
	// contains filtered or unexported fields
}

WebSocket2000Server implements NMEA 2000 message streaming over WebSocket

func NewWebSocket2000Server added in v1.1.0

func NewWebSocket2000Server(cfg Config) *WebSocket2000Server

NewWebSocket2000Server creates a new WebSocket server instance for NMEA 2000

func (*WebSocket2000Server) SendPGN added in v1.1.0

func (s *WebSocket2000Server) SendPGN(msg pgn.Message) error

SendPGN sends a NMEA 2000 message to all connected WebSocket clients

func (*WebSocket2000Server) Start added in v1.1.0

func (s *WebSocket2000Server) Start(ctx context.Context) error

Start begins the WebSocket server

func (*WebSocket2000Server) Stop added in v1.1.0

func (s *WebSocket2000Server) Stop() error

Stop terminates the WebSocket server

type WebSocketServer

type WebSocketServer struct {
	*BaseServer
	// contains filtered or unexported fields
}

WebSocketServer implements NMEA sentence streaming over WebSocket

func NewWebSocketServer

func NewWebSocketServer(cfg Config) *WebSocketServer

NewWebSocketServer creates a new WebSocket server instance

func (*WebSocketServer) Start

func (s *WebSocketServer) Start(ctx context.Context) error

Start begins the WebSocket server

func (*WebSocketServer) Stop

func (s *WebSocketServer) Stop() error

Stop closes all client connections and stops the server

Jump to

Keyboard shortcuts

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