Documentation
¶
Overview ¶
Package lassie provides a client for the REST API for Telenor LoRa.
All Create* and Update* methods return the created and updated entity, respectively, which may include setting fields that were not set.
Index ¶
- Constants
- type AWSIoTConfig
- type Application
- type Client
- func (c *Client) Address() string
- func (c *Client) Application(eui string) (Application, error)
- func (c *Client) ApplicationStream(appeui string, handler func(DeviceData)) error
- func (c *Client) Applications() ([]Application, error)
- func (c *Client) CreateApplication(app Application) (Application, error)
- func (c *Client) CreateDevice(appeui string, dev Device) (Device, error)
- func (c *Client) CreateGateway(gw Gateway) (Gateway, error)
- func (c *Client) CreateOutput(appEUI string, config OutputConfig) (Output, error)
- func (c *Client) DeleteApplication(eui string) error
- func (c *Client) DeleteDevice(appeui, deveui string) error
- func (c *Client) DeleteGateway(eui string) error
- func (c *Client) DeleteOutput(appEUI, outputEUI string) error
- func (c *Client) Device(appeui, deveui string) (Device, error)
- func (c *Client) Devices(appeui string) ([]Device, error)
- func (c *Client) Gateway(eui string) (Gateway, error)
- func (c *Client) GetScheduledMessage(appeui, deveui string) (DownstreamMessage, error)
- func (c *Client) Output(appEUI, outputEUI string) (Output, error)
- func (c *Client) Outputs(appEUI string) ([]Output, error)
- func (c *Client) ScheduleMessage(appeui, deveui string, msg DownstreamMessage) error
- func (c *Client) UpdateApplication(app Application) (Application, error)
- func (c *Client) UpdateDevice(appeui string, dev Device) (Device, error)
- func (c *Client) UpdateGateway(gw Gateway) (Gateway, error)
- func (c *Client) UpdateOutput(appEUI, outputEUI string, config OutputConfig) (Output, error)
- type ClientError
- type Device
- type DeviceData
- type DownstreamMessage
- type Gateway
- type MQTTConfig
- type Output
- type OutputConfig
- type OutputLogEntry
Constants ¶
const ( // DefaultAddr is the default address of the Congress API. You normally won't // have to change this. DefaultAddr = "https://api.lora.telenor.io" // ConfigFile is the default name for the config file. The configuration // file is a plain text file that contains the default Lassie configuration. // The configuration file is expected to be at the current home directory. ConfigFile = ".lassie" // AddressEnvironmentVariable is the name of the environment variable that // can be used to override the address set in the configuration file. // If the environment variable isn't set (or is empty) the configuration // file settings will be used. AddressEnvironmentVariable = "LASSIE_ADDRESS" // TokenEnvironmentVariable is the name of the environment variable that // can be used to override the token set in the configuration file. TokenEnvironmentVariable = "LASSIE_TOKEN" )
const AWSIoTConfigType = "awsiot"
AWSIoTConfigType is the string identifier for AWS IoT configs.
const MQTTConfigType = "mqtt"
MQTTConfigType is the string idenfier for MQTT configs
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSIoTConfig ¶
type AWSIoTConfig struct { Endpoint string `json:"endpoint"` ClientID string `json:"clientid"` ClientCertificate string `json:"clientCertificate"` PrivateKey string `json:"privateKey"` }
AWSIoTConfig is an application output configuration for AWS IoT.
func (*AWSIoTConfig) Map ¶
func (a *AWSIoTConfig) Map() map[string]interface{}
Map returns the configuration as a map
func (*AWSIoTConfig) Type ¶
func (a *AWSIoTConfig) Type() string
Type returns the string identifying the output
type Application ¶
Application represents an application.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the Telenor LoRa-as-a-Service API.
func New ¶
New creates a new client with the default configuration. The default configuration can be specified in a configuration file or through environment variables.
func NewWithAddr ¶
NewWithAddr creates a new client with the specified address and token.
func (*Client) Application ¶
func (c *Client) Application(eui string) (Application, error)
Application gets an application.
func (*Client) ApplicationStream ¶
func (c *Client) ApplicationStream(appeui string, handler func(DeviceData)) error
ApplicationStream calls handler in its own goroutine for each device message received. It blocks until an error occurs, including EOF when the connection is closed.
func (*Client) Applications ¶
func (c *Client) Applications() ([]Application, error)
Applications gets all applications.
func (*Client) CreateApplication ¶
func (c *Client) CreateApplication(app Application) (Application, error)
CreateApplication creates an application.
func (*Client) CreateDevice ¶
CreateDevice creates a device.
func (*Client) CreateGateway ¶
CreateGateway creates a new gateway
func (*Client) CreateOutput ¶
func (c *Client) CreateOutput(appEUI string, config OutputConfig) (Output, error)
CreateOutput creates a new application output.
func (*Client) DeleteApplication ¶
DeleteApplication deletes an application.
func (*Client) DeleteDevice ¶
DeleteDevice deletes a device.
func (*Client) DeleteGateway ¶
DeleteGateway removes a gateway
func (*Client) DeleteOutput ¶
DeleteOutput removes (and stops) an application output
func (*Client) GetScheduledMessage ¶
func (c *Client) GetScheduledMessage(appeui, deveui string) (DownstreamMessage, error)
GetScheduledMessage returns the scheduled message for the device.
func (*Client) ScheduleMessage ¶
func (c *Client) ScheduleMessage(appeui, deveui string, msg DownstreamMessage) error
ScheduleMessage schedules a downstream message to a device. Port is in range 1-223. If the ack flag is set the message will be re-sent until the device acknowledges it. The payload is hex encoded.
func (*Client) UpdateApplication ¶
func (c *Client) UpdateApplication(app Application) (Application, error)
UpdateApplication updates an application.
func (*Client) UpdateDevice ¶
UpdateDevice updates a device.
func (*Client) UpdateGateway ¶
UpdateGateway updates the gateway
func (*Client) UpdateOutput ¶
func (c *Client) UpdateOutput(appEUI, outputEUI string, config OutputConfig) (Output, error)
UpdateOutput updates an application output with a new configuration
type ClientError ¶
ClientError describes what went wrong with a request that otherwise succeeded but which resulted in an HTTP status code >= 300.
func (ClientError) Error ¶
func (e ClientError) Error() string
type Device ¶
type Device struct { EUI string `json:"deviceEUI"` Type string `json:"deviceType"` DeviceAddress string `json:"devAddr"` ApplicationKey string `json:"appKey"` ApplicationSessionKey string `json:"appSKey"` NetworkSessionKey string `json:"nwkSKey"` FrameCounterUp uint16 `json:"fCntUp"` FrameCounterDown uint16 `json:"fCntDn"` RelaxedCounter bool `json:"relaxedCounter"` KeyWarning bool `json:"keyWarning"` Tags map[string]string `json:"tags"` }
Device represents a device.
type DeviceData ¶
type DeviceData struct { DeviceEUI string `json:"deviceEUI"` DeviceAddress string `json:"devAddr"` GatewayEUI string `json:"gatewayEUI"` ApplicationEUI string `json:"appEUI"` Timestamp int64 `json:"timestamp"` HexData string `json:"data"` Data []byte Frequency float32 `json:"frequency"` DataRate string `json:"dataRate"` RSSI int32 `json:"rssi"` SNR float32 `json:"snr"` }
DeviceData represents data received from a device.
type DownstreamMessage ¶
type DownstreamMessage struct { Port uint8 `json:"port"` Ack bool `json:"ack"` HexPayload string `json:"data"` }
DownstreamMessage represents downstream messages to devices.
type Gateway ¶
type Gateway struct { EUI string `json:"gatewayEUI"` IP string `json:"ip"` StrictIP bool `json:"strictIP"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Altitude float64 `json:"altitude"` Tags map[string]string `json:"tags"` }
Gateway represents a gateway
type MQTTConfig ¶
type MQTTConfig struct { Endpoint string `json:"endpoint"` Port int `json:"port"` TLS bool `json:"tls"` CertificateCheck bool `json:"certCheck"` Username string `json:"username"` Password string `json:"password"` ClientID string `json:"clientid"` TopicName string `json:"topicName"` }
MQTTConfig is an application output configuration for the MQTT outputs.
func (*MQTTConfig) Map ¶
func (m *MQTTConfig) Map() map[string]interface{}
Map returns the configuration as a map
func (*MQTTConfig) Type ¶
func (m *MQTTConfig) Type() string
Type returns a string identifying the output
type Output ¶
type Output struct { EUI string `json:"eui"` AppEUI string `json:"appEUI"` Config map[string]interface{} `json:"config"` Log []OutputLogEntry `json:"logs"` Status string `json:"status"` }
Output contains status, logs and configuration for an application output.
func (*Output) AWSIoTConfig ¶
func (o *Output) AWSIoTConfig() (AWSIoTConfig, error)
AWSIoTConfig returns the AWS IoT config for the output
func (*Output) MQTTConfig ¶
func (o *Output) MQTTConfig() (MQTTConfig, error)
MQTTConfig returns the MQTTConfig for the output.
type OutputConfig ¶
OutputConfig is a configuration for application outputs. Use the actual output types
type OutputLogEntry ¶
OutputLogEntry contains a single log entry from an application output. This log entries are kept just for simple diagnostics. If you are having problems with the output inspect the output's log entries.