gateway

package
v0.0.0-...-2f095fc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: MIT Imports: 13 Imported by: 0

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 map[string]pb_monitor.GatewayClient

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

Gateway contains the state of a gateway

func NewGateway

func NewGateway(ctx log.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) SetToken

func (g *Gateway) SetToken(token string)

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() <-chan *router_pb.DownlinkMessage
	// Whether the gateway has active downlink
	IsActive() bool
	// Stop the subscription
	Stop()
}

Schedule is used to schedule downlink transmissions

func NewSchedule

func NewSchedule(ctx log.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