Documentation ¶
Overview ¶
Package gatewayserver contains the structs and methods necessary to start a gRPC Gateway Server
Index ¶
- type BasicStationConfig
- type Cluster
- type Config
- type EntityRegistry
- type GatewayConnectionStatsRegistry
- type GatewayServer
- func (gs *GatewayServer) BatchGetGatewayConnectionStats(ctx context.Context, req *ttnpb.BatchGetGatewayConnectionStatsRequest) (*ttnpb.BatchGetGatewayConnectionStatsResponse, error)
- func (gs *GatewayServer) ClaimDownlink(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error
- func (gs *GatewayServer) Connect(ctx context.Context, frontend io.Frontend, ids *ttnpb.GatewayIdentifiers, ...) (*io.Connection, error)
- func (gs *GatewayServer) Context() context.Context
- func (gs *GatewayServer) FillGatewayContext(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (context.Context, *ttnpb.GatewayIdentifiers, error)
- func (gs *GatewayServer) GetConfig(ctx context.Context) (*Config, error)
- func (gs *GatewayServer) GetConnection(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (*io.Connection, bool)
- func (gs *GatewayServer) GetFrequencyPlans(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (map[string]*frequencyplans.FrequencyPlan, error)
- func (gs *GatewayServer) GetGatewayConnectionStats(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (*ttnpb.GatewayConnectionStats, error)
- func (gs *GatewayServer) GetMQTTConfig(ctx context.Context) (*config.MQTT, error)
- func (gs *GatewayServer) RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)
- func (gs *GatewayServer) RegisterServices(s *grpc.Server)
- func (gs *GatewayServer) Roles() []ttnpb.ClusterRole
- func (gs *GatewayServer) ScheduleDownlink(ctx context.Context, down *ttnpb.DownlinkMessage) (*ttnpb.ScheduleDownlinkResponse, error)
- func (gs *GatewayServer) UnclaimDownlink(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error
- func (gs *GatewayServer) ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error
- type IS
- func (is IS) AssertGatewayRights(ctx context.Context, ids *ttnpb.GatewayIdentifiers, required ...ttnpb.Right) error
- func (is IS) Get(ctx context.Context, req *ttnpb.GetGatewayRequest) (*ttnpb.Gateway, error)
- func (is IS) GetIdentifiersForEUI(ctx context.Context, req *ttnpb.GetGatewayIdentifiersForEUIRequest) (*ttnpb.GatewayIdentifiers, error)
- func (is IS) UpdateAntennas(ctx context.Context, ids *ttnpb.GatewayIdentifiers, ...) error
- func (is IS) UpdateAttributes(ctx context.Context, ids *ttnpb.GatewayIdentifiers, ...) error
- func (is IS) ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error
- type Option
- type PacketBrokerConfig
- type UDPConfig
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 // 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, stats *ttnpb.GatewayConnectionStats, paths []string, ttl time.Duration) error }
GatewayConnectionStatsRegistry stores, updates and cleans up gateway connection stats.
type GatewayServer ¶
GatewayServer implements the Gateway Server component.
The Gateway Server exposes the Gs, GtwGs and NsGs services and MQTT and UDP frontends for gateways.
func (*GatewayServer) BatchGetGatewayConnectionStats ¶ added in v3.21.0
func (gs *GatewayServer) BatchGetGatewayConnectionStats( ctx context.Context, req *ttnpb.BatchGetGatewayConnectionStatsRequest, ) (*ttnpb.BatchGetGatewayConnectionStatsResponse, error)
BatchGetGatewayConnectionStats gets statistics about gateway connections to the Gateway Server of a batch of gateways. This RPC skips unconnected gateways. FieldMask paths can be used directly since they are sanitized by the middleware.
func (*GatewayServer) ClaimDownlink ¶
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, addr *ttnpb.GatewayRemoteAddress, ) (*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 ¶
func (gs *GatewayServer) FillGatewayContext(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (context.Context, *ttnpb.GatewayIdentifiers, error)
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 ¶
func (gs *GatewayServer) GetFrequencyPlans(ctx context.Context, ids *ttnpb.GatewayIdentifiers) (map[string]*frequencyplans.FrequencyPlan, error)
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 ¶
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.
func (*GatewayServer) ScheduleDownlink ¶
func (gs *GatewayServer) ScheduleDownlink(ctx context.Context, down *ttnpb.DownlinkMessage) (*ttnpb.ScheduleDownlinkResponse, error)
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 (*GatewayServer) UnclaimDownlink ¶
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 (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) GetIdentifiersForEUI ¶ added in v3.14.0
func (is IS) GetIdentifiersForEUI(ctx context.Context, req *ttnpb.GetGatewayIdentifiersForEUIRequest) (*ttnpb.GatewayIdentifiers, error)
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
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
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. |