fragmentation

package
v0.0.0-...-559f553 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fragmentation implements the Fragmented Data Block Transport v1.0.0 over LoRaWAN.

Index

Constants

View Source
const DefaultFPort uint8 = 201

DefaultFPort defines the default fPort value for Fragmented Data Block Transport.

Variables

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

Errors

Functions

func Encode

func Encode(data []byte, fragmentSize, redundancy int) ([][]byte, error)

Encode encodes the given slice of bytes to fragments including forward error correction. This is based on the proposed FEC code from the Fragmented Data Block Transport over LoRaWAN recommendation.

Types

type CID

type CID byte

CID defines the command identifier.

const (
	PackageVersionReq    CID = 0x00
	PackageVersionAns    CID = 0x00
	FragSessionStatusReq CID = 0x01
	FragSessionStatusAns CID = 0x01
	FragSessionSetupReq  CID = 0x02
	FragSessionSetupAns  CID = 0x02
	FragSessionDeleteReq CID = 0x03
	FragSessionDeleteAns CID = 0x03
	DataFragment         CID = 0x08
)

Available command identifier.

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 DataFragmentPayload

type DataFragmentPayload struct {
	IndexAndN DataFragmentPayloadIndexAndN
	Payload   []byte
}

DataFragmentPayload implements the DataFragment payload.

func (DataFragmentPayload) MarshalBinary

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

MarshalBinary encodes the given payload to a slice of bytes.

func (DataFragmentPayload) Size

func (p DataFragmentPayload) Size() int

Size returns the payload size in bytes.

func (*DataFragmentPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type DataFragmentPayloadIndexAndN

type DataFragmentPayloadIndexAndN struct {
	FragIndex uint8
	N         uint16
}

DataFragmentPayloadIndexAndN implements the DataFragment payload IndexAndN field.

type FragSessionDeleteAnsPayload

type FragSessionDeleteAnsPayload struct {
	Status FragSessionDeleteAnsPayloadStatus
}

FragSessionDeleteAnsPayload implements the FragSessionDeleteAns payload.

func (FragSessionDeleteAnsPayload) MarshalBinary

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

MarshalBinary encodes the payload to a slice of bytes.

func (FragSessionDeleteAnsPayload) Size

Size returns the size of the payload in bytes.

func (*FragSessionDeleteAnsPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type FragSessionDeleteAnsPayloadStatus

type FragSessionDeleteAnsPayloadStatus struct {
	FragIndex           uint8
	SessionDoesNotExist bool
}

FragSessionDeleteAnsPayloadStatus implements the FragSessionDeleteAns payload Status field.

type FragSessionDeleteReqPayload

type FragSessionDeleteReqPayload struct {
	Param FragSessionDeleteReqPayloadParam
}

FragSessionDeleteReqPayload implements the FragSessionDeleteReq paylaod.

func (FragSessionDeleteReqPayload) MarshalBinary

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

MarshalBinary encodes the payload to a slice of bytes.

func (FragSessionDeleteReqPayload) Size

Size returns the payload size in bytes.

func (*FragSessionDeleteReqPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type FragSessionDeleteReqPayloadParam

type FragSessionDeleteReqPayloadParam struct {
	FragIndex uint8
}

FragSessionDeleteReqPayloadParam implements the FragSessionDeleteReq payload Param field.

type FragSessionSetupAnsPayload

type FragSessionSetupAnsPayload struct {
	StatusBitMask FragSessionSetupAnsPayloadStatusBitMask
}

FragSessionSetupAnsPayload implements the FragSessionSetupAns payload.

func (FragSessionSetupAnsPayload) MarshalBinary

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

MarshalBinary encodes the payload to a slice of bytes.

func (FragSessionSetupAnsPayload) Size

Size returns the paylaod size in bytes.

func (*FragSessionSetupAnsPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type FragSessionSetupAnsPayloadStatusBitMask

type FragSessionSetupAnsPayloadStatusBitMask struct {
	FragIndex                    uint8
	WrongDescriptor              bool
	FragSessionIndexNotSupported bool
	NotEnoughMemory              bool
	EncodingUnsupported          bool
}

FragSessionSetupAnsPayloadStatusBitMask implements the FragSessionSetupAns payload StatusBitMask field.

type FragSessionSetupReqPayload

type FragSessionSetupReqPayload struct {
	FragSession FragSessionSetupReqPayloadFragSession
	NbFrag      uint16
	FragSize    uint8
	Control     FragSessionSetupReqPayloadControl
	Padding     uint8
	Descriptor  [4]byte
}

FragSessionSetupReqPayload implements the FragSessionSetupReq payload.

func (FragSessionSetupReqPayload) MarshalBinary

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

MarshalBinary encodes the payload to a slice of bytes.

func (FragSessionSetupReqPayload) Size

Size returns the payload size in number of bytes.

func (*FragSessionSetupReqPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type FragSessionSetupReqPayloadControl

type FragSessionSetupReqPayloadControl struct {
	FragmentationMatrix uint8
	BlockAckDelay       uint8
}

FragSessionSetupReqPayloadControl implements the FragSessionSetupReq payload Control field.

type FragSessionSetupReqPayloadFragSession

type FragSessionSetupReqPayloadFragSession struct {
	FragIndex      uint8
	McGroupBitMask [4]bool
}

FragSessionSetupReqPayloadFragSession implements the FragSessionSetupReq payload FragSession field.

type FragSessionStatusAnsPayload

type FragSessionStatusAnsPayload struct {
	ReceivedAndIndex FragSessionStatusAnsPayloadReceivedAndIndex
	MissingFrag      uint8
	Status           FragSessionStatusAnsPayloadStatus
}

FragSessionStatusAnsPayload implements the FragSessionStatusAns payload.

func (FragSessionStatusAnsPayload) MarshalBinary

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

MarshalBinary encodes the payload to a slice of bytes.

func (FragSessionStatusAnsPayload) Size

Size returns the payload size in number of bytes.

func (*FragSessionStatusAnsPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type FragSessionStatusAnsPayloadReceivedAndIndex

type FragSessionStatusAnsPayloadReceivedAndIndex struct {
	FragIndex      uint8
	NbFragReceived uint16
}

FragSessionStatusAnsPayloadReceivedAndIndex implements the FragSessionStatusAns payload ReceivedAndIndex field.

type FragSessionStatusAnsPayloadStatus

type FragSessionStatusAnsPayloadStatus struct {
	NotEnoughMatrixMemory bool
}

FragSessionStatusAnsPayloadStatus implements the FragSessionStatusAns payload Status field.

type FragSessionStatusReqPayload

type FragSessionStatusReqPayload struct {
	FragStatusReqParam FragSessionStatusReqPayloadFragStatusReqParam
}

FragSessionStatusReqPayload implements the FragSessionStatusReq payload.

func (FragSessionStatusReqPayload) MarshalBinary

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

MarshalBinary encodes the payload to a slice of bytes.

func (FragSessionStatusReqPayload) Size

Size returns the payload size in number of bytes.

func (*FragSessionStatusReqPayload) UnmarshalBinary

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

UnmarshalBinary decodes the payload from a slice of bytes.

type FragSessionStatusReqPayloadFragStatusReqParam

type FragSessionStatusReqPayloadFragStatusReqParam struct {
	FragIndex    uint8
	Participants bool
}

FragSessionStatusReqPayloadFragStatusReqParam implements the FragSessionStatusReq payload FragStatusReqParam 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 number of 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