gateway

package
v0.0.0-...-cfba5c7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Overview

Package gateway implements the various gateway interfaces.

Index

Constants

View Source
const (
	PushData    = 0  // PushData (aka PUSH_DATA) is used by the gateway to push data to the server
	PushAck     = 1  // PushAck (aka PUSH_ACK) is sent from the server to the gateway as a response to PushData packets
	PullData    = 2  // PullData (aka PULL_DATA) is used to poll from the gateway to the server. It is sent periodically
	PullResp    = 3  // PullResp (aka PULL_RESP) is sent from the server to the gateway indicating that it is connected to the network
	PullAck     = 4  // PullAck (aka PULL_ACK) is sent from the gateway to the server to signal that the network is available
	TxAck       = 5  // TxAck (aka TX_ACK) is sent from the gateway to the server to acknowledge packets
	UnknownType = 99 // UnknownType represents an unknown type identifier

)

Message identifiers for the packet forwarder protocol

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericPacketForwarder

type GenericPacketForwarder struct {
	// contains filtered or unexported fields
}

GenericPacketForwarder is the generic packet forwarder provided by Semtech. It has its weak points but it is the smallest common denominator for all gateways on the market.

func NewGenericPacketForwarder

func NewGenericPacketForwarder(serverPort int, storage storage.GatewayStorage, context *server.Context) *GenericPacketForwarder

NewGenericPacketForwarder creates a new generic packet forwarder listening on a port. There's no authentication (which is TBD) or validation of the gateway (which is a bad idea). The serverPort parameter specifies the port the server will listen on and the gatewayPort specifies which port the gateway is supposed to listen on. There's no need to configure the gateways since the gateway's IP will be attached to the received data.

func (*GenericPacketForwarder) Input

func (p *GenericPacketForwarder) Input() chan<- server.GatewayPacket

Input returns the input channel for the gateway. When a message is received on this channel the message will be forwarded to the gateway.

func (*GenericPacketForwarder) Output

func (p *GenericPacketForwarder) Output() <-chan server.GatewayPacket

Output returns the output channel for the gateway. A message will be sent on this channel every time the gateway has sent a message to the server.

func (*GenericPacketForwarder) Start

func (p *GenericPacketForwarder) Start()

Start launches the generic packet forwarder. It does not return until the gateway shuts down.

func (*GenericPacketForwarder) Stop

func (p *GenericPacketForwarder) Stop()

Stop stops the packet forwarder and closes the channels

type GwPacket

type GwPacket struct {
	ProtocolVersion uint8        // ProtocolVersion protocol version reported to/from the gateway
	Token           uint16       // Token is sent by the gateway and re-used by the server when sending responses.
	Identifier      int          // Identifier is the packet identifier (PUSH_DATA/PUSH_ACK etc)
	GatewayEUI      protocol.EUI // GatewayEUI holds the gateway's EUI. It might be 0 if it isn't set in the originating packet
	JSONString      string       // Option JSON sentence(s) sent by or to the gateway
	Host            string       // The IP address of the gateway that sent the message
	Port            int          // The port of the gateway that sent the message
}

GwPacket represents a packet received from (or sent to) the gateway

func (*GwPacket) MarshalBinary

func (pkt *GwPacket) MarshalBinary() ([]byte, error)

MarshalBinary marshals the packet into a binary byte buffer

func (*GwPacket) UnmarshalBinary

func (pkt *GwPacket) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a byte buffer into a GwPacket structure

type RXData

type RXData struct {
	Data []Rxpk `json:"rxpk"`
}

RXData contains device payload in "Data" and also (possibly) gateway status in "Stat". Both contain JSON

type Rxpk

type Rxpk struct {
	Time                string  `json:"time"` // Time stamp (unix-) for the gateway
	Timestamp           uint32  `json:"tmst"`
	Frequency           float32 `json:"freq"`
	ConcentratorChannel uint8   `json:"chan"`
	ConcentratorRFChain uint8   `json:"rfch"`
	ModulationID        string  `json:"modu"`
	DataRateID          string  `json:"datr"`
	CodingRateID        string  `json:"codr"`
	RSSI                int32   `json:"rssi"`
	LoraSNRRatio        float32 `json:"lsnr"`
	PayloadSize         uint32  `json:"size"`
	RFPackets           string  `json:"data"`
}

Copyright 2018 Telenor Digital AS

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Rxpk is a (JSON) struct used by the Semtech packet forwarder. It is sent from the gateway to the server.

type TXData

type TXData struct {
	Data Txpk `json:"txpk"`
}

TXData is the struct used when transmitting data to the gateway

type Txpk

type Txpk struct {
	Immediate             bool    `json:"imme"`           // (one of)Send packet immediately (will ignore tmst & time)
	Timestamp             uint32  `json:"tmst,omitempty"` // (one of)Send packet on a certain timestamp value (will ignore time)
	Time                  string  `json:"time,omitempty"` // (one of)Send packet at a certain time (GPS synchronization required)
	Frequency             float32 `json:"freq"`           // (mandatory)TX central frequency in MHz (unsigned float, Hz precision)
	RFChain               uint8   `json:"rfch"`           // (mandatory)Concentrator "RF chain" used for TX (unsigned integer)
	TxPower               uint32  `json:"powe,omitempty"` // TX output power in dBm (unsigned integer, dBm precision)
	Modulation            string  `json:"modu"`           // (mandatory)Modulation identifier "LORA" or "FSK"
	LoRaDataRate          string  `json:"datr"`           // (mandatory)LoRa datarate identifier (eg. SF12BW500)
	EccCoding             string  `json:"codr,omitempty"` // LoRa ECC coding rate identifier
	FskFrequencyDeviation uint32  `json:"fdev,omitempty"` // FSK frequency deviation (unsigned integer, in Hz)
	LoraInvPol            bool    `json:"ipol,omitempty"` // Lora modulation polarization inversion
	RfPreamble            uint32  `json:"prea,omitempty"` // RF preamble size (unsigned integer)
	PayloadSize           int     `json:"size"`           // (mandatory)RF packet payload size in bytes (unsigned integer)
	Data                  string  `json:"data"`           // (mandatory)Base64 encoded RF packet payload, padding optional
	NoCRC                 bool    `json:"ncrc,omitempty"` // If true, disable the CRC of the physical layer (optional)

}

Txpk is a (JSON) struct used by the Semtech packet forwarder. It is sent from the server to the gateway

Jump to

Keyboard shortcuts

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