band

package
v0.0.0-...-78d1355 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	LoRaWAN_1_0_0 = "1.0.0"
	LoRaWAN_1_0_1 = "1.0.1"
	LoRaWAN_1_0_2 = "1.0.2"
	LoRaWAN_1_0_3 = "1.0.3"
	LoRaWAN_1_1_0 = "1.1.0"
)

Available protocol versions.

View Source
const (
	RegParamRevA = "A"
	RegParamRevB = "B"
	RegParamRevC = "C"
)

Regional parameters revisions.

Variables

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

errors

Functions

This section is empty.

Types

type Band

type Band interface {
	// Name returns the name of the band.
	Name() string

	// GetDataRateIndex returns the index for the given data-rate parameters.
	GetDataRateIndex(uplink bool, dataRate DataRate) (int, error)

	// GetDataRate returns the data-rate for the given index.
	GetDataRate(dr int) (DataRate, error)

	// GetMaxPayloadSizeForDataRateIndex returns the max-payload size for the
	// given data-rate index, protocol version and regional-parameters revision.
	// The protocol-version and regional-parameters revision must be given
	// to make sure the maximum payload size is not exceeded when communicating
	// with a device implementing a less recent revision (which could cause
	// the device to reject the payload).
	// When the version or revision is unknown, it will return the most recent
	// implemented revision values.
	GetMaxPayloadSizeForDataRateIndex(protocolVersion, regParamRevision string, dr int) (MaxPayloadSize, error)

	// GetRX1DataRateIndex returns the RX1 data-rate given the uplink data-rate
	// and RX1 data-rate offset.
	GetRX1DataRateIndex(uplinkDR, rx1DROffset int) (int, error)

	// GetTXPowerOffset returns the TX Power offset for the given offset
	// index.
	GetTXPowerOffset(txPower int) (int, error)

	// AddChannel adds an extra (user-configured) uplink / downlink channel.
	// Note: this is not supported by every region.
	AddChannel(frequency, minDR, maxDR int) error

	// GetUplinkChannel returns the uplink channel for the given index.
	GetUplinkChannel(channel int) (Channel, error)

	// GetUplinkChannelIndex returns the uplink channel index given a frequency.
	// As it is possible that the same frequency occurs twice (eg. one time as
	// a default LoRaWAN channel and one time as a custom channel using a 250 kHz
	// data-rate), a bool must be given indicating this is a default channel.
	GetUplinkChannelIndex(frequency int, defaultChannel bool) (int, error)

	// GetDownlinkChannel returns the downlink channel for the given index.
	GetDownlinkChannel(channel int) (Channel, error)

	// DisableUplinkChannelIndex disables the given uplink channel index.
	DisableUplinkChannelIndex(channel int) error

	// EnableUplinkChannelIndex enables the given uplink channel index.
	EnableUplinkChannelIndex(channel int) error

	// GetUplinkChannelIndices returns all available uplink channel indices.
	GetUplinkChannelIndices() []int

	// GetStandardUplinkChannelIndices returns all standard available uplink
	// channel indices.
	GetStandardUplinkChannelIndices() []int

	// GetCustomUplinkChannelIndices returns all custom uplink channels.
	GetCustomUplinkChannelIndices() []int

	// GetEnabledUplinkChannelIndices returns the enabled uplink channel indices.
	GetEnabledUplinkChannelIndices() []int

	// GetDisabledUplinkChannelIndices returns the disabled uplink channel indices.
	GetDisabledUplinkChannelIndices() []int

	// GetRX1ChannelIndexForUplinkChannelIndex returns the channel to use for RX1
	// given the uplink channel index.
	GetRX1ChannelIndexForUplinkChannelIndex(uplinkChannel int) (int, error)

	// GetRX1FrequencyForUplinkFrequency returns the frequency to use for RX1
	// given the uplink frequency.
	GetRX1FrequencyForUplinkFrequency(uplinkFrequency int) (int, error)

	// GetPingSlotFrequency returns the frequency to use for the Class-B ping-slot.
	GetPingSlotFrequency(devAddr lorawan.DevAddr, beaconTime time.Duration) (int, error)

	// GetCFList returns the CFList used for OTAA activation.
	// The CFList contains the extra channels (e.g. for the EU band) or the
	// channel-mask for LoRaWAN 1.1+ devices (e.g. for the US band).
	// In case of extra channels, only the first 5 extra channels with DR 0-5
	// are returned. Other channels must be set using mac-commands. When there
	// are no extra channels, this method returns nil.
	GetCFList(protocolVersion string) *lorawan.CFList

	// GetLinkADRReqPayloadsForEnabledUplinkChannelIndices returns the LinkADRReqPayloads to
	// reconfigure the device to the current enabled channels. Note that in case of
	// activation, user-defined channels (e.g. CFList) will be ignored as it
	// is unknown if the device is aware of these extra frequencies.
	GetLinkADRReqPayloadsForEnabledUplinkChannelIndices(deviceEnabledChannels []int) []lorawan.LinkADRReqPayload

	// GetEnabledUplinkChannelIndicesForLinkADRReqPayloads returns the enabled uplink channel
	// indices after applying the given LinkADRReqPayloads to the given enabled device
	// channels.
	GetEnabledUplinkChannelIndicesForLinkADRReqPayloads(deviceEnabledChannels []int, pls []lorawan.LinkADRReqPayload) ([]int, error)

	// GetDownlinkTXPower returns the TX power for downlink transmissions
	// using the given frequency. Depending the band, it could return different
	// values for different frequencies.
	GetDownlinkTXPower(frequency int) int

	// GetDefaults returns the band defaults.
	GetDefaults() Defaults
}

Band defines the interface of a LoRaWAN band object.

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.

type Channel

type Channel struct {
	Frequency int // frequency in Hz
	MinDR     int
	MaxDR     int
	// 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
	// contains filtered or unexported fields
}

DataRate defines a data rate

type Defaults

type Defaults struct {
	// 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

	// 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
}

Defaults defines the default values defined by a band.

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"
	US_902_928 Name = "US_902_928"
	RU_864_870 Name = "RU_864_870"
)

Available ISM bands (deprecated, use the common name).

const (
	EU868 Name = "EU868"
	US915 Name = "US915"
	CN779 Name = "CN779"
	EU433 Name = "EU433"
	AU915 Name = "AU915"
	CN470 Name = "CN470"
	AS923 Name = "AS923"
	KR920 Name = "KR920"
	IN865 Name = "IN865"
	RU864 Name = "RU864"
)

Available ISM bands (by common name).

Jump to

Keyboard shortcuts

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