Table of Contents

Class GatewayNetwork

Namespace
Pamoja.Gateway
Assembly
Pamoja.Gateway.dll

The network side of one site: what a server does with what a gateway forwarded.

public sealed class GatewayNetwork : IDisposable
Inheritance
GatewayNetwork
Implements
Inherited Members

Remarks

A gateway forwards packets without reading them, because it holds no keys. This is the other half: it holds the devices it admits, the sessions it has granted and the counters it has seen, so a packet handed to it comes back as one of three things. A device joined and its accept is ready to transmit, a session frame arrived and was decrypted, or the frame belongs to a network this site never granted, which a gateway hears all the time and is not an error.

Constructors

GatewayNetwork(LoraChannelPlan, uint, GatewayNetworkWindows?, uint)

Opens the network side of a site on a channel plan.

public GatewayNetwork(LoraChannelPlan plan, uint netId, GatewayNetworkWindows? windows = null, uint firstDevAddr = 1)

Parameters

plan LoraChannelPlan

The band this site operates in, which is copied into the network.

netId uint

The network identifier granted addresses carry.

windows GatewayNetworkWindows

When and where to answer, or null for the recommended values.

firstDevAddr uint

The first address to grant.

Exceptions

PamojaException

The native core could not open a network.

Methods

Answer(uint, GatewaySlot, byte, ReadOnlySpan<byte>)

Builds a downlink for a device, encrypted with its session.

public GatewayTxpk Answer(uint devAddr, GatewaySlot slot, byte fport, ReadOnlySpan<byte> payload)

Parameters

devAddr uint

The device to answer.

slot GatewaySlot

Where and when to transmit, from the event that reported the uplink.

fport byte

The port to answer on.

payload ReadOnlySpan<byte>

What to send.

Returns

GatewayTxpk

The packet to put in a PULL_RESP.

Exceptions

PamojaException

No session is held for the address.

Dispose()

Releases the network.

public void Dispose()

Register(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Admits a device, so a join request signed with its key is accepted.

public void Register(ReadOnlySpan<byte> devEui, ReadOnlySpan<byte> appEui, ReadOnlySpan<byte> appKey)

Parameters

devEui ReadOnlySpan<byte>

The device identifier, eight bytes.

appEui ReadOnlySpan<byte>

The application identifier, eight bytes.

appKey ReadOnlySpan<byte>

The root key, sixteen bytes.

Exceptions

PamojaException

An identifier or the key is the wrong length.

Reads a packet the gateway forwarded.

public GatewayNetworkEvent Uplink(GatewayRxpk heard)

Parameters

heard GatewayRxpk

The packet as the gateway reported it.

Returns

GatewayNetworkEvent

What it turned out to be, and where its answer goes.

Exceptions

PamojaException

The frame was refused, with the reason.