gatewayserver

package
v3.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 48 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 {
	ws.Config               `name:",squash"`
	MaxValidRoundTripDelay  time.Duration `name:"max-valid-round-trip-delay" description:"Maximum valid round trip delay to qualify for RTT calculations"`
	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)"`
}

BasicStationConfig defines the LoRa Basics Station configuration of the Gateway Server.

type Cluster added in v3.14.0

type Cluster interface {
	GetPeerConn(ctx context.Context, role ttnpb.ClusterRole, ids cluster.EntityIdentifiers) (*grpc.ClientConn, error)
	AllowInsecureForCredentials() bool
	WithClusterAuth() grpc.CallOption
}

Cluster provides cluster operations.

type Config

type Config struct {
	RequireRegisteredGateways bool `name:"require-registered-gateways" description:"Require the gateways to be registered in the Identity Server"`

	Stats GatewayConnectionStatsRegistry `name:"-"`

	FetchGatewayInterval time.Duration `name:"fetch-gateway-interval" description:"Fetch gateway interval"`
	FetchGatewayJitter   float64       `name:"fetch-gateway-jitter" description:"Jitter (fraction) to apply to the get interval to randomize intervals"`

	UpdateGatewayLocationDebounceTime time.Duration `name:"update-gateway-location-debounce-time" description:"Debounce time for gateway location updates from status messages"`
	UpdateConnectionStatsInterval     time.Duration `name:"update-connection-stats-interval" description:"Update interval of gateway connection stats"`
	UpdateConnectionStatsDebounceTime time.Duration `name:"update-connection-stats-debounce-time" description:"Time before repeated refresh of the gateway connection stats"`
	ConnectionStatsTTL                time.Duration `` /* 134-byte string literal not displayed */
	ConnectionStatsDisconnectTTL      time.Duration `name:"connection-stats-disconnect-ttl" description:"Time to live of the gateway connection stats after disconnecting"`

	UpdateVersionInfoDelay time.Duration `` /* 143-byte string literal not displayed */

	Forward      map[string][]string `name:"forward" description:"Forward the DevAddr prefixes to the specified hosts"`
	PacketBroker PacketBrokerConfig  `name:"packetbroker" description:"Packet Broker upstream configuration"`

	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 EntityRegistry added in v3.13.1

type EntityRegistry interface {
	// AssertGatewayRights checks whether the gateway authentication (provied in the context) contains the required rights.
	AssertGatewayRights(ctx context.Context, ids *ttnpb.GatewayIdentifiers, required ...ttnpb.Right) error
	// AssertGatewayBatchRights checks whether the caller has the requested rights on all the requested gateways.
	AssertGatewayBatchRights(ctx context.Context, ids []*ttnpb.GatewayIdentifiers, required ...ttnpb.Right) error
	// Get the identifiers of the gateway that has the given EUI registered.
	GetIdentifiersForEUI(ctx context.Context, in *ttnpb.GetGatewayIdentifiersForEUIRequest) (*ttnpb.GatewayIdentifiers, error)
	// Get the gateway with the given identifiers, selecting the fields specified.
	Get(ctx context.Context, in *ttnpb.GetGatewayRequest) (*ttnpb.Gateway, error)
	// UpdateAntennas updates the gateway antennas.
	UpdateAntennas(ctx context.Context, ids *ttnpb.GatewayIdentifiers, antennas []*ttnpb.GatewayAntenna) error
	// UpdateAttributes updates the gateway attributes. It takes the union of current and new values.
	UpdateAttributes(ctx context.Context, ids *ttnpb.GatewayIdentifiers, current, new map[string]string) error
	// ValidateGatewayID validates the ID of the gateway.
	ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error
}

EntityRegistry abstracts the Identity server gateway functions.

type GatewayConnectionStatsRegistry

type GatewayConnectionStatsRegistry interface {
	// Get returns connection stats for a gateway.
	Get(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (*ttnpb.GatewayConnectionStats, error)
	// BatchGet returns connection stats for a batch of gateways.
	BatchGet(
		ctx context.Context,
		ids []*ttnpb.GatewayIdentifiers,
		paths ...string,
	) (map[string]*ttnpb.GatewayConnectionStats, error)
	// Set sets, updates or clears the connection stats for a gateway. Only fields specified in the field mask paths are set.
	Set(
		ctx context.Context,
		ids *ttnpb.GatewayIdentifiers,
		f func(*ttnpb.GatewayConnectionStats) (*ttnpb.GatewayConnectionStats, []string, error),
		ttl time.Duration,
		gets ...string,
	) error
}

GatewayConnectionStatsRegistry stores, updates and cleans up gateway connection stats.

type GatewayServer

type GatewayServer struct {
	ttnpb.UnimplementedGsServer
	ttnpb.UnimplementedNsGsServer

	*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 (*GatewayServer) BatchGetGatewayConnectionStats added in v3.21.0

BatchGetGatewayConnectionStats implements Gs.

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

ClaimDownlink claims the downlink path for the given gateway.

func (*GatewayServer) Connect

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) ValidateGatewayID added in v3.13.3

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

ValidateGatewayID implements io.Server.

type IS added in v3.14.0

type IS struct {
	Cluster
}

IS exposes Identity Server functions.

func NewIS added in v3.14.0

func NewIS(c Cluster) *IS

NewIS returns a new IS.

func (IS) AssertGatewayBatchRights added in v3.28.0

func (is IS) AssertGatewayBatchRights(
	ctx context.Context,
	ids []*ttnpb.GatewayIdentifiers,
	required ...ttnpb.Right,
) error

AssertGatewayBatchRights implements EntityRegistry.

func (IS) AssertGatewayRights added in v3.14.0

func (is IS) AssertGatewayRights(ctx context.Context, ids *ttnpb.GatewayIdentifiers, required ...ttnpb.Right) error

AssertGatewayRights implements EntityRegistry.

func (IS) Get added in v3.14.0

func (is IS) Get(ctx context.Context, req *ttnpb.GetGatewayRequest) (*ttnpb.Gateway, error)

Get implements EntityRegistry.

func (IS) GetIdentifiersForEUI added in v3.14.0

GetIdentifiersForEUI implements EntityRegistry.

func (IS) UpdateAntennas added in v3.14.0

func (is IS) UpdateAntennas(ctx context.Context, ids *ttnpb.GatewayIdentifiers, antennas []*ttnpb.GatewayAntenna) error

UpdateAntennas updates the gateway antennas.

func (IS) UpdateAttributes added in v3.16.1

func (is IS) UpdateAttributes(ctx context.Context, ids *ttnpb.GatewayIdentifiers, current, new map[string]string) error

UpdateAttributes implements EntityRegistry.

func (IS) ValidateGatewayID added in v3.14.0

func (is IS) ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error

ValidateGatewayID implements EntityRegistry.

type Option

type Option func(*GatewayServer)

Option configures GatewayServer.

func WithRegistry

func WithRegistry(registry EntityRegistry) Option

WithRegistry overrides the registry.

type PacketBrokerConfig added in v3.13.3

type PacketBrokerConfig struct {
	UpdateGatewayInterval time.Duration `name:"update-gateway-interval" description:"Update gateway interval"`
	UpdateGatewayJitter   float64       `name:"update-gateway-jitter" description:"Jitter (fraction) to apply to the update interval to randomize intervals"`
	OnlineTTLMargin       time.Duration `name:"online-ttl-margin" description:"Time to extend the online status before it expires"`
}

PacketBrokerConfig configures the Packet Broker upstream.

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
Package io contains the interface between server implementations and the gateway frontends.
Package io contains the interface between server implementations and the gateway frontends.
udp
ws
Package ws provides common interface for Web Socket front end.
Package ws provides common interface for Web Socket front end.
ws/id6
Package id6 provides translation functions to the ID6 format.
Package id6 provides translation functions to the ID6 format.
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.
packetbroker
Package packetbroker abstracts the Packet Broker Agent to the upstream.Handler interface.
Package packetbroker abstracts the Packet Broker Agent to the upstream.Handler interface.

Jump to

Keyboard shortcuts

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