handler

package
v2.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AMQPBufferSize = 10

AMQPBufferSize indicates the size for uplink channel buffers

View Source
var (
	// AMQPDownlinkQueue is the AMQP queue to use for downlink
	AMQPDownlinkQueue = "ttn-handler-downlink"
)
View Source
var ErrNotNeeded = errors.New("Further processing not needed")

ErrNotNeeded indicates that the processing of a message should be aborted

View Source
var MQTTBufferSize = 10

MQTTBufferSize indicates the size for uplink channel buffers

View Source
var MQTTTimeout = 2 * time.Second

MQTTTimeout indicates how long we should wait for an MQTT publish

View Source
var ResponseDeadline = 100 * time.Millisecond

ResponseDeadline indicates how long

Functions

This section is empty.

Types

type CustomDownlinkFunctions

type CustomDownlinkFunctions struct {
	// Encoder is a JavaScript function that accepts the payload as JSON and
	// returns an array of bytes
	Encoder string

	// Logger is the logger that will be used to store logs
	Logger functions.Logger
}

CustomDownlinkFunctions encodes payload using JavaScript functions

func (*CustomDownlinkFunctions) Encode

func (f *CustomDownlinkFunctions) Encode(payload map[string]interface{}, port uint8) ([]byte, bool, error)

Encode encodes the specified field, converts it into a valid payload

func (*CustomDownlinkFunctions) Log

Log returns the log

type CustomUplinkFunctions

type CustomUplinkFunctions struct {
	// Decoder is a JavaScript function that accepts the payload as byte array and
	// returns an object containing the decoded values
	Decoder string
	// Converter is a JavaScript function that accepts the data as decoded by
	// Decoder and returns an object containing the converted values
	Converter string
	// Validator is a JavaScript function that validates the data is converted by
	// Converter and returns a boolean value indicating the validity of the data
	Validator string

	// Logger is the logger that will be used to store logs
	Logger functions.Logger
}

CustomUplinkFunctions decodes, converts and validates payload using JavaScript functions

func (*CustomUplinkFunctions) Decode

func (f *CustomUplinkFunctions) Decode(payload []byte, port uint8) (map[string]interface{}, bool, error)

Decode decodes the specified payload, converts it and tests the validity

func (*CustomUplinkFunctions) Log

Log returns the log

type DownlinkProcessor

type DownlinkProcessor func(ctx ttnlog.Interface, appDown *types.DownlinkMessage, ttnDown *pb_broker.DownlinkMessage, device *device.Device) error

DownlinkProcessor processes an application-layer downlink message to a downlik protobuf

type Handler

type Handler interface {
	component.Interface
	component.ManagementInterface

	WithMQTT(username, password string, brokers ...string) Handler
	WithAMQP(username, password, host, exchange string) Handler
	WithDeviceAttributes(attribute ...string) Handler

	HandleUplink(uplink *pb_broker.DeduplicatedUplinkMessage) error
	HandleActivationChallenge(challenge *pb_broker.ActivationChallengeRequest) (*pb_broker.ActivationChallengeResponse, error)
	HandleActivation(activation *pb_broker.DeduplicatedDeviceActivationRequest) (*pb.DeviceActivationResponse, error)
	EnqueueDownlink(appDownlink *types.DownlinkMessage) error
}

Handler component

func NewRedisHandler

func NewRedisHandler(client *redis.Client, ttnBrokerID string) Handler

NewRedisHandler creates a new Redis-backed Handler

type PayloadDecoder

type PayloadDecoder interface {
	Decode(payload []byte, fPort uint8) (map[string]interface{}, bool, error)
	Log() []*pb_handler.LogEntry
}

PayloadDecoder decodes raw payload to fields

type PayloadEncoder

type PayloadEncoder interface {
	Encode(fields map[string]interface{}, fPort uint8) ([]byte, bool, error)
	Log() []*pb_handler.LogEntry
}

PayloadEncoder encodes fields to raw payload

type UplinkProcessor

type UplinkProcessor func(ctx ttnlog.Interface, ttnUp *pb_broker.DeduplicatedUplinkMessage, appUp *types.UplinkMessage, device *device.Device) error

UplinkProcessor processes an uplink protobuf to an application-layer uplink message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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