alcsyncv1

package
v3.30.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package alcsyncv1 provides the LoRa Application Layer Clock Synchronization Package.

Index

Constants

View Source
const PackageName = "alcsync-v1"

PackageName is the name of the package.

Variables

View Source
var (
	// EvtTimeCorrectionCmdReceived is the event that is published when
	// a time correction command is received and successfully parsed.
	EvtTimeCorrectionCmdReceived = defineCmdReceivedEvent(
		"time_correction", "time correction",
		events.WithDataType(&ttnpb.ALCSyncCommand_AppTimeReq{}),
	)()

	// EvtTimeCorrectionAnsEnqueue is the event that is published when
	// a time correction command is processed successfully and an answer is enqueued.
	EvtTimeCorrectionAnsEnqueue = defineCmdAnsEnqueueEvent(
		"time_correction", "time correction",
		events.WithDataType(&ttnpb.ALCSyncCommand_AppTimeAns{}),
	)()

	// EvtPkgFail is the event that is published when an error occurs in the package.
	EvtPkgFail = events.Define(
		"as.packages.alcsync.v1.fail", "package failed due to error", eventOptions(
			events.WithErrorDataType(), events.WithPropagateToParent(),
		)...,
	)
)

Functions

func MakeDownlink(results []Result, fPort uint32) (*ttnpb.ApplicationDownlink, error)

MakeDownlink builds a single downlink message from the results.

func New

New returns a new ALCSync package.

Types

type Command

type Command interface {
	// Code returns the command code.
	Code() ttnpb.ALCSyncCommandIdentifier

	// CommandReceivedEventBuilder returns the event that should be emitted when the command is successfully parsed.
	CommandReceivedEventBuilder() events.Builder

	// Execute runs the command logic.
	Execute() (Result, error)
}

Command is the interface for commands.

func MakeCommands

func MakeCommands(up *ttnpb.ApplicationUplink, fPort uint32, data *packageData) ([]Command, events.Builders, error)

MakeCommands parses the uplink payload and returns the commands.

type Result

type Result interface {
	// MarshalBinary marshals the result into a binary representation.
	MarshalBinary() ([]byte, error)

	// AnswerEnqueuedEventBuilder returns the event that should be emitted when the answer is enqueued or executed.
	AnswerEnqueuedEventBuilder() events.Builder
}

Result is the result of a command execution.

type TimeSyncCommand

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

TimeSyncCommand is the command for time synchronization.

func (*TimeSyncCommand) Code

Code implements commands.Command.

func (*TimeSyncCommand) CommandReceivedEventBuilder

func (cmd *TimeSyncCommand) CommandReceivedEventBuilder() events.Builder

CommandReceivedEventBuilder implements commands.Command.

func (*TimeSyncCommand) Execute

func (cmd *TimeSyncCommand) Execute() (Result, error)

Execute implements commands.Command.

type TimeSyncCommandResult

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

TimeSyncCommandResult is the result of the time synchronization command.

func (*TimeSyncCommandResult) AnswerEnqueuedEventBuilder

func (r *TimeSyncCommandResult) AnswerEnqueuedEventBuilder() events.Builder

AnswerEnqueuedEventBuilder implements commands.Command.

func (*TimeSyncCommandResult) MarshalBinary

func (r *TimeSyncCommandResult) MarshalBinary() ([]byte, error)

MarshalBinary implements Result.

Jump to

Keyboard shortcuts

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