TTNet.Data 6.1.0

Install-Package TTNet.Data -Version 6.1.0
dotnet add package TTNet.Data --version 6.1.0
<PackageReference Include="TTNet.Data" Version="6.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TTNet.Data --version 6.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TTNet.Data, 6.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TTNet.Data as a Cake Addin
#addin nuget:?package=TTNet.Data&version=6.1.0

// Install TTNet.Data as a Cake Tool
#tool nuget:?package=TTNet.Data&version=6.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TTNet.Data

A .NET library for The Things Network MQTT Data API

Install

Available at NuGet:

dotnet add package TTNet.Data

Usage

Create an instance:

var app = new App("Your app ID");

Listen to events:

app.Connected += (s, e) => Console.WriteLine("Connected");

app.Up += (s, e) =>
{
    Console.WriteLine(e.DeviceID);
    foreach (var f in e.Message.UplinkMessage.DecodedPayload.EnumerateObject())
        Console.WriteLine($"\t{f.Name}: {f.Value}");

    // Or you can convert it to your data type
    var myObject = e.Message.UplinkMessage.DecodedPayload.Deserialize<MyClass>();
};

Listen to specific devices:

app["deviceId"].Up += (s, e) =>
{
    foreach (var f in e.Message.UplinkMessage.DecodedPayload.EnumerateObject())
        Console.WriteLine($"\t{f.Name}: {f.Value}");
};

Connect:

var c = await app.ConnectAsync(cluster, port, withTls, username, apiKey);

See how to create an API key

Example:

var c = await app.ConnectAsync("eu1.cloud.thethings.network", 8883, true, "username@ttn", "XXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

You can add or remove events wether connected or disconnected.

Publish messages:

// Raw payload
await app[deviceID].PublishAsync(new Downlink {
    FPort = port,
    FrmPayload = new byte[] { 0x10, 0xF1 }
}, default(CancellationToken));
// JSON payload
await app[deviceID].PublishAsync(new Downlink {
    FPort = port,
    DecodedPayload = JsonSerializer.SerializeToElement(myObject)
}, default(CancellationToken));

Managed

Managed mode is also available. The client is started once and will mantain the connection automatically including reconnecting.

Create a managed instance:

var app = new ManagedApp("Your app ID");

Use StartAsync/StopAsync instead of ConnectAsync/DisconnectAsync:

await app.StartAsync(cluster, port, withTls, username, apiKey, autoReconnectDelay);

Publish messages:

// Raw payload
await app[deviceID].PublishAsync(new Downlink {
    FPort = port,
    FrmPayload = new byte[] { 0x10, 0xF1 }
});
// JSON payload
await app[deviceID].PublishAsync(new Downlink {
    FPort = port,
    DecodedPayload = JsonSerializer.SerializeToElement(myObject)
});
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.1.0 16 1/17/2022
6.1.0-beta.4 74 12/29/2021
6.1.0-beta.3 25 12/27/2021
6.1.0-beta.2 35 12/23/2021
6.1.0-beta.1 30 12/21/2021
6.0.0-rc.2 3,008 11/24/2021
6.0.0-rc.1 51 10/15/2021
5.0.1 588 12/15/2020
5.0.0 178 11/19/2020
3.3.0 200 10/1/2020
3.2.1 265 6/17/2020
3.2.1-rc.1 179 6/16/2020
3.2.0 235 5/19/2020
3.2.0-rc.2 151 5/18/2020
3.2.0-rc.1 211 5/17/2020
3.1.0 246 5/16/2020
3.1.0-rc.2 153 5/16/2020
3.1.0-rc.1 149 5/15/2020
3.0.0 314 1/3/2020