io

package
v3.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustUplinkToken

func MustUplinkToken(ids ttnpb.GatewayAntennaIdentifiers, timestamp uint32, concentratorTime scheduling.ConcentratorTime, serverTime time.Time) []byte

MustUplinkToken returns an uplink token from the given downlink path. This function panics if an error occurs. Use UplinkToken to handle errors.

func ParseUplinkToken

func ParseUplinkToken(buf []byte) (*ttnpb.UplinkToken, error)

ParseUplinkToken returns the downlink path from the given uplink token.

func UplinkToken

func UplinkToken(ids ttnpb.GatewayAntennaIdentifiers, timestamp uint32, concentratorTime scheduling.ConcentratorTime, serverTime time.Time) ([]byte, error)

UplinkToken returns an uplink token from the given downlink path.

Types

type Connection

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

Connection is a connection to a gateway managed by a frontend.

func NewConnection

func NewConnection(ctx context.Context, frontend Frontend, gateway *ttnpb.Gateway, fps *frequencyplans.Store, enforceDutyCycle bool, scheduleAnytimeDelay *time.Duration) (*Connection, error)

NewConnection instantiates a new gateway connection.

func (*Connection) BandID

func (c *Connection) BandID() string

BandID returns the common band ID for the frequency plans in this connection. TODO: Handle mixed bands (https://github.com/TheThingsNetwork/lorawan-stack/issues/1394)

func (*Connection) ConnectTime

func (c *Connection) ConnectTime() time.Time

ConnectTime returns the time the gateway connected.

func (*Connection) Context

func (c *Connection) Context() context.Context

Context returns the connection context.

func (*Connection) Disconnect

func (c *Connection) Disconnect(err error)

Disconnect marks the connection as disconnected and cancels the context.

func (*Connection) Down

func (c *Connection) Down() <-chan *ttnpb.DownlinkMessage

Down returns the downstream channel.

func (*Connection) DownStats

func (c *Connection) DownStats() (total uint64, t time.Time, ok bool)

DownStats returns the downstream statistics.

func (*Connection) FrequencyPlans

func (c *Connection) FrequencyPlans() map[string]*frequencyplans.FrequencyPlan

FrequencyPlans returns the frequency plans for the gateway.

func (*Connection) Frontend

func (c *Connection) Frontend() Frontend

Frontend returns the frontend using this connection.

func (*Connection) Gateway

func (c *Connection) Gateway() *ttnpb.Gateway

Gateway returns the gateway entity.

func (*Connection) HandleStatus

func (c *Connection) HandleStatus(status *ttnpb.GatewayStatus) error

HandleStatus updates the status stats and sends the status to the status channel.

func (*Connection) HandleTxAck

func (c *Connection) HandleTxAck(ack *ttnpb.TxAcknowledgment) error

HandleTxAck sends the acknowledgment to the status channel.

func (*Connection) HandleUp

func (c *Connection) HandleUp(up *ttnpb.UplinkMessage) error

HandleUp updates the uplink stats and sends the message to the upstream channel.

func (*Connection) LocationChanged

func (c *Connection) LocationChanged() <-chan struct{}

LocationChanged returns the location updates channel.

func (*Connection) RTTStats

func (c *Connection) RTTStats(percentile int, t time.Time) (min, max, median, np time.Duration, count int)

RTTStats returns the recorded round-trip time statistics.

func (*Connection) RecordRTT

func (c *Connection) RecordRTT(d time.Duration, t time.Time)

RecordRTT records the given round-trip time.

func (*Connection) ScheduleDown

func (c *Connection) ScheduleDown(path *ttnpb.DownlinkPath, msg *ttnpb.DownlinkMessage) (time.Duration, error)

ScheduleDown schedules and sends a downlink message by using the given path and updates the downlink stats. This method returns an error if the downlink message is not a Tx request.

func (*Connection) SendDown

func (c *Connection) SendDown(msg *ttnpb.DownlinkMessage) error

SendDown sends the downlink message directly on the downlink channel.

func (*Connection) Stats

Stats collects and returns the gateway connection statistics.

func (*Connection) StatsChanged

func (c *Connection) StatsChanged() <-chan struct{}

StatsChanged returns the stats changed channel.

func (*Connection) Status

func (c *Connection) Status() <-chan *ttnpb.GatewayStatus

Status returns the status channel.

func (*Connection) StatusStats

func (c *Connection) StatusStats() (last *ttnpb.GatewayStatus, t time.Time, ok bool)

StatusStats returns the status statistics.

func (*Connection) SyncWithGatewayConcentrator

func (c *Connection) SyncWithGatewayConcentrator(timestamp uint32, server time.Time, concentrator scheduling.ConcentratorTime)

SyncWithGatewayConcentrator synchronizes the clock with the given concentrator timestamp, the server time and the relative gateway time that corresponds to the given timestamp.

func (*Connection) TimeFromTimestampTime

func (c *Connection) TimeFromTimestampTime(timestamp uint32) (scheduling.ConcentratorTime, bool)

TimeFromTimestampTime returns the concentrator time by the given timestamp. This method returns false if the clock is not synced with the server.

func (*Connection) TxAck

func (c *Connection) TxAck() <-chan *ttnpb.TxAcknowledgment

TxAck returns the downlink acknowledgments channel.

func (*Connection) Up

func (c *Connection) Up() <-chan *ttnpb.GatewayUplinkMessage

Up returns the upstream channel.

func (*Connection) UpStats

func (c *Connection) UpStats() (total uint64, t time.Time, ok bool)

UpStats returns the upstream statistics.

type DownlinkTokens

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

DownlinkTokens stores a set of downlink tokens and can be used to track roundtrip time. The number of downlink tokens stored is fixed to 16. New issued tokens with `Next` overwrite the oldest token.

func (DownlinkTokens) Get

func (t DownlinkTokens) Get(token uint16, time time.Time) (correlationIDs []string, delta time.Duration, ok bool)

Get returns the correlation IDs and time difference between the time given to `Next` and the given time by the token. If the token could not be found, this method returns false for `ok`.

func (*DownlinkTokens) Next

func (t *DownlinkTokens) Next(correlationIDs []string, time time.Time) uint16

Next returns a new downlink token.

type Frontend

type Frontend interface {
	// Protocol returns the protocol used in the frontend.
	Protocol() string
	// SupportsDownlinkClaim returns true if the frontend can itself claim downlinks.
	SupportsDownlinkClaim() bool
}

Frontend provides supported features by the gateway frontend.

type Server

type Server interface {
	// GetBaseConfig returns the component configuration.
	GetBaseConfig(ctx context.Context) config.ServiceBase
	// FillGatewayContext fills the given context and identifiers.
	// This method should only be used for request contexts.
	FillGatewayContext(ctx context.Context, ids ttnpb.GatewayIdentifiers) (context.Context, ttnpb.GatewayIdentifiers, error)
	// Connect connects a gateway by its identifiers to the Gateway Server, and returns a Connection for traffic and
	// control.
	Connect(ctx context.Context, frontend Frontend, ids ttnpb.GatewayIdentifiers) (*Connection, error)
	// GetFrequencyPlans gets the frequency plans by the gateway identifiers.
	GetFrequencyPlans(ctx context.Context, ids ttnpb.GatewayIdentifiers) (map[string]*frequencyplans.FrequencyPlan, error)
	// ClaimDownlink claims the downlink path for the given gateway.
	ClaimDownlink(ctx context.Context, ids ttnpb.GatewayIdentifiers) error
	// UnclaimDownlink releases the claim of the downlink path for the given gateway.
	UnclaimDownlink(ctx context.Context, ids ttnpb.GatewayIdentifiers) error
}

Server represents the Gateway Server to gateway frontends.

Directories

Path Synopsis
ws

Jump to

Keyboard shortcuts

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