NmeaTransport 0.5.0
dotnet add package NmeaTransport --version 0.5.0
NuGet\Install-Package NmeaTransport -Version 0.5.0
<PackageReference Include="NmeaTransport" Version="0.5.0" />
<PackageVersion Include="NmeaTransport" Version="0.5.0" />
<PackageReference Include="NmeaTransport" />
paket add NmeaTransport --version 0.5.0
#r "nuget: NmeaTransport, 0.5.0"
#:package NmeaTransport@0.5.0
#addin nuget:?package=NmeaTransport&version=0.5.0
#tool nuget:?package=NmeaTransport&version=0.5.0
NmeaTransport
NmeaTransport is a small .NET library for exchanging NMEA sentences over TCP and UDP.
It currently provides:
- a reusable TCP client with automatic reconnection
- a reusable UDP client for local listening plus unicast and broadcast sending
- structured message sending via
NmeaMessage - header-based message handlers for incoming sentences
- a lightweight TCP server that validates and broadcasts NMEA sentences
Target framework
The package targets netstandard2.1.
Installation
dotnet add package NmeaTransport
Client usage
The client connects to a remote TCP endpoint, keeps a background lifecycle running, routes incoming messages by header, and can queue outgoing messages while disconnected.
using NmeaTransport.Clients;
var options = new NmeaTcpClientOptions
{
EnableLogging = true,
ValidateChecksum = true,
ReconnectDelay = TimeSpan.FromSeconds(2),
ConnectTimeout = TimeSpan.FromSeconds(1),
WriteTimeout = TimeSpan.FromSeconds(1)
};
await using var client = new NmeaTcpClient("127.0.0.1", 10110, options);
using var registration = client.RegisterHandler("GPGLL", async (message, cancellationToken) =>
{
Console.WriteLine($"Received {message.Header}: {string.Join(", ", message.PayloadParts)}");
await Task.CompletedTask;
});
await client.ConnectAsync();
await client.SendAsync(new NmeaMessage(
"GPGLL",
["4916.45", "N", "12311.12", "W", "225444", "A", ""]));
await client.DisconnectAsync();
Client behavior
ConnectAsync()starts the client lifecycle and waits for the first successful connection.DisconnectAsync()stops the lifecycle and prevents further reconnect attempts.SendAsync()serializes the message as a NMEA sentence with checksum.RegisterHandler()routes incoming messages by header and returns anIDisposableto unregister.EnableLoggingcontrols whether the client writes lifecycle, RX, and error messages to the terminal.EnableLoggingdefaults tofalse;nullalso keeps terminal logging disabled.- When disconnected unexpectedly, the client keeps retrying based on
ReconnectDelay. - Outgoing messages remain queued and are flushed after reconnection.
Server usage
The server listens for TCP clients, accepts valid NMEA sentences, and broadcasts them to connected peers.
using NmeaTransport.Server;
var options = new NmeaTcpServerOptions
{
EnableLogging = true
};
await using var server = new NmeaTcpServer(10110, options);
using var cts = new CancellationTokenSource();
var runTask = server.StartAsync(cts.Token);
Console.WriteLine("Server is running. Press enter to stop.");
Console.ReadLine();
await server.StopAsync();
await runTask;
Server behavior
- ignores invalid or malformed input
- validates checksum when the incoming sentence includes one
- broadcasts valid sentences to all connected clients
EnableLoggingcontrols whether the server writes lifecycle, RX, and error messages to the terminalEnableLoggingdefaults tofalse;nullalso keeps terminal logging disabled
Core types
NmeaTcpClient: main client implementationINmeaTcpClient: public client contractNmeaTcpClientOptions: logging, checksum, reconnect, connect timeout, and write timeout settingsNmeaUdpClient: UDP client implementation for local listening and datagram sendingINmeaUdpClient: public UDP client contractNmeaUdpClientOptions: logging, checksum, receive timeout, write timeout, and endpoint settingsNmeaMessage: structured header + payload representationNmeaTcpServer: lightweight TCP relay for valid NMEA sentences
Development
Build and test locally with:
dotnet restore NmeaTransport.sln
dotnet build NmeaTransport.sln --no-restore --configuration Release
dotnet test NmeaTransport.sln --no-build --configuration Release
dotnet format NmeaTransport.sln --verify-no-changes
Branching
The repository adopts Gitflow-style working branches for implementation work.
feature/<short-name>for new featuresfix/<short-name>for bug fixes that do not require emergency release handlinghotfix/<short-name>for urgent production fixes when applicablerelease/<short-name>for release-oriented branches when the workflow requires it
Prefer opening pull requests to main from one of these branch types. For new development tasks in this repository, default to feature/... unless the nature of the change clearly fits another type.
CI and merge protection
Pull requests targeting main run a single required GitHub Actions workflow (for example, Build and test) that contains a job named ci. That job restores, builds, tests, and validates formatting with dotnet format --verify-no-changes.
To block merges when CI fails, configure the repository rules for main in GitHub:
- Open
Settings→Branchesor the repository rulesets page. - Edit the protection rule or ruleset for
main. - Mark the status check
Build and test / ci(workflow name / job id, as shown in the GitHub UI) as required. - Optionally require branches to be up to date before merging if you want fresh validation against the current
main.
Notes
- The package metadata is defined in NmeaTransport.csproj.
- Release automation uses GitHub Actions plus
release-please, with versioning persisted in the.csproj.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Threading.Channels (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.