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 ¶
Push sends an APDU the meter pushes (a data-notification) to a client SAP as uplinks.
func (*LoRaWAN) SetIIDs ¶
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.
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) Call ¶
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.
type Radio ¶
Radio is the device's LoRaWAN modem: it sends uplinks and delivers the downlinks received in the receive windows.
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.