simulator

package
v0.0.0-...-c4ba475 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	sync.RWMutex

	//Name
	Name string
	// contains filtered or unexported fields
}

Device contains the state of a simulated LoRaWAN OTAA device (1.0.x).

func NewDevice

func NewDevice(ctx context.Context, wg *sync.WaitGroup, opts ...DeviceOption) (*Device, error)

NewDevice creates a new device simulation.

type DeviceOption

type DeviceOption func(*Device) error

DeviceOption is the interface for a device option.

func WithAppKey

func WithAppKey(appKey lorawan.AES128Key) DeviceOption

WithAppKey sets the AppKey.

func WithDevEUI

func WithDevEUI(devEUI lorawan.EUI64) DeviceOption

WithDevEUI sets the DevEUI.

func WithDevName

func WithDevName(Name string) DeviceOption

WithDevName sets the Name.

func WithDownlinkHandlerFunc

func WithDownlinkHandlerFunc(f func(confirmed, ack bool, fCntDown uint32, fPort uint8, data []byte) error) DeviceOption

WithDownlinkHandlerFunc sets the downlink handler func.

func WithGateways

func WithGateways(gws []*Gateway) DeviceOption

WithGateways adds the device to the given gateways. Use this function after WithDevEUI!

func WithJoinEUI

func WithJoinEUI(joinEUI lorawan.EUI64) DeviceOption

WithJoinEUI sets the JoinEUI.

func WithOTAADelay

func WithOTAADelay(delay time.Duration) DeviceOption

WithOTAADelay sets the OTAA delay.

func WithRandomDevNonce

func WithRandomDevNonce() DeviceOption

WithRandomDevNonce randomizes the OTAA DevNonce instead of using a counter value.

func WithUplinkCount

func WithUplinkCount(count uint32) DeviceOption

WithUplinkCount sets the uplink count, after which the device simulation ends.

func WithUplinkInterval

func WithUplinkInterval(interval time.Duration) DeviceOption

WithUplinkInterval sets the uplink interval.

func WithUplinkPayload

func WithUplinkPayload(confirmed bool, fPort uint8, pl []byte) DeviceOption

WithUplinkPayload sets the uplink payload.

func WithUplinkTXInfo

func WithUplinkTXInfo(txInfo gw.UplinkTXInfo) DeviceOption

WithUplinkTXInfo sets the TXInfo used for simulating the uplinks.

type Gateway

type Gateway struct {
	Name string
	// contains filtered or unexported fields
}

Gateway defines a simulated LoRa gateway.

func NewGateway

func NewGateway(opts ...GatewayOption) (*Gateway, error)

NewGateway creates a new gateway, using the given MQTT client for sending and receiving.

func (*Gateway) SendUplinkFrame

func (g *Gateway) SendUplinkFrame(pl gw.UplinkFrame) error

SendUplinkFrame sends the given uplink frame.

type GatewayOption

type GatewayOption func(*Gateway) error

GatewayOption is the interface for a gateway option.

func WithCommandTopicTemplate

func WithCommandTopicTemplate(ct string) GatewayOption

WithCommandTopicTemplate sets the command (ns > gw) topic template. Example: 'gateway/{{ .GatewayID }}/command/{{ .Command }}'

func WithDownlinkTxAckDelay

func WithDownlinkTxAckDelay(d time.Duration) GatewayOption

WithDownlinkTxAckDelay sets the delay in which the Tx Ack is returned.

func WithDownlinkTxNackRate

func WithDownlinkTxNackRate(rate int) GatewayOption

WithDownlinkTxNackRate sets the rate in which Tx NAck messages are sent. Setting this to:

0: always ACK
1: NAck every message
2: NAck every other message
3: NAck every third message
...

func WithEventTopicTemplate

func WithEventTopicTemplate(tt string) GatewayOption

WithEventTopicTemplate sets the event (gw > ns) topic template. Example: 'gateway/{{ .GatewayID }}/event/{{ .Event }}'

func WithGatewayID

func WithGatewayID(gatewayID lorawan.EUI64) GatewayOption

WithGatewayID sets the gateway ID.

func WithGatewayName

func WithGatewayName(gatewayName string) GatewayOption

WithGatewayName sets the gateway name.

func WithMQTTCertificates

func WithMQTTCertificates(server, caCert, tlsCert, tlsKey string) GatewayOption

WithMQTTCertificates initializes a new MQTT client with the given CA and client-certificate files.

func WithMQTTClient

func WithMQTTClient(client mqtt.Client) GatewayOption

WithMQTTClient sets the MQTT client for the gateway.

func WithMQTTCredentials

func WithMQTTCredentials(server, username, password string) GatewayOption

WithMQTTCredentials initializes a new MQTT client with the given credentials.

Jump to

Keyboard shortcuts

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