models

package
v0.0.0-...-2ac35d6 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package models contains all the exported lorawan models.

Index

Constants

View Source
const (
	RX1 = iota
	RX2
)

Available RX window options.

View Source
const UsedDevNonceCount = 10

UsedDevNonceCount is the number of used dev-nonces to track.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACKNotification

type ACKNotification struct {
	Reference string        `json:"reference"` // refers to the given reference by the application
	DevEUI    lorawan.EUI64 `json:"devEUI"`
}

ACKNotification defines the payload sent to the application on an ACK event.

type Application

type Application struct {
	AppEUI lorawan.EUI64 `db:"app_eui" json:"appEUI"`
	Name   string        `db:"name" json:"name"`
}

Application contains the information of an application.

type Channel

type Channel struct {
	ID            int64 `db:"id" json:"id"`
	ChannelListID int64 `db:"channel_list_id" json:"channelListID"`
	Channel       int   `db:"channel" json:"channel"` // set this to channel 3 - 7
	Frequency     int   `db:"frequency" json:"frequency"`
}

Channel represents a single channel.

type ChannelList

type ChannelList struct {
	ID   int64  `db:"id" json:"id"`
	Name string `db:"name" json:"name"`
}

ChannelList represents a list of channels. This list will be used for the FCList field (if allowed for the used band).

type DevNonceList

type DevNonceList [][2]byte

DevNonceList represents a list of dev nonces

func (*DevNonceList) Scan

func (l *DevNonceList) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (DevNonceList) Value

func (l DevNonceList) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type ErrorPayload

type ErrorPayload struct {
	Reference string        `json:"reference"` // refers to the given reference
	DevEUI    lorawan.EUI64 `json:"devEUI"`
	Message   string        `json:"message"`
}

ErrorPayload defines the payload sent on an error event.

type GatewayStatsPacket

type GatewayStatsPacket struct {
	MAC                 lorawan.EUI64          `json:"mac"`
	Time                time.Time              `json:"time"`
	Latitude            float64                `json:"latitude"`
	Longitude           float64                `json:"longitude"`
	Altitude            float64                `json:"altitude"`
	RXPacketsReceived   int                    `json:"rxPacketsReceived"`
	RXPacketsReceivedOK int                    `json:"rxPacketsReceivedOK"`
	TXPacketsEmitted    int                    `json:"txPacketsEmitted"`
	CustomData          map[string]interface{} `json:"customData"` // custom fields defined by alternative packet_forwarder versions (e.g. TTN sends platform, contactEmail, and description)
}

GatewayStatsPacket contains the information of a gateway.

type GetListForAppEUIRequest

type GetListForAppEUIRequest struct {
	AppEUI lorawan.EUI64 `json:"appEUI"`
	Limit  int           `json:"limit"`
	Offset int           `json:"offset"`
}

GetListForAppEUIRequest represents the request for getting a list of objects for the given AppEUI.

type GetListRequest

type GetListRequest struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

GetListRequest represents the request for getting a list of objects.

type JoinNotification

type JoinNotification struct {
	DevAddr lorawan.DevAddr `json:"devAddr"`
	DevEUI  lorawan.EUI64   `json:"devEUI"`
}

JoinNotification defines the payload sent to the application on a JoinNotificationType event.

type MACPayload

type MACPayload struct {
	Reference  string        `json:"reference,omitempty"` // external reference that needs to be defined by the network-controller
	FRMPayload bool          `json:"frmPayload"`          // indicating if the mac command was or must be sent as a FRMPayload (and thus encrypted)
	DevEUI     lorawan.EUI64 `json:"devEUI"`
	MACCommand []byte        `json:"macCommand"`
}

MACPayload contains data from a MAC command.

type Node

type Node struct {
	DevEUI        lorawan.EUI64     `db:"dev_eui" json:"devEUI"`
	AppEUI        lorawan.EUI64     `db:"app_eui" json:"appEUI"`
	AppKey        lorawan.AES128Key `db:"app_key" json:"appKey"`
	UsedDevNonces DevNonceList      `db:"used_dev_nonces" json:"usedDevNonces"`

	RXWindow      RXWindow `db:"rx_window" json:"rxWindow"`
	RXDelay       uint8    `db:"rx_delay" json:"rxDelay"`
	RX1DROffset   uint8    `db:"rx1_dr_offset" json:"rx1DROffset"`
	RX2DR         uint8    `db:"rx2_dr" json:"rx2DR"`
	ChannelListID *int64   `db:"channel_list_id" json:"channelListID"`
}

Node contains the information of a node.

func (*Node) ValidateDevNonce

func (n *Node) ValidateDevNonce(nonce [2]byte) bool

ValidateDevNonce returns if the given dev-nonce is valid. When valid, it will be added to UsedDevNonces. This does not update the Node in the database!

type NodeSession

type NodeSession struct {
	DevAddr  lorawan.DevAddr   `json:"devAddr"`
	AppEUI   lorawan.EUI64     `json:"appEUI"`
	DevEUI   lorawan.EUI64     `json:"devEUI"`
	AppSKey  lorawan.AES128Key `json:"appSKey"`
	NwkSKey  lorawan.AES128Key `json:"nwkSKey"`
	FCntUp   uint32            `json:"fCntUp"`
	FCntDown uint32            `json:"fCntDown"`

	RXWindow    RXWindow `json:"rxWindow"`
	RXDelay     uint8    `json:"rxDelay"`
	RX1DROffset uint8    `json:"rx1DROffset"`
	RX2DR       uint8    `json:"rx2DR"`

	CFList *lorawan.CFList `json:"cFlist"`
}

NodeSession contains the informatio of a node-session (an activated node).

type NotificationType

type NotificationType int

NotificationType defines the notification.

const (
	JoinNotificationType NotificationType = iota
	ErrorNotificationType
	ACKNotificationType
)

Available notification types.

func (NotificationType) String

func (i NotificationType) String() string

type RXInfo

type RXInfo struct {
	MAC       lorawan.EUI64 `json:"mac"`       // MAC address of the gateway
	Time      time.Time     `json:"time"`      // receive time
	Timestamp uint32        `json:"timestamp"` // gateway internal receive timestamp with microsecond precision, will rollover every ~ 72 minutes
	Frequency int           `json:"frequency"` // frequency in Hz
	Channel   int           `json:"channel"`   // concentrator IF channel used for RX
	RFChain   int           `json:"rfChain"`   // RF chain used for RX
	CRCStatus int           `json:"crcStatus"` // 1 = OK, -1 = fail, 0 = no CRC
	CodeRate  string        `json:"codeRate"`  // ECC code rate
	RSSI      int           `json:"rssi"`      // RSSI in dBm
	LoRaSNR   float64       `json:"loRaSNR"`   // LoRa signal-to-noise ratio in dB
	Size      int           `json:"size"`      // packet payload size
	DataRate  band.DataRate `json:"dataRate"`  // RX datarate (either LoRa or FSK)
}

RXInfo contains the RX information.

type RXInfoPayload

type RXInfoPayload struct {
	DevEUI lorawan.EUI64 `json:"devEUI"`
	ADR    bool          `json:"adr"`
	FCnt   uint32        `json:"fCnt"`
	RXInfo []RXInfo      `json:"rxInfo"`
}

RXInfoPayload defines the payload containing the RX information sent to the network-controller on each received packet.

type RXPacket

type RXPacket struct {
	RXInfo     RXInfo             `json:"rxInfo"`
	PHYPayload lorawan.PHYPayload `json:"phyPayload"`
}

RXPacket contains the PHYPayload received from GatewayMAC.

type RXPayload

type RXPayload struct {
	DevEUI       lorawan.EUI64 `json:"devEUI"`
	Time         time.Time     `json:"time"`
	FPort        uint8         `json:"fPort"`
	GatewayCount int           `json:"gatewayCount"`
	RSSI         int           `json:"rssi"`
	Data         []byte        `json:"data"`
}

RXPayload contains the received (decrypted) payload from the node which will be sent to the application.

type RXWindow

type RXWindow int8

RXWindow defines the RX window option.

func (*RXWindow) Scan

func (r *RXWindow) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (RXWindow) Value

func (r RXWindow) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type TXInfo

type TXInfo struct {
	MAC         lorawan.EUI64 `json:"mac"`         // MAC address of the gateway
	Immediately bool          `json:"immediately"` // send the packet immediately (ignore Time)
	Timestamp   uint32        `json:"timestamp"`   // gateway internal receive timestamp with microsecond precision, will rollover every ~ 72 minutes
	Frequency   int           `json:"frequency"`   // frequency in Hz
	Power       int           `json:"power"`       // TX power to use in dBm
	DataRate    band.DataRate `json:"dataRate"`    // TX datarate (either LoRa or FSK)
	CodeRate    string        `json:"codeRate"`    // ECC code rate
}

TXInfo contains the information used for TX.

type TXPacket

type TXPacket struct {
	TXInfo     TXInfo             `json:"txInfo"`
	PHYPayload lorawan.PHYPayload `json:"phyPayload"`
}

TXPacket contains the PHYPayload which should be send to the gateway.

type TXPayload

type TXPayload struct {
	Reference string        `json:"reference"` // external reference that needs to be defined by the application, used for error notifications
	Confirmed bool          `json:"confirmed"` // indicates if the packet needs to be confirmed with an ACK
	DevEUI    lorawan.EUI64 `json:"devEUI"`    // the DevEUI of the node to send the payload to
	FPort     uint8         `json:"fPort"`     // the FPort
	Data      []byte        `json:"data"`      // the data to send (unencrypted, in JSON this must be the base64 representation of the data)
}

TXPayload contains the payload to be sent to the node.

Jump to

Keyboard shortcuts

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