Documentation ¶
Index ¶
- func MustUplinkToken(ids *ttnpb.GatewayAntennaIdentifiers, timestamp uint32, ...) []byte
- func ParseUplinkToken(buf []byte) (*ttnpb.UplinkToken, error)
- func UniqueUplinkMessagesByRSSI(uplinks []*ttnpb.UplinkMessage) []*ttnpb.UplinkMessage
- func UplinkToken(ids *ttnpb.GatewayAntennaIdentifiers, timestamp uint32, ...) ([]byte, error)
- type Connection
- func (c *Connection) BandID() string
- func (c *Connection) ConnectTime() time.Time
- func (c *Connection) Context() context.Context
- func (c *Connection) Disconnect(err error)
- func (c *Connection) Down() <-chan *ttnpb.DownlinkMessage
- func (c *Connection) DownStats() (total uint64, t time.Time, ok bool)
- func (c *Connection) FrequencyPlans() map[string]*frequencyplans.FrequencyPlan
- func (c *Connection) Frontend() Frontend
- func (c *Connection) Gateway() *ttnpb.Gateway
- func (c *Connection) GatewayRemoteAddress() *ttnpb.GatewayRemoteAddress
- func (c *Connection) HandleStatus(status *ttnpb.GatewayStatus) (err error)
- func (c *Connection) HandleTxAck(ack *ttnpb.TxAcknowledgment) (err error)
- func (c *Connection) HandleUp(up *ttnpb.UplinkMessage, frontendSync *FrontendClockSynchronization) (err error)
- func (c *Connection) LocationChanged() <-chan struct{}
- func (c *Connection) PrimaryFrequencyPlan() *frequencyplans.FrequencyPlan
- func (c *Connection) RTTStats(percentile int, t time.Time) (min, max, median, np time.Duration, count int)
- func (c *Connection) RecordRTT(d time.Duration, t time.Time)
- func (c *Connection) ScheduleDown(path *ttnpb.DownlinkPath, msg *ttnpb.DownlinkMessage) (rx1, rx2 bool, delay time.Duration, err error)
- func (c *Connection) SendDown(msg *ttnpb.DownlinkMessage) error
- func (c *Connection) Stats() (*ttnpb.GatewayConnectionStats, []string)
- func (c *Connection) StatsChanged() <-chan struct{}
- func (c *Connection) Status() <-chan *ttnpb.GatewayStatus
- func (c *Connection) StatusStats() (last *ttnpb.GatewayStatus, t time.Time, ok bool)
- func (c *Connection) SyncWithGatewayConcentrator(timestamp uint32, server time.Time, gateway *time.Time, ...) scheduling.ConcentratorTime
- func (c *Connection) TimeFromServerTime(t time.Time) (scheduling.ConcentratorTime, bool)
- func (c *Connection) TimeFromTimestampTime(timestamp uint32) (scheduling.ConcentratorTime, bool)
- func (c *Connection) TxAck() <-chan *ttnpb.TxAcknowledgment
- func (c *Connection) Up() <-chan *ttnpb.GatewayUplinkMessage
- func (c *Connection) UpStats() (total uint64, t time.Time, ok bool)
- func (c *Connection) VersionInfoChanged() <-chan struct{}
- type DownlinkTokens
- func (t DownlinkTokens) FormatCorrelationID(token uint16) string
- func (t DownlinkTokens) Get(token uint16, time time.Time) (*ttnpb.DownlinkMessage, time.Duration, bool)
- func (t *DownlinkTokens) Next(msg *ttnpb.DownlinkMessage, time time.Time) uint16
- func (t DownlinkTokens) ParseTokenFromCorrelationIDs(cids []string) (uint16, bool)
- type Frontend
- type FrontendClockSynchronization
- type Server
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, gatewayTime *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 UniqueUplinkMessagesByRSSI ¶ added in v3.14.0
func UniqueUplinkMessagesByRSSI(uplinks []*ttnpb.UplinkMessage) []*ttnpb.UplinkMessage
UniqueUplinkMessagesByRSSI returns the given list of gateway uplink messages after discarding duplicates by RSSI. Two gateway uplink messages are considered duplicates if the RawPayload is identical, and the RSSI values differ. In these cases, only the gateway uplink message with the highest RSSI will be included in the result.
UniqueUplinkMessagesByRSSI will allocate a new list of uplink messages, but will not copy the uplink messages themselves.
func UplinkToken ¶
func UplinkToken(ids *ttnpb.GatewayAntennaIdentifiers, timestamp uint32, concentratorTime scheduling.ConcentratorTime, serverTime time.Time, gatewayTime *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, addr *ttnpb.GatewayRemoteAddress, ) (*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) GatewayRemoteAddress ¶ added in v3.20.2
func (c *Connection) GatewayRemoteAddress() *ttnpb.GatewayRemoteAddress
GatewayRemoteAddress returns the time the remote address of the gateway as seen by the server.
func (*Connection) HandleStatus ¶
func (c *Connection) HandleStatus(status *ttnpb.GatewayStatus) (err error)
HandleStatus updates the status stats and sends the status to the status channel.
func (*Connection) HandleTxAck ¶
func (c *Connection) HandleTxAck(ack *ttnpb.TxAcknowledgment) (err error)
HandleTxAck sends the acknowledgment to the status channel.
func (*Connection) HandleUp ¶
func (c *Connection) HandleUp(up *ttnpb.UplinkMessage, frontendSync *FrontendClockSynchronization) (err 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) PrimaryFrequencyPlan ¶ added in v3.10.0
func (c *Connection) PrimaryFrequencyPlan() *frequencyplans.FrequencyPlan
PrimaryFrequencyPlan returns the primary frequency plan of the gateway.
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) (rx1, rx2 bool, delay time.Duration, err 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 ¶
func (c *Connection) Stats() (*ttnpb.GatewayConnectionStats, []string)
Stats collects and returns the gateway connection statistics and the field mask paths.
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, gateway *time.Time, concentrator scheduling.ConcentratorTime) 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) TimeFromServerTime ¶ added in v3.16.0
func (c *Connection) TimeFromServerTime(t time.Time) (scheduling.ConcentratorTime, bool)
TimeFromServerTime returns the concentrator time by the given server time. This method returns false if the clock is not synced with the server.
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.
func (*Connection) VersionInfoChanged ¶ added in v3.16.1
func (c *Connection) VersionInfoChanged() <-chan struct{}
VersionInfoChanged returns the version info updates channel.
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) FormatCorrelationID ¶ added in v3.12.0
func (t DownlinkTokens) FormatCorrelationID(token uint16) string
FormatCorrelationID formats a correlation ID for a downlink token.
func (DownlinkTokens) Get ¶
func (t DownlinkTokens) Get(token uint16, time time.Time) (*ttnpb.DownlinkMessage, time.Duration, 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.
func (*DownlinkTokens) Next ¶
func (t *DownlinkTokens) Next(msg *ttnpb.DownlinkMessage, time time.Time) uint16
Next returns a new downlink token for a downlink message.
func (DownlinkTokens) ParseTokenFromCorrelationIDs ¶ added in v3.12.0
func (t DownlinkTokens) ParseTokenFromCorrelationIDs(cids []string) (uint16, bool)
ParseTokenFromCorrelationIDs parses the correlation ID
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 // DutyCycleStyle returns the duty cycle style used by the frontend. DutyCycleStyle() scheduling.DutyCycleStyle }
Frontend provides supported features by the gateway frontend.
type FrontendClockSynchronization ¶ added in v3.16.1
type FrontendClockSynchronization struct { Timestamp uint32 ServerTime time.Time GatewayTime *time.Time ConcentratorTime scheduling.ConcentratorTime }
FrontendClockSynchronization contains the clock synchronization timestamps provided by a frontend for manual synchronization.
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, addr *ttnpb.GatewayRemoteAddress) (*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 // FromRequestContext decouples the lifetime of the provided context from the values found in the context. FromRequestContext(ctx context.Context) context.Context // RateLimiter returns the rate limiter instance. RateLimiter() ratelimit.Interface // ValidateGatewayID validates the ID of the gateway. ValidateGatewayID(ctx context.Context, ids *ttnpb.GatewayIdentifiers) error task.Starter }
Server represents the Gateway Server to gateway frontends.