-
-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Max Litruv Boonzaayer edited this page Feb 15, 2026
·
3 revisions
This guide will help you get up and running with MeshCS in minutes.
Install MeshCS via NuGet:
dotnet add package MeshCSInstall-Package MeshCS<PackageReference Include="MeshCS" Version="1.0.0" />using MeshCS;
// Create a radio instance
var radio = new MeshRadio("COM3");
// Open the connection
await radio.OpenAsync();
// Your code here...
// Close when done
radio.Close();MeshCS uses the standard .NET event pattern:
radio.MessageReceived += (sender, msg) =>
{
Console.WriteLine($"From: {msg.PubKeyPrefix}");
Console.WriteLine($"Text: {msg.Text}");
};
radio.ContactUpdated += (sender, contact) =>
{
Console.WriteLine($"Contact: {contact.PublicName}");
};
radio.ErrorOccurred += (sender, error) =>
{
Console.WriteLine($"Error: {error.Message}");
};// Send to a specific contact by their public key prefix
await radio.SendTextMessageAsync(recipientId, "Hello!");
// Send with optional flags
await radio.SendTextMessageAsync(recipientId, "Important!",
PacketBuilder.PATH_TYPE_FLOOD);var contacts = await radio.GetContactsAsync();
foreach (var contact in contacts)
{
Console.WriteLine($"{contact.PublicName} - Last seen: {contact.LastSeen}");
}var info = await radio.GetSelfInfoAsync();
Console.WriteLine($"Name: {info.Name}");
Console.WriteLine($"Battery: {info.BatteryPercent}%");MeshCS has three abstraction levels:
| Class | Purpose |
|---|---|
MeshRadio |
High-level async API with events |
PacketBuilder |
Build binary command packets |
PacketParser |
Parse binary response packets |
CommandCodes |
Protocol constants |
Choose the level that fits your needs:
-
Most apps: Use
MeshRadiofor the simplest experience -
Custom protocols: Use
PacketBuilder/PacketParserdirectly -
Low-level access: Use
CommandCodesfor raw values
MeshCS © 2026 Litruv | MIT License
MeshCS Documentation
Classes
Models
Enums
Links