Documentation ¶
Overview ¶
Package model contains the high-level entities in the LoRaWAN spec.package model
Index ¶
Constants ¶
const ( // TransportTypeKey is the key used to identify the output (and configuration) TransportTypeKey = TransportConfigKey("type") )
Variables ¶
var ( // ErrInvalidChars is returned when a tag contains invalid chars ErrInvalidChars = errors.New("invalid characters in tag") )
Functions ¶
This section is empty.
Types ¶
type APIToken ¶
APIToken represents an API token that the users can use to access the API. There are two basic roles -- "read" and "write", set by the ReadOnly flag.
The resource is a HTTP URI. A token with the resource
/applications/<eui>
would give access to that particular application while a token with the resource set to
/applications
would give access to all of the applications. The most relaxed resource is a single `/` which gives access to *all* resources owned by the user. The user ID is the CONNECT ID user id. The token itself is a string of alphanumeric characters.
func NewAPIToken ¶
NewAPIToken creates a new API token.
type AppOutput ¶
type AppOutput struct { EUI protocol.EUI // Unique identifier for output AppEUI protocol.EUI // The associated application Configuration TransportConfig // Output configuration }
AppOutput is configuration for application outputs (MQTT et al)
type Application ¶
Application represents a LoRa application instance.
func NewApplication ¶
func NewApplication() Application
NewApplication creates a new application instance
func (*Application) Equals ¶
func (a *Application) Equals(other Application) bool
Equals returns true if the other application has identical fields. Just like ...Equals
func (*Application) GenerateAppNonce ¶
func (a *Application) GenerateAppNonce() ([3]byte, error)
GenerateAppNonce generates a new AppNonce, three random bytes that will be used to generate new devices.
type Device ¶
type Device struct { DeviceEUI protocol.EUI // EUI for device DevAddr protocol.DevAddr // Device address AppKey protocol.AESKey // AES key for application AppSKey protocol.AESKey // Application session key NwkSKey protocol.AESKey // Network session key AppEUI protocol.EUI // The application associated with the device. Set by storage backend State DeviceState // Current state of the device FCntUp uint16 // Frame counter up (from device) FCntDn uint16 // Frame counter down (to device) RelaxedCounter bool // Relaxed frame count checks DevNonceHistory []uint16 // Log of DevNonces sent from the device KeyWarning bool // Duplicate key warning flag Tags }
Device represents a device. Devices are associated with one and only one Application
func (*Device) GetRX1Window ¶
GetRX1Window returns the 1st receive window for the device BUG(stlaehd): Returns constant. Should be set based on device settings and frequency plan.
func (*Device) GetRX2Window ¶
GetRX2Window returns the 2nd receive window for the device BUG(stalehd): Returns a constant. Should be set based on frequency plan (EU, US, CN)
func (*Device) HasDevNonce ¶
HasDevNonce returns true if the specified nonce exists in the nonce history
type DeviceData ¶
type DeviceData struct { DeviceEUI protocol.EUI // Device address used Timestamp int64 // Timestamp for message. Data type might change. Data []byte // The data the end-device sent GatewayEUI protocol.EUI // The gateway the message was received from. RSSI int32 // Radio stats; RSSI SNR float32 // Radio; SNR Frequency float32 // Radio; Frequency DataRate string // Data rate (ie "SF7BW125" or similar) DevAddr protocol.DevAddr // The reported DevAddr (at the time) }
DeviceData contains a single transmission from an end-device.
func (*DeviceData) Equals ¶
func (d *DeviceData) Equals(other DeviceData) bool
Equals compares two DeviceData instances
type DeviceState ¶
type DeviceState uint8
DeviceState represents the device state
const ( OverTheAirDevice DeviceState = 1 PersonalizedDevice DeviceState = 8 // Note: 8 is for backwards compatibility DisabledDevice DeviceState = 0 )
Types of devices. A device can either be OTAA, ABP or disabled.
func DeviceStateFromString ¶
func DeviceStateFromString(str string) (DeviceState, error)
DeviceStateFromString converts a string representation of DeviceState into a DeviceState value. Unknown strings returns the DisabledDevice state. Conversion is not case sensitive. White space is trimmed.
func (DeviceState) String ¶
func (d DeviceState) String() string
String converts the device state into a human-readable string representation.
type DownstreamMessage ¶
type DownstreamMessage struct { DeviceEUI protocol.EUI Data string Port uint8 Ack bool CreatedTime int64 SentTime int64 AckTime int64 }
DownstreamMessage is messages sent downstream (ie to devices from the server).
func NewDownstreamMessage ¶
func NewDownstreamMessage(deviceEUI protocol.EUI, port uint8) DownstreamMessage
NewDownstreamMessage creates a new DownstreamMessage
func (*DownstreamMessage) IsComplete ¶
func (d *DownstreamMessage) IsComplete() bool
IsComplete returns true if the message processing is completed. If the ack flag isn't set the message would only have to be sent to the device. If the ack flag is set the device must acknowledge the message before it is considered completed.
func (*DownstreamMessage) Payload ¶
func (d *DownstreamMessage) Payload() []byte
Payload returns the payload as a byte array. If there's an error decoding the data it will return an empty byte array
func (*DownstreamMessage) State ¶
func (d *DownstreamMessage) State() DownstreamMessageState
State returns the message's state based on the value of the time stamps
type DownstreamMessageState ¶
type DownstreamMessageState uint8
DownstreamMessageState is the state of the downstream messages
const ( UnsentState DownstreamMessageState = iota SentState AcknowledgedState )
States for the downstream message
type Gateway ¶
type Gateway struct { GatewayEUI protocol.EUI // EUI of gateway. IP net.IP // IP address of gateway. This might not be fixed. StrictIP bool // Strict IP address check Latitude float32 // Latitude, in decimal degrees, positive N <-90-90> Longitude float32 // Longitude, in decimal degrees, positive E [-180-180> Altitude float32 // Altitude, meters Tags }
Gateway represents - you guessed it - a gateway.
type PublicGatewayInfo ¶
type PublicGatewayInfo struct { EUI string // EUI of gateway. Latitude float32 // Latitude, in decimal degrees, positive N <-90-90> Longitude float32 // Longitude, in decimal degrees, positive E [-180-180> Altitude float32 // Altitude, meters }
PublicGatewayInfo contains public information for gateways. This information is available to all users, even the ones not owning a gateway.
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags contains
func NewTagsFromBuffer ¶
NewTagsFromBuffer unmarshals a JSON struct into a Tags structure
func NewTagsFromMap ¶
NewTagsFromMap builds a new tags structure from a map
func (*Tags) SetTag ¶
SetTag adds or replaces a tag. ErrInvalidChars are returned if the tag name or value contains invalid characters
type TransportConfig ¶
type TransportConfig map[TransportConfigKey]interface{}
TransportConfig is a generic configuration for outputs. This is in effect a simple map keyed on a string.
func NewTransportConfig ¶
func NewTransportConfig(jsonString string) (TransportConfig, error)
NewTransportConfig creates a new OutputConfig from a JSON string
func (TransportConfig) Bool ¶
func (t TransportConfig) Bool(key TransportConfigKey, def bool) bool
Bool returns the key value as a boolean. If the key doesn't exist or the key is of a different type the default will be returned
func (TransportConfig) Int ¶
func (t TransportConfig) Int(key TransportConfigKey, def int) int
Int returns the key value as a boolean. If the key doesn't exist or the key is of a different type the default will be returned
func (TransportConfig) String ¶
func (t TransportConfig) String(key TransportConfigKey, def string) string
String returns the key value as a string. If the key doesn't exist or the key is of a different type the default will be returned
type TransportConfigKey ¶
type TransportConfigKey string
TransportConfigKey is the key for configuration items
type User ¶
User is the user owning/administering applications. Authentication and authorization are performed by external systems.
Notes ¶
Bugs ¶
Returns constant. Should be set based on device settings and frequency plan.
Returns a constant. Should be set based on frequency plan (EU, US, CN)