gateway

package
v2.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2017 License: MIT Imports: 14 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Deadline = 800 * 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

	Monitor       *pb_monitor.Client
	MonitorStream pb_monitor.GenericStream

	Ctx ttnlog.Interface
	// contains filtered or unexported fields
}

Gateway contains the state of a gateway

func NewGateway

func NewGateway(ctx ttnlog.Interface, id string) *Gateway

NewGateway creates a new in-memory Gateway structure

func (g *Gateway) HandleDownlink(identifier string, downlink *pb_router.DownlinkMessage) (err error)

func (*Gateway) HandleStatus

func (g *Gateway) HandleStatus(status *pb.Status) (err error)
func (g *Gateway) HandleUplink(uplink *pb_router.UplinkMessage) (err error)

func (*Gateway) SetAuth

func (g *Gateway) SetAuth(token string, authenticated bool)

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

func NewSchedule(ctx ttnlog.Interface) Schedule

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

func NewUtilization

func NewUtilization() Utilization

NewUtilization creates a new Utilization

Jump to

Keyboard shortcuts

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