gatewayserver

package
v0.0.0-...-5352646 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package gatewayserver contains the structs and methods necessary to start a gRPC Gateway Server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicStationConfig

type BasicStationConfig struct {
	FallbackFrequencyPlanID string        `name:"fallback-frequency-plan-id" description:"Fallback frequency plan ID for non-registered gateways"`
	Listen                  string        `name:"listen" description:"Address for the Basic Station frontend to listen on"`
	ListenTLS               string        `name:"listen-tls" description:"Address for the Basic Station frontend to listen on (with TLS)"`
	UseTrafficTLSAddress    bool          `name:"use-traffic-tls-address" description:"Use WSS for the traffic address regardless of the TLS setting"`
	WSPingInterval          time.Duration `name:"ws-ping-interval" description:"Interval to send WS ping messages"`
}

BasicStationConfig defines the Basic Station configuration of the Gateway Server.

type Config

type Config struct {
	RequireRegisteredGateways         bool          `name:"require-registered-gateways" description:"Require the gateways to be registered in the Identity Server"`
	UpdateGatewayLocationDebounceTime time.Duration `name:"update-gateway-location-debounce-time" description:"Debounce time for gateway location updates from status messages"`

	Stats                             GatewayConnectionStatsRegistry `name:"-"`
	UpdateConnectionStatsDebounceTime time.Duration                  `name:"update-connection-stats-debounce-time" description:"Time before repeated refresh of the gateway connection stats"`

	Forward map[string][]string `name:"forward" description:"Forward the DevAddr prefixes to the specified hosts"`

	MQTT         config.MQTT        `name:"mqtt"`
	MQTTV2       config.MQTT        `name:"mqtt-v2"`
	UDP          UDPConfig          `name:"udp"`
	BasicStation BasicStationConfig `name:"basic-station"`
}

Config represents the Gateway Server configuration.

func (Config) ForwardDevAddrPrefixes

func (c Config) ForwardDevAddrPrefixes() (map[string][]types.DevAddrPrefix, error)

ForwardDevAddrPrefixes parses the configured forward map.

type GatewayConnectionStatsRegistry

type GatewayConnectionStatsRegistry interface {
	// Get returns connection stats for a gateway.
	Get(ctx context.Context, ids ttnpb.GatewayIdentifiers) (*ttnpb.GatewayConnectionStats, error)
	// Set updates the connection stats for a gateway.
	Set(ctx context.Context, ids ttnpb.GatewayIdentifiers, stats *ttnpb.GatewayConnectionStats) error
}

GatewayConnectionStatsRegistry stores, updates and cleans up gateway connection stats.

type GatewayServer

type GatewayServer struct {
	*component.Component
	// contains filtered or unexported fields
}

GatewayServer implements the Gateway Server component.

The Gateway Server exposes the Gs, GtwGs and NsGs services and MQTT and UDP frontends for gateways.

func New

func New(c *component.Component, conf *Config, opts ...Option) (gs *GatewayServer, err error)

New returns new *GatewayServer.

func (gs *GatewayServer) ClaimDownlink(ctx context.Context, ids ttnpb.GatewayIdentifiers) error

ClaimDownlink claims the downlink path for the given gateway.

func (*GatewayServer) Connect

func (gs *GatewayServer) Connect(ctx context.Context, frontend io.Frontend, ids ttnpb.GatewayIdentifiers) (*io.Connection, error)

Connect connects a gateway by its identifiers to the Gateway Server, and returns a io.Connection for traffic and control.

func (*GatewayServer) Context

func (gs *GatewayServer) Context() context.Context

Context returns the context of the Gateway Server.

func (*GatewayServer) FillGatewayContext

FillGatewayContext fills the given context and identifiers. This method should only be used for request contexts.

func (*GatewayServer) GetConfig

func (gs *GatewayServer) GetConfig(ctx context.Context) (*Config, error)

GetConfig returns the Gateway Server config based on the context.

func (*GatewayServer) GetConnection

func (gs *GatewayServer) GetConnection(ctx context.Context, ids ttnpb.GatewayIdentifiers) (*io.Connection, bool)

GetConnection returns the *io.Connection for the given gateway. If not found, this method returns nil, false.

func (*GatewayServer) GetFrequencyPlans

GetFrequencyPlans gets the frequency plans by the gateway identifiers.

func (*GatewayServer) GetGatewayConnectionStats

func (gs *GatewayServer) GetGatewayConnectionStats(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (*ttnpb.GatewayConnectionStats, error)

GetGatewayConnectionStats returns statistics about a gateway connection.

func (*GatewayServer) GetMQTTConfig

func (gs *GatewayServer) GetMQTTConfig(ctx context.Context) (*config.MQTT, error)

GetMQTTConfig returns the MQTT frontend configuration based on the context.

func (*GatewayServer) RegisterHandlers

func (gs *GatewayServer) RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)

RegisterHandlers registers gRPC handlers.

func (*GatewayServer) RegisterServices

func (gs *GatewayServer) RegisterServices(s *grpc.Server)

RegisterServices registers services provided by gs at s.

func (*GatewayServer) Roles

func (gs *GatewayServer) Roles() []ttnpb.ClusterRole

Roles returns the roles that the Gateway Server fulfills.

ScheduleDownlink instructs the Gateway Server to schedule a downlink message request. This method returns an error if the downlink path cannot be found, if the requested parameters are invalid for the gateway's frequency plan or if there is no transmission window available because of scheduling conflicts or regional limitations such as duty-cycle and dwell time.

func (gs *GatewayServer) UnclaimDownlink(ctx context.Context, ids ttnpb.GatewayIdentifiers) error

UnclaimDownlink releases the claim of the downlink path for the given gateway.

func (*GatewayServer) UpdateConnectionStats

func (gs *GatewayServer) UpdateConnectionStats(ctx context.Context, conn *io.Connection) error

UpdateConnectionStats updates the stats for a single gateway connection.

type Option

type Option func(*GatewayServer)

Option configures GatewayServer.

func WithRegistry

func WithRegistry(registry ttnpb.GatewayRegistryClient) Option

WithRegistry overrides the registry.

type UDPConfig

type UDPConfig struct {
	udp.Config `name:",squash"`
	Listeners  map[string]string `name:"listeners" description:"Listen addresses with (optional) fallback frequency plan ID for non-registered gateways"`
}

UDPConfig defines the UDP configuration of the Gateway Server.

Directories

Path Synopsis
io
udp
Package scheduling implements a packet scheduling that detects and avoids conflicts and enforces regional restrictions like duty-cycle and dwell time.
Package scheduling implements a packet scheduling that detects and avoids conflicts and enforces regional restrictions like duty-cycle and dwell time.
mock
Package mock provides mock implementation of necessary NS interfaces for testing.
Package mock provides mock implementation of necessary NS interfaces for testing.
ns
Package ns abstracts the V3 Network Server to the upstream.Handler interface.
Package ns abstracts the V3 Network Server to the upstream.Handler interface.

Jump to

Keyboard shortcuts

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