Skip to content
Max Litruv Boonzaayer edited this page Feb 15, 2026 · 3 revisions

A comprehensive C# library for communicating with MeshCore companion radios via serial port.

Overview

MeshCS provides a high-level, async-friendly API for interacting with MeshCore LoRa mesh networking devices. It handles all the low-level details including COBS framing, packet building/parsing, and event dispatching.

Features

  • High-level async API - Simple MeshRadio class for most use cases
  • Event-driven messaging - Subscribe to events for incoming messages, adverts, and errors
  • Auto-discovery - Scan serial ports to find connected devices
  • Full protocol support - All MeshCore companion commands implemented
  • Low-level access - Direct packet building/parsing for advanced use

Quick Links

Requirements

  • .NET 8.0 or later
  • MeshCore companion radio (T-Beam, T-Echo, etc.)
  • Serial/USB connection to the device

Installation

dotnet add package MeshCS

Basic Usage

using MeshCS;

// Auto-discover and connect to the first available device
var radio = await MeshRadio.ConnectFirstAsync(verbose: true);
if (radio == null)
{
    Console.WriteLine("No MeshCore device found");
    return;
}

// Subscribe to incoming messages
radio.DirectMessageReceived += (msg) =>
{
    Console.WriteLine($"[{msg.SenderPrefixHex}]: {msg.Text}");
};

// Send a message
var contacts = await radio.GetContactsAsync();
if (contacts.Count > 0)
{
    await radio.SendMessageAsync(contacts[0].PublicKey[..6], "Hello!");
}

// Keep running to receive messages
await Task.Delay(Timeout.Infinite);

Architecture

┌─────────────────────────────────────────────────┐
│                  Your Application               │
├─────────────────────────────────────────────────┤
│                   MeshRadio                     │
│  (High-level async API, events, auto-discovery) │
├─────────────────────────────────────────────────┤
│     PacketBuilder          PacketParser         │
│  (Build command packets) (Parse responses)      │
├─────────────────────────────────────────────────┤
│              COBS Framing Layer                 │
├─────────────────────────────────────────────────┤
│              Serial Port (USB)                  │
├─────────────────────────────────────────────────┤
│           MeshCore Companion Radio              │
└─────────────────────────────────────────────────┘

License

MIT License - see LICENSE

Clone this wiki locally