band

package
v0.0.0-...-b905ab3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package band provides band specific defaults and configuration for downlink communication with end-nodes.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelDoesNotExist = errors.New("lorawan/band: channel does not exist")
)

errors

Functions

This section is empty.

Types

type Band

type Band struct {

	// DefaultTXPower defines the default radiated transmit output power
	DefaultTXPower int

	// ImplementsCFlist defines if the band implements the optional channel
	// frequency list.
	ImplementsCFlist bool

	// RX2Frequency defines the fixed frequency for the RX2 receive window
	RX2Frequency int

	// RX2DataRate defines the fixed data-rate for the RX2 receive window
	RX2DataRate int

	// MaxFcntGap defines the MAC_FCNT_GAP default value.
	MaxFCntGap uint32

	// ADRACKLimit defines the ADR_ACK_LIMIT default value.
	ADRACKLimit int

	// ADRACKDelay defines the ADR_ACK_DELAY default value.
	ADRACKDelay int

	// ReceiveDelay1 defines the RECEIVE_DELAY1 default value.
	ReceiveDelay1 time.Duration

	// ReceiveDelay2 defines the RECEIVE_DELAY2 default value.
	ReceiveDelay2 time.Duration

	// JoinAcceptDelay1 defines the JOIN_ACCEPT_DELAY1 default value.
	JoinAcceptDelay1 time.Duration

	// JoinAcceptDelay2 defines the JOIN_ACCEPT_DELAY2 default value.
	JoinAcceptDelay2 time.Duration

	// ACKTimeoutMin defines the ACK_TIMEOUT min. default value.
	ACKTimeoutMin time.Duration

	// ACKTimeoutMax defines the ACK_TIMEOUT max. default value.
	ACKTimeoutMax time.Duration

	// DataRates defines the available data rates.
	DataRates []DataRate

	// MaxPayloadSize defines the maximum payload size, per data-rate.
	MaxPayloadSize []MaxPayloadSize

	// TXPower defines the TX power configuration.
	TXPower []int

	// UplinkChannels defines the list of (default) configured uplink channels.
	UplinkChannels []Channel

	// DownlinkChannels defines the list of (default) configured downlink
	// channels.
	DownlinkChannels []Channel
	// contains filtered or unexported fields
}

Band defines an region specific ISM band implementation for LoRa.

func GetConfig

func GetConfig(name Name, repeaterCompatible bool, dt lorawan.DwellTime) (Band, error)

GetConfig returns the band configuration for the given band. Please refer to the LoRaWAN specification for more details about the effect of the repeater and dwell time arguments.

func (*Band) AddChannel

func (b *Band) AddChannel(freq int) error

AddChannel adds an extra (user-configured) channel to the channels. The DataRates wil be set to DR 0-5. Note: this is only allowed when the band supports a CFList.

func (*Band) DisableUplinkChannel

func (b *Band) DisableUplinkChannel(i int) error

DisableUplinkChannel disables the given uplink channel.

func (*Band) EnableUplinkChannel

func (b *Band) EnableUplinkChannel(i int) error

EnableUplinkChannel enables the given uplink channel.

func (*Band) GetCFList

func (b *Band) GetCFList() *lorawan.CFList

GetCFList returns the CFList used for OTAA activation, or returns nil if the band does not implement the CFList or when there are no extra channels. Note that this only returns the first 5 extra channels.

func (*Band) GetDataRate

func (b *Band) GetDataRate(dr DataRate) (int, error)

GetDataRate returns the index of the given DataRate.

func (*Band) GetDisabledUplinkChannels

func (b *Band) GetDisabledUplinkChannels() []int

GetDisabledUplinkChannels returns the disabled uplink channels.

func (*Band) GetEnabledChannelsForLinkADRReqPayloads

func (b *Band) GetEnabledChannelsForLinkADRReqPayloads(nodeChannels []int, pls []lorawan.LinkADRReqPayload) ([]int, error)

GetEnabledChannelsForLinkADRReqPaylaods returns the enabled after which the given LinkADRReqPayloads have been applied to the given node channels.

func (*Band) GetEnabledUplinkChannels

func (b *Band) GetEnabledUplinkChannels() []int

GetEnabledUplinkChannels returns the enabled uplink channels.

func (*Band) GetLinkADRReqPayloadsForEnabledChannels

func (b *Band) GetLinkADRReqPayloadsForEnabledChannels(nodeChannels []int) []lorawan.LinkADRReqPayload

GetLinkADRReqPayloadsForEnabledChannels returns the LinkADRReqPayloads to reconfigure the node to the current active channels. Note that in case of activation, user-defined channels (e.g. CFList) will be ignored as it is unknown if the node is aware about these extra frequencies.

func (*Band) GetRX1Channel

func (b *Band) GetRX1Channel(txChannel int) int

GetRX1Channel returns the channel to use for RX1 given the channel used for uplink.

func (*Band) GetRX1DataRate

func (b *Band) GetRX1DataRate(uplinkDR, rx1DROffset int) (int, error)

GetRX1DataRate returns the RX1 data-rate given the uplink data-rate and RX1 data-rate offset.

func (*Band) GetRX1Frequency

func (b *Band) GetRX1Frequency(txFrequency int) (int, error)

GetRX1Frequency returns the frequency to use for RX1 given the uplink frequency.

func (*Band) GetUplinkChannelNumber

func (b *Band) GetUplinkChannelNumber(frequency int) (int, error)

GetUplinkChannelNumber returns the channel number given a frequency.

func (*Band) GetUplinkChannels

func (b *Band) GetUplinkChannels() []int

GetUplinkChannels returns all available uplink channels.

type Channel

type Channel struct {
	Frequency int   // frequency in Hz
	DataRates []int // each int mapping to an index in DataRateConfiguration
	// contains filtered or unexported fields
}

Channel defines the channel structure

type DataRate

type DataRate struct {
	Modulation   Modulation `json:"modulation"`
	SpreadFactor int        `json:"spreadFactor,omitempty"` // used for LoRa
	Bandwidth    int        `json:"bandwidth,omitempty"`    // in kHz, used for LoRa
	BitRate      int        `json:"bitRate,omitempty"`      // bits per second, used for FSK
}

DataRate defines a data rate

type MaxPayloadSize

type MaxPayloadSize struct {
	M int // The maximum MACPayload size length
	N int // The maximum application payload length in the absence of the optional FOpt control field
}

MaxPayloadSize defines the max payload size

type Modulation

type Modulation string

Modulation defines the modulation type.

const (
	LoRaModulation Modulation = "LORA"
	FSKModulation  Modulation = "FSK"
)

Possible modulation types.

type Name

type Name string

Name defines the band-name type.

const (
	AS_923     Name = "AS_923"
	AU_915_928 Name = "AU_915_928"
	CN_470_510 Name = "CN_470_510"
	CN_779_787 Name = "CN_779_787"
	EU_433     Name = "EU_433"
	EU_863_870 Name = "EU_863_870"
	IN_865_867 Name = "IN_865_867"
	KR_920_923 Name = "KR_920_923"
	RU_864_870 Name = "RU_864_870"
	US_902_928 Name = "US_902_928"
)

Available ISM bands.

Jump to

Keyboard shortcuts

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