Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Deadline = 400 * time.Millisecond
Deadline for sending a downlink back to the gateway TODO: Make configurable
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway struct {
ID string
Status StatusStore
Utilization Utilization
Schedule Schedule
LastSeen time.Time
Monitors pb_monitor.Registry
Ctx ttnlog.Interface
// contains filtered or unexported fields
}
Gateway contains the state of a gateway
func NewGateway ¶
NewGateway creates a new in-memory Gateway structure
func (*Gateway) HandleDownlink ¶
func (g *Gateway) HandleDownlink(identifier string, downlink *pb_router.DownlinkMessage) (err error)
func (*Gateway) HandleUplink ¶
func (g *Gateway) HandleUplink(uplink *pb_router.UplinkMessage) (err error)
type Schedule ¶
type Schedule interface {
fmt.GoStringer
// Synchronize the schedule with the gateway timestamp (in microseconds)
Sync(timestamp uint32)
// Get an "option" on a transmission slot at timestamp for the maximum duration of length (both in microseconds)
GetOption(timestamp uint32, length uint32) (id string, score uint)
// Schedule a transmission on a slot
Schedule(id string, downlink *router_pb.DownlinkMessage) error
// Subscribe to downlink messages
Subscribe(subscriptionID string) <-chan *router_pb.DownlinkMessage
// Whether the gateway has active downlink
IsActive() bool
// Stop the subscription
Stop(subscriptionID string)
}
Schedule is used to schedule downlink transmissions
func NewSchedule ¶
NewSchedule creates a new Schedule
type StatusStore ¶
type StatusStore interface {
// Insert or Update the status
Update(status *pb_gateway.Status) error
// Get the last status
Get() (*pb_gateway.Status, error)
}
StatusStore is a database for setting and retrieving the latest gateway status
func NewStatusStore ¶
func NewStatusStore() StatusStore
NewStatusStore creates a new in-memory status store
type Utilization ¶
type Utilization interface {
fmt.GoStringer
// AddRx updates the utilization for receiving an uplink message
AddRx(uplink *pb_router.UplinkMessage) error
// AddRx updates the utilization for transmitting a downlink message
AddTx(downlink *pb_router.DownlinkMessage) error
// Get returns the overall rx and tx utilization for the gateway. If the gateway has multiple channels, the values will be 0 <= value < numChannels
Get() (rx float64, tx float64)
// GetChannel returns the rx and tx utilization for the given channel. The values will be 0 <= value < 1
GetChannel(frequency uint64) (rx float64, tx float64)
// Tick the clock to update the moving average. It should be called every 5 seconds
Tick()
}
Utilization manages the utilization of a gateway and its channels It is based on an exponentially weighted moving average over one minute
Click to show internal directories.
Click to hide internal directories.