Documentation ¶
Index ¶
- type Device
- type DeviceOption
- func WithAppKey(appKey lorawan.AES128Key) DeviceOption
- func WithDevEUI(devEUI lorawan.EUI64) DeviceOption
- func WithDevName(Name string) DeviceOption
- func WithDownlinkHandlerFunc(f func(confirmed, ack bool, fCntDown uint32, fPort uint8, data []byte) error) DeviceOption
- func WithGateways(gws []*Gateway) DeviceOption
- func WithJoinEUI(joinEUI lorawan.EUI64) DeviceOption
- func WithOTAADelay(delay time.Duration) DeviceOption
- func WithRandomDevNonce() DeviceOption
- func WithUplinkCount(count uint32) DeviceOption
- func WithUplinkInterval(interval time.Duration) DeviceOption
- func WithUplinkPayload(confirmed bool, fPort uint8, pl []byte) DeviceOption
- func WithUplinkTXInfo(txInfo gw.UplinkTXInfo) DeviceOption
- type Gateway
- type GatewayOption
- func WithCommandTopicTemplate(ct string) GatewayOption
- func WithDownlinkTxAckDelay(d time.Duration) GatewayOption
- func WithDownlinkTxNackRate(rate int) GatewayOption
- func WithEventTopicTemplate(tt string) GatewayOption
- func WithGatewayID(gatewayID lorawan.EUI64) GatewayOption
- func WithGatewayName(gatewayName string) GatewayOption
- func WithMQTTCertificates(server, caCert, tlsCert, tlsKey string) GatewayOption
- func WithMQTTClient(client mqtt.Client) GatewayOption
- func WithMQTTCredentials(server, username, password string) GatewayOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeviceOption ¶
DeviceOption is the interface for a device option.
func WithAppKey ¶
func WithAppKey(appKey lorawan.AES128Key) DeviceOption
WithAppKey sets the AppKey.
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 ¶
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.