Documentation ¶
Index ¶
- func MustUplinkToken(ids ttnpb.GatewayAntennaIdentifiers, timestamp uint32, ...) []byte
- func ParseUplinkToken(buf []byte) (*ttnpb.UplinkToken, error)
- 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) HandleStatus(status *ttnpb.GatewayStatus) error
- func (c *Connection) HandleTxAck(ack *ttnpb.TxAcknowledgment) error
- func (c *Connection) HandleUp(up *ttnpb.UplinkMessage) 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) (time.Duration, error)
- func (c *Connection) SendDown(msg *ttnpb.DownlinkMessage) error
- func (c *Connection) Stats() *ttnpb.GatewayConnectionStats
- 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, concentrator scheduling.ConcentratorTime)
- 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)
- 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 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) []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) PrimaryFrequencyPlan ¶
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) (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 ¶
func (c *Connection) Stats() *ttnpb.GatewayConnectionStats
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.
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 ¶
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 ¶
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 }
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 // 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 }
Server represents the Gateway Server to gateway frontends.