clocksync

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package clocksync implements the Application Layer Clock Synchronization v1.0.0 over LoRaWAN.

Index

Constants

View Source
const DefaultFPort uint8 = 202

DefaultFPort defines the default fPort value for Clock Synnchronization.

Variables

View Source
var (
	ErrNoPayloadForCID = errors.New("lorawan/applayer/clocksync: no payload for given CID")
)

Errors

Functions

This section is empty.

Types

type AppTimeAnsPayload

type AppTimeAnsPayload struct {
	TimeCorrection int32
	Param          AppTimeAnsPayloadParam
}

AppTimeAnsPayload implements the AppTimeAns payload.

func (AppTimeAnsPayload) MarshalBinary

func (p AppTimeAnsPayload) MarshalBinary() ([]byte, error)

MarshalBinary encodes the payload to a slice of bytes.

func (*AppTimeAnsPayload) Size

func (p *AppTimeAnsPayload) Size() int

Size returns the payload size in bytes.

func (*AppTimeAnsPayload) UnmarshalBinary

func (p *AppTimeAnsPayload) UnmarshalBinary(data []byte) error

UnmarshalBinary decoces the payload from a slice of bytes.

type AppTimeAnsPayloadParam

type AppTimeAnsPayloadParam struct {
	TokenAns uint8
}

AppTimeAnsPayloadParam implements the AppTimeAns payload Param field.

type AppTimeReqPayload

type AppTimeReqPayload struct {
	DeviceTime uint32
	Param      AppTimeReqPayloadParam
}

AppTimeReqPayload implements the AppTimeReq payload.

func (AppTimeReqPayload) MarshalBinary

func (p AppTimeReqPayload) MarshalBinary() ([]byte, error)

MarshalBinary encodes the payload to a slice of bytes.

func (AppTimeReqPayload) Size

func (p AppTimeReqPayload) Size() int

Size returns the payload size in bytes.

func (*AppTimeReqPayload) UnmarshalBinary

func (p *AppTimeReqPayload) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the payload from a slice of bytes.

type AppTimeReqPayloadParam

type AppTimeReqPayloadParam struct {
	AnsRequired bool
	TokenReq    uint8
}

AppTimeReqPayloadParam implements the AppTimeReq Param field.

type CID

type CID byte

CID defines the command identifier.

const (
	PackageVersionReq           CID = 0x00
	PackageVersionAns           CID = 0x00
	AppTimeReq                  CID = 0x01
	AppTimeAns                  CID = 0x01
	DeviceAppTimePeriodicityReq CID = 0x02
	DeviceAppTimePeriodicityAns CID = 0x02
	ForceDeviceResyncReq        CID = 0x03
)

Available command identifiers.

func (CID) String

func (i CID) String() string

type Command

type Command struct {
	CID     CID
	Payload CommandPayload
}

Command defines the Command structure.

func (Command) MarshalBinary

func (c Command) MarshalBinary() ([]byte, error)

MarshalBinary encodes the command to a slice of bytes.

func (Command) Size

func (c Command) Size() int

Size returns the size of the command in bytes.

func (*Command) UnmarshalBinary

func (c *Command) UnmarshalBinary(uplink bool, data []byte) error

UnmarshalBinary decodes a slice of bytes into a command.

type CommandPayload

type CommandPayload interface {
	MarshalBinary() (data []byte, err error)
	UnmarshalBinary(data []byte) error
	Size() int
}

CommandPayload defines the interface that a command payload must implement.

func GetCommandPayload

func GetCommandPayload(uplink bool, c CID) (CommandPayload, error)

GetCommandPayload returns a new CommandPayload for the given CID.

type Commands

type Commands []Command

Commands defines a slice of commands.

func (Commands) MarshalBinary

func (c Commands) MarshalBinary() ([]byte, error)

MarshalBinary encodes the commands to a slice of bytes.

func (*Commands) UnmarshalBinary

func (c *Commands) UnmarshalBinary(uplink bool, data []byte) error

UnmarshalBinary decodes a slice of bytes into a slice of commands.

type DeviceAppTimePeriodicityAnsPayload

type DeviceAppTimePeriodicityAnsPayload struct {
	Status DeviceAppTimePeriodicityAnsPayloadStatus
	Time   uint32
}

DeviceAppTimePeriodicityAnsPayload implements the DeviceAppTimePeriodicityAns payload.

func (DeviceAppTimePeriodicityAnsPayload) MarshalBinary

func (p DeviceAppTimePeriodicityAnsPayload) MarshalBinary() ([]byte, error)

MarshalBinary encodes the payload to a slice of bytes.

func (DeviceAppTimePeriodicityAnsPayload) Size

Size returns the payload size in bytes.

func (*DeviceAppTimePeriodicityAnsPayload) UnmarshalBinary

func (p *DeviceAppTimePeriodicityAnsPayload) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the payload from a slice of bytes.

type DeviceAppTimePeriodicityAnsPayloadStatus

type DeviceAppTimePeriodicityAnsPayloadStatus struct {
	NotSupported bool
}

DeviceAppTimePeriodicityAnsPayloadStatus implements the DeviceAppTimePeriodicityAns status field.

type DeviceAppTimePeriodicityReqPayload

type DeviceAppTimePeriodicityReqPayload struct {
	Periodicity DeviceAppTimePeriodicityReqPayloadPeriodicity
}

DeviceAppTimePeriodicityReqPayload implements the DeviceAppTimePeriodicityReq payload.

func (DeviceAppTimePeriodicityReqPayload) MarshalBinary

func (p DeviceAppTimePeriodicityReqPayload) MarshalBinary() ([]byte, error)

MarshalBinary encodes the payload to a slice of bytes.

func (DeviceAppTimePeriodicityReqPayload) Size

Size returns the payload size in bytes.

func (*DeviceAppTimePeriodicityReqPayload) UnmarshalBinary

func (p *DeviceAppTimePeriodicityReqPayload) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the payload from a slice of bytes.

type DeviceAppTimePeriodicityReqPayloadPeriodicity

type DeviceAppTimePeriodicityReqPayloadPeriodicity struct {
	Period uint8
}

DeviceAppTimePeriodicityReqPayloadPeriodicity implements the DeviceAppTimePeriodicityReq payload Periodicity field.

type ForceDeviceResyncReqPayload

type ForceDeviceResyncReqPayload struct {
	ForceConf ForceDeviceResyncReqPayloadForceConf
}

ForceDeviceResyncReqPayload implements the ForceDeviceResyncReq payload.

func (ForceDeviceResyncReqPayload) MarshalBinary

func (p ForceDeviceResyncReqPayload) MarshalBinary() ([]byte, error)

MarshalBinary encodes the payload to a slice of bytes.

func (ForceDeviceResyncReqPayload) Size

Size returns the payload size in bytes.

func (*ForceDeviceResyncReqPayload) UnmarshalBinary

func (p *ForceDeviceResyncReqPayload) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the payload from a slice of bytes.

type ForceDeviceResyncReqPayloadForceConf

type ForceDeviceResyncReqPayloadForceConf struct {
	NbTransmissions uint8
}

ForceDeviceResyncReqPayloadForceConf implements the ForceDeviceResyncReq payload ForceConf field.

type PackageVersionAnsPayload

type PackageVersionAnsPayload struct {
	PackageIdentifier uint8
	PackageVersion    uint8
}

PackageVersionAnsPayload implements the PackageVersionAns payload.

func (PackageVersionAnsPayload) MarshalBinary

func (p PackageVersionAnsPayload) MarshalBinary() ([]byte, error)

MarshalBinary encodes the payload to a slice of bytes.

func (*PackageVersionAnsPayload) Size

func (p *PackageVersionAnsPayload) Size() int

Size returns the payload size in bytes.

func (*PackageVersionAnsPayload) UnmarshalBinary

func (p *PackageVersionAnsPayload) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the payload from a slice of bytes.

Jump to

Keyboard shortcuts

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