Class GatewayNetwork
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
planLoraChannelPlanThe band this site operates in, which is copied into the network.
netIduintThe network identifier granted addresses carry.
windowsGatewayNetworkWindowsWhen and where to answer, or null for the recommended values.
firstDevAddruintThe 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
devAddruintThe device to answer.
slotGatewaySlotWhere and when to transmit, from the event that reported the uplink.
fportbyteThe port to answer on.
payloadReadOnlySpan<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
devEuiReadOnlySpan<byte>The device identifier, eight bytes.
appEuiReadOnlySpan<byte>The application identifier, eight bytes.
appKeyReadOnlySpan<byte>The root key, sixteen bytes.
Exceptions
- PamojaException
An identifier or the key is the wrong length.
Uplink(GatewayRxpk)
Reads a packet the gateway forwarded.
public GatewayNetworkEvent Uplink(GatewayRxpk heard)
Parameters
heardGatewayRxpkThe 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.