Skip to content

Add TCP, UDP, and WebSocket output servers#42

Merged
xoolive merged 4 commits intoxoolive:masterfrom
junzis:feature/output-servers
Mar 31, 2026
Merged

Add TCP, UDP, and WebSocket output servers#42
xoolive merged 4 commits intoxoolive:masterfrom
junzis:feature/output-servers

Conversation

@junzis
Copy link
Copy Markdown
Contributor

@junzis junzis commented Mar 30, 2026

Summary

  • Add output servers to serve decoded AIS messages as timestamped NMEA (Norwegian coast guard IEC 61162-1 format) via TCP, UDP, and WebSocket
  • This allows ship162 to decode from SDR and re-broadcast to downstream consumers as if they were connecting to the Norwegian Coastal Administration feed
  • New config options: serve_tcp, serve_udp, serve_ws, udp_targets

Details

TCP server (outputs/tcp.rs): Clients connect and receive a continuous NMEA stream. Uses tokio::sync::broadcast for fan-out to multiple clients with automatic cleanup on disconnect.

UDP server (outputs/udp.rs): Supports both static targets (configured via udp_targets) and dynamic peer registration (clients send any datagram to register). Useful for pushing data to remote hosts.

WebSocket server (outputs/websocket.rs): Clients connect via ws:// and receive NMEA messages. Built on tokio-tungstenite.

NMEA encoding (outputs/mod.rs): Formats messages with Norwegian coast guard timestamp tag blocks: \s:SERIAL,c:TIMESTAMP*CHECKSUM\!AIVDM,...

SDR-decoded messages now call encode_nmea() to generate NMEA sentences before sending through the pipeline.

Configuration example

serve_tcp = "0.0.0.0:5631"
serve_ws = "0.0.0.0:8080"
udp_targets = ["x.x.x.x:88888"]

[[sources]]
soapy.args="driver=sdrplay"
soapy.sample_rate=1000000
gain=50

New dependencies

  • tokio-tungstenite (WebSocket protocol)

Test plan

  • TCP output: verified with nc localhost 5631 — receives live NMEA stream from SDRplay RSPdxR2
  • UDP output: verified with Python UDP listener — receives NMEA datagrams
  • WebSocket: verified handshake with curl
  • cargo fmt — clean
  • cargo clippy — zero warnings
  • Release build with --features soapy — passes
  • Tested live on sil server with SDRplay RSPdxR2 antenna

junzis added 3 commits March 30, 2026 23:20
Serve decoded AIS messages as timestamped NMEA (Norwegian coast guard
format) to connected clients, allowing ship162 to act as a local AIS
data source when decoding from SDR.

- TCP server: clients connect and receive continuous NMEA stream
- UDP server: sends to configured static targets + dynamic registration
- WebSocket server: clients connect via ws:// for NMEA stream
- New config options: serve_tcp, serve_udp, serve_ws, udp_targets
- SDR-decoded messages now carry NMEA sentences via encode_nmea()
Support ws:// and wss:// URLs as data sources, allowing ship162 to
receive AIS NMEA data from WebSocket servers. Handles both timestamped
(Norwegian coast guard format) and plain NMEA messages.

Usage: ship162 ws://host:port/path
Config: ws = "ws://host:port/path"
Handle both text and binary WebSocket frames (UTF-8 encoded), support
bare NMEA without ! prefix (AIVDM/BSVDM), and add debug tracing for
received messages to aid troubleshooting.
@xoolive xoolive merged commit 47883d5 into xoolive:master Mar 31, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants