enddevice

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package enddevice is the meter end of DLMS/COSEM over LoRaWAN and NB-IoT, the other side of package lpwan's head-end links.

LoRaWAN: the device end of SCHC (RFC 8724, RFC 9011) on a LoRaWAN radio. Uplinks are compressed with the head end's rules and fragmented with ACK-on-Error when they do not fit one frame; downlinks are reassembled (ACK-Always) and acknowledged; as a class A device the meter can only be reached in the receive window after one of its uplinks, so it sends an empty frame every Poll. Settings (FPorts, header, rules) must be the head end's: the DLMS UA LoRaWAN profile is not public, so its choices are settings here as in package lpwan.

NB-IoT: a meter behind carrier NAT that sleeps in power saving mode. It wakes, sends a push over UDP with the wrapper to the head end from a fresh source port, answers the head end's requests until it has been idle for ActiveTime (T3324), then sleeps and cannot be reached.

Both serve a Handler: a server of package server (ServerHandler), or any other meter model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dropper

type Dropper interface {
	Drop()
}

Dropper is a Handler told about requests dropped for their SAP.

type Handler

type Handler interface {
	// Serves reports whether the device answers a destination SAP (its
	// logical device, or the all-station address, which it never
	// answers).
	Serves(server uint16) bool
	// Handle answers one APDU from a client SAP (nil: nothing).
	Handle(client uint16, apdu []byte) []byte
}

Handler answers APDUs for the end device's logical device.

type LoRaWAN

type LoRaWAN struct {
	Handler Handler
	// ServerAddress is the logical device's SAP in the wrapper header of
	// uplinks (default 1).
	ServerAddress uint16
	DevEUI        string
	Radio         Radio
	Settings      lpwan.BridgeSettings // FPorts, header, rules: the head end's
	// UplinkPayload is the largest uplink FRMPayload in octets (default
	// 51, data rates 0 to 2 in IN865).
	UplinkPayload int
	// Poll is how often the meter sends an empty uplink to open a receive
	// window (default 200 ms).
	Poll time.Duration
	// NoneClient is the client SAP taken for requests when the header is
	// none (no wPorts on the air; default 48).
	NoneClient uint16
	// contains filtered or unexported fields
}

LoRaWAN is a meter behind a LoRaWAN radio.

func (*LoRaWAN) Push

func (d *LoRaWAN) Push(client uint16, apdu []byte) error

Push sends an APDU the meter pushes (a data-notification) to a client SAP as uplinks.

func (*LoRaWAN) Served

func (d *LoRaWAN) Served() int

Served is how many requests the meter answered.

func (*LoRaWAN) SetIIDs

func (d *LoRaWAN) SetIIDs(dev, app []byte)

SetIIDs sets the IPv6 interface identifiers the meter uses with header ipv6/udp/wrapper (the head end's defaults: EUI-64 based and ::1). Call it before Start.

func (*LoRaWAN) Start

func (d *LoRaWAN) Start() error

Start checks the settings and runs the meter until Stop.

func (*LoRaWAN) Stop

func (d *LoRaWAN) Stop()

Stop stops the meter.

func (d *LoRaWAN) Uplinks() int

Uplinks is how many SCHC messages the meter sent.

type NBIoT

type NBIoT struct {
	Handler Handler
	// ServerAddress is the logical device's SAP (default 1).
	ServerAddress uint16
	// Server is the head end's host:port.
	Server string
	// Local is the address the meter sends from (default "127.0.0.1:0" when
	// Server is on the loopback, else ":0"): a fresh port each wake, as a
	// NAT rebinding shows it.
	Local string
	// ActiveTime is how long it listens after its last datagram (T3324;
	// default 2 s).
	ActiveTime time.Duration
	// contains filtered or unexported fields
}

NBIoT is a meter on NB-IoT (or LTE-M) behind carrier NAT that sleeps in power saving mode.

func (*NBIoT) Awake

func (n *NBIoT) Awake() bool

Awake reports whether it is listening now.

func (*NBIoT) Call

func (n *NBIoT) Call(client uint16, push []byte) error

Call wakes the meter: it sends push (a data-notification APDU) to the client SAP, serves the head end until it has been idle for ActiveTime, and returns when the meter sleeps again.

func (*NBIoT) CallAsync

func (n *NBIoT) CallAsync(client uint16, push []byte) (<-chan struct{}, error)

CallAsync is Call returning at once; the channel closes when the meter sleeps.

func (*NBIoT) Calls

func (n *NBIoT) Calls() int

Calls is how many times the meter woke.

func (*NBIoT) Served

func (n *NBIoT) Served() int

Served is how many requests it answered.

type Radio

type Radio interface {
	Uplink(fport int, payload []byte) error
	Downlinks() <-chan lpwan.Downlink
}

Radio is the device's LoRaWAN modem: it sends uplinks and delivers the downlinks received in the receive windows.

func MemRadio

func MemRadio(ns *lpwan.MemNS, devEUI, class string) Radio

MemRadio is a radio on package lpwan's in-memory network server.

type SessionHandler

type SessionHandler struct {
	// contains filtered or unexported fields
}

SessionHandler is a Handler over a server of package server.

func ServerHandler

func ServerHandler(s *server.Server) *SessionHandler

ServerHandler serves a server of package server: a session per client SAP, kept until Reset.

func (*SessionHandler) Handle

func (h *SessionHandler) Handle(client uint16, apdu []byte) []byte

Handle answers one APDU in the client's session.

func (*SessionHandler) Reset

func (h *SessionHandler) Reset()

Reset forgets the sessions (a meter that rebooted).

func (*SessionHandler) Serves

func (h *SessionHandler) Serves(sap uint16) bool

Serves reports the server's own SAP (Address, default 1) and the all-station address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL