processor

package
v0.0.0-...-cfba5c7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package processor contains the various steps in the processing pipeline.package processor

Index

Constants

View Source
const DefaultRXDelay time.Duration = 200 * time.Millisecond

DefaultRXDelay is the default delay

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder is the process that decodes the bytes received from the gateway interface into go structs.

func NewDecoder

func NewDecoder(context *server.Context, input <-chan server.GatewayPacket) *Decoder

NewDecoder creates a new decoder.

func (*Decoder) Output

func (d *Decoder) Output() <-chan server.LoRaMessage

Output returns the output channel from the decoder. This channel will receive a message every time a message is successfully decoded.

func (*Decoder) Start

func (d *Decoder) Start()

Start launches the decoder. It will terminate when the input channel is closed. On exit the output channel will be closed.

type Decrypter

type Decrypter struct {
	// contains filtered or unexported fields
}

Decrypter decrypts the decoded LoRa packets into payloads. It will receive decoded packets on one channel and submit decrypted payloads on another channel.

func NewDecrypter

func NewDecrypter(context *server.Context, input <-chan server.LoRaMessage) *Decrypter

NewDecrypter creates a new decrypter instance.

func (*Decrypter) Output

func (d *Decrypter) Output() <-chan server.LoRaMessage

Output returns the MAC notification output from the decrypter. This channel will receive a message every time a message is successfully verified and decrypted.

func (*Decrypter) Start

func (d *Decrypter) Start()

Start launches the decrypter. It will loop forever until the input channel closes. The output channel will be closed upon return. BUG(stalehd): Doesn't do what it says -- decrypt

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder receives LoRaMessage data structures on a channel, encodes into a binary buffer and sends the buffer as a GatewayPacket instance on a new channel.

func NewEncoder

func NewEncoder(context *server.Context, input <-chan server.LoRaMessage, output chan<- server.GatewayPacket) *Encoder

NewEncoder creates a new Encoder instance.

func (*Encoder) Start

func (e *Encoder) Start()

Start starts the Encoder instance. It will terminate when the input channel is closed. The output channel is closed when the method stops. The input channel receives messages due to be sent to gateways a short time before the messages must be sent from the gateway.

type GwForwarder

type GwForwarder interface {
	// Start launches the forwarder and starts sending and receiving packets
	Start()
	// Stop terminates the forwarder and closes the input and output channels.
	Stop()
	// Input returns the input channel for the forwarder (ie data to send)
	Input() chan<- server.GatewayPacket
	// Output returns the output channel for the forwarder (ie data received)
	Output() <-chan server.GatewayPacket
}

GwForwarder is the generic gateway interface. All of the communication is done via two channels. Outputs from the gateway is sent on the output channel while inputs are forwarded to the gateway.

func NewGwForwarder

func NewGwForwarder(port int, context *server.Context) GwForwarder

NewGwForwarder creates a new gateway forwarder instance. The input and output channels

type MACProcessor

type MACProcessor struct {
	// contains filtered or unexported fields
}

MACProcessor is the process responsible for processing the MAC commands.

func NewMACProcessor

func NewMACProcessor(context *server.Context, input <-chan server.LoRaMessage) *MACProcessor

NewMACProcessor creates a new MAC processor instance.

func (*MACProcessor) CommandNotifier

func (m *MACProcessor) CommandNotifier() <-chan server.LoRaMessage

CommandNotifier returns the output channel for the MAC processor. A new message is sent on the channel every time the MAC processing step is completed, even if there's no new MAC commands that must be sent.

func (*MACProcessor) Start

func (m *MACProcessor) Start()

Start launches the MAC processor. When the input channel is closed the method will stop and the notifier channel will be closed.

type Pipeline

type Pipeline struct {
	Decoder      *Decoder
	Decrypter    *Decrypter
	MACProcessor *MACProcessor
	Scheduler    *Scheduler
	Encoder      *Encoder
}

Pipeline is the main processing pipeline for the server. Each step in the pipeline is handled by one or more goroutines. Channels are used to forward messages between the steps in the pipeline the channels are unbuffered at the moment and each step runs as a single goroutine. If one of the steps end up being a bottleneck we can increase the number of outputs and at the same time buffer the channels.

The pipeline is roughly built like this:

GW Forwarder -> Decoder -> Decrypter -> MAC Processor
      => Scheduler => Encoder -> GW Forwarder

func NewPipeline

func NewPipeline(context *server.Context, forwarder GwForwarder) *Pipeline

NewPipeline creates a new pipeline. The pipeline will stop automatically when the forwarder is terminated

func (*Pipeline) Start

func (p *Pipeline) Start()

Start launches the pipeline

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler is the process that schedules downlink frames. The sceduler reads from a command notifier channel and will schedule a frame to be sent to the device when it receives notification of an uplink. If the frame to be sent is empty it won't generate any output.

func NewScheduler

func NewScheduler(context *server.Context, commandNotifier <-chan server.LoRaMessage) *Scheduler

NewScheduler creates a new scheduler.

func (*Scheduler) Output

func (s *Scheduler) Output() <-chan server.LoRaMessage

Output returns the output channel for the scheduler. A new message is sent on the channel whenever it is ready to be sent to a device.

func (*Scheduler) SetRXDelay

func (s *Scheduler) SetRXDelay(newDelay time.Duration)

SetRXDelay adjusts the RX delay. This is only for testing

func (*Scheduler) Start

func (s *Scheduler) Start()

Start launches the scheduler. When the notifier channel is closed it will stop and the output channel will be closed.

Notes

Bugs

  • Doesn't do what it says -- decrypt

Jump to

Keyboard shortcuts

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