frequencyplans

package
v3.21.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package frequencyplans contains abstractions to fetch and manipulate frequency plans.

Example
package main

import (
	"fmt"
	"net/http"

	"go.thethings.network/lorawan-stack/v3/pkg/fetch"
	"go.thethings.network/lorawan-stack/v3/pkg/frequencyplans"
)

func main() {
	fetcher, err := fetch.FromHTTP(http.DefaultClient, "https://raw.githubusercontent.com/TheThingsNetwork/lorawan-frequency-plans")
	if err != nil {
		panic(err)
	}
	store := frequencyplans.NewStore(fetcher)

	ids, err := store.GetAllIDs()
	if err != nil {
		panic(err)
	}

	fmt.Println("Frequency plans available:")
	for _, id := range ids {
		fmt.Println("-", id)
	}

	euFP, err := store.GetByID("EU_863_870")
	if err != nil {
		panic(err)
	}

	fmt.Println("Content of the EU frequency plan:")
	fmt.Println(euFP)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CFList

func CFList(fp *FrequencyPlan, version ttnpb.PHYVersion) *ttnpb.CFList

CFList generated by this frequency plan, for the version used by a device. This function returns nil if the CFList could not be computed, or if the device does not support CFLists.

func FallbackIDFromContext

func FallbackIDFromContext(ctx context.Context) (string, bool)

FallbackIDFromContext returns the fallback frequency plan ID and whether it's set using WithFallbackID.

func WithFallbackID

func WithFallbackID(ctx context.Context, id string) context.Context

WithFallbackID returns a derived context with the given frequency plan ID to be used as fallback.

Types

type Channel

type Channel struct {
	Frequency   uint64            `yaml:"frequency"`
	DwellTime   *ChannelDwellTime `yaml:"dwell-time,omitempty"`
	Radio       uint8             `yaml:"radio"`
	MinDataRate uint8             `yaml:"min-data-rate"`
	MaxDataRate uint8             `yaml:"max-data-rate"`
}

Channel contains the configuration of a channel.

func (*Channel) Clone

func (c *Channel) Clone() *Channel

Clone returns a cloned Channel.

func (*Channel) ToConcentratorConfig

func (c *Channel) ToConcentratorConfig() *ttnpb.ConcentratorConfig_Channel

ToConcentratorConfig returns the channel configuration in the protobuf format.

type ChannelDwellTime

type ChannelDwellTime struct {
	Enabled  *bool          `yaml:"enabled,omitempty"`
	Duration *time.Duration `yaml:"duration,omitempty"`
}

ChannelDwellTime contains dwell time settings for a channel.

func (*ChannelDwellTime) Clone

func (dt *ChannelDwellTime) Clone() *ChannelDwellTime

Clone returns a cloned ChannelDwellTime.

func (*ChannelDwellTime) GetEnabled

func (dt *ChannelDwellTime) GetEnabled() bool

GetEnabled returns whether dwell time is enabled.

type DwellTime

type DwellTime struct {
	Uplinks   *bool          `yaml:"uplinks,omitempty"`
	Downlinks *bool          `yaml:"downlinks,omitempty"`
	Duration  *time.Duration `yaml:"duration,omitempty"`
}

DwellTime contains dwell time settings.

func (*DwellTime) Clone

func (dt *DwellTime) Clone() *DwellTime

Clone returns a cloned DwellTime.

func (dt *DwellTime) GetDownlinks() bool

GetDownlinks returns whether the dwell time is applicable to downlinks.

func (dt *DwellTime) GetUplinks() bool

GetUplinks returns whether the dwell time is applicable to uplinks.

type FSKChannel

type FSKChannel struct {
	Frequency uint64            `yaml:"frequency"`
	DwellTime *ChannelDwellTime `yaml:"dwell-time,omitempty"`
	Radio     uint8             `yaml:"radio"`
	DataRate  uint8             `yaml:"data-rate"`
}

FSKChannel contains the configuration of an FSK channel.

func (*FSKChannel) Clone

func (fskc *FSKChannel) Clone() *FSKChannel

Clone returns a cloned FSKChannel.

func (*FSKChannel) ToConcentratorConfig

func (fskc *FSKChannel) ToConcentratorConfig() *ttnpb.ConcentratorConfig_FSKChannel

ToConcentratorConfig returns the FSK channel configuration in the protobuf format.

type FrequencyPlan

type FrequencyPlan struct {
	BandID   string              `yaml:"band-id,omitempty"`
	SubBands []SubBandParameters `yaml:"sub-bands,omitempty"`

	UplinkChannels      []Channel            `yaml:"uplink-channels,omitempty"`
	DownlinkChannels    []Channel            `yaml:"downlink-channels,omitempty"`
	LoRaStandardChannel *LoRaStandardChannel `yaml:"lora-standard-channel,omitempty"`
	FSKChannel          *FSKChannel          `yaml:"fsk-channel,omitempty"`

	TimeOffAir TimeOffAir `yaml:"time-off-air,omitempty"`
	DwellTime  DwellTime  `yaml:"dwell-time,omitempty"`
	LBT        *LBT       `yaml:"listen-before-talk,omitempty"`

	Radios      []Radio `yaml:"radios,omitempty"`
	ClockSource uint8   `yaml:"clock-source,omitempty"`

	// PingSlot overrides the default band settings for the class B ping slot.
	PingSlot                *Channel `yaml:"ping-slot,omitempty"`
	DefaultPingSlotDataRate *uint8   `yaml:"ping-slot-default-data-rate,omitempty"`
	// Rx2Channel overrides the default band settings for Rx2.
	Rx2Channel         *Channel `yaml:"rx2-channel,omitempty"`
	DefaultRx2DataRate *uint8   `yaml:"rx2-default-data-rate,omitempty"`
	// MaxEIRP is the maximum EIRP as ceiling for any (sub-)band value.
	MaxEIRP *float32 `yaml:"max-eirp,omitempty"`
}

FrequencyPlan contains a frequency plan.

func (FrequencyPlan) Extend

func (fp FrequencyPlan) Extend(extension FrequencyPlan) FrequencyPlan

Extend returns the same frequency plan, with values overridden by the passed frequency plan.

func (*FrequencyPlan) FindSubBand

func (fp *FrequencyPlan) FindSubBand(frequency uint64) (SubBandParameters, bool)

FindSubBand returns the sub-band by frequency, if any.

func (*FrequencyPlan) RespectsDwellTime

func (fp *FrequencyPlan) RespectsDwellTime(isDownlink bool, frequency uint64, duration time.Duration) bool

RespectsDwellTime returns whether the transmission respects the frequency plan's dwell time restrictions.

func (*FrequencyPlan) ToConcentratorConfig

func (fp *FrequencyPlan) ToConcentratorConfig() (*ttnpb.ConcentratorConfig, error)

ToConcentratorConfig returns the frequency plan in the protobuf format.

func (FrequencyPlan) Validate

func (fp FrequencyPlan) Validate() error

Validate returns an error if the frequency plan is invalid.

type FrequencyPlanDescription

type FrequencyPlanDescription struct {
	// ID is the unique identifier of the frequency plan.
	ID string `yaml:"id"`
	// BaseID is the ID of the base frequency plan that this frequency plan extends (optional).
	BaseID string `yaml:"base-id,omitempty"`
	// Name is a human readable name of the frequency plan.
	Name string `yaml:"name"`
	// BaseFrequency is the base frequency of the frequency plan (i.e. 868, 915)
	BaseFrequency uint16 `yaml:"base-frequency"`
	// File is the file where the frequency plan is defined.
	File string `yaml:"file"`
}

FrequencyPlanDescription describes a frequency plan in the YAML format.

type LBT

type LBT struct {
	RSSITarget float32       `yaml:"rssi-target"`
	RSSIOffset float32       `yaml:"rssi-offset,omitempty"`
	ScanTime   time.Duration `yaml:"scan-time"`
}

LBT contains the listen-before-talk requirements for a region.

func (*LBT) Clone

func (lbt *LBT) Clone() *LBT

Clone returns a cloned LBT.

func (*LBT) ToConcentratorConfig

func (lbt *LBT) ToConcentratorConfig() *ttnpb.ConcentratorConfig_LBTConfiguration

ToConcentratorConfig returns the LBT configuration in the protobuf format.

type LoRaStandardChannel

type LoRaStandardChannel struct {
	Frequency uint64            `yaml:"frequency"`
	DwellTime *ChannelDwellTime `yaml:"dwell-time,omitempty"`
	Radio     uint8             `yaml:"radio"`
	DataRate  uint8             `yaml:"data-rate"`
}

LoRaStandardChannel contains the configuration of the LoRa standard channel.

func (*LoRaStandardChannel) Clone

Clone returns a cloned LoRaStandardChannel.

func (*LoRaStandardChannel) ToConcentratorConfig

ToConcentratorConfig returns the LoRa standard channel configuration in the protobuf format.

type RPCServer

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

RPCServer is the RPC server that serves frequency plan information.

func NewRPCServer

func NewRPCServer(store *Store) *RPCServer

NewRPCServer returns a new RPC server that serves frequency plan information.

func (*RPCServer) ListFrequencyPlans

ListFrequencyPlans lists frequency plans for the requested base frequency.

type Radio

type Radio struct {
	Enable          bool                  `yaml:"enable"`
	ChipType        string                `yaml:"chip-type,omitempty"`
	Frequency       uint64                `yaml:"frequency,omitempty"`
	RSSIOffset      float32               `yaml:"rssi-offset,omitempty"`
	TxConfiguration *RadioTxConfiguration `yaml:"tx,omitempty"`
}

Radio contains the gateway configuration of a radio.

func (*Radio) Clone

func (r *Radio) Clone() *Radio

Clone returns a cloned Radio.

func (Radio) ToConcentratorConfig

func (r Radio) ToConcentratorConfig() *ttnpb.GatewayRadio

ToConcentratorConfig returns the radio configuration in the protobuf format.

type RadioTxConfiguration

type RadioTxConfiguration struct {
	MinFrequency   uint64  `yaml:"min-frequency"`
	MaxFrequency   uint64  `yaml:"max-frequency"`
	NotchFrequency *uint64 `yaml:"notch-frequency,omitempty"`
}

RadioTxConfiguration contains the gateway radio transmission configuration.

func (*RadioTxConfiguration) Clone

Clone returns a cloned RadioTxConfiguration.

type Store

type Store struct {
	Fetcher fetch.Interface
	// contains filtered or unexported fields
}

Store contains frequency plans.

func NewStore

func NewStore(fetcher fetch.Interface) *Store

NewStore of frequency plans.

func (*Store) GetAllIDs

func (s *Store) GetAllIDs() ([]string, error)

GetAllIDs returns the list of IDs of the available frequency plans.

func (*Store) GetByID

func (s *Store) GetByID(id string) (*FrequencyPlan, error)

GetByID retrieves the frequency plan that has the given ID.

type SubBandParameters

type SubBandParameters struct {
	MinFrequency uint64 `yaml:"min-frequency,omitempty"`
	MaxFrequency uint64 `yaml:"max-frequency,omitempty"`
	// DutyCycle is a fraction. A value of 0 is interpreted as 1, i.e. no duty-cycle limitation.
	DutyCycle float32  `yaml:"duty-cycle,omitempty"`
	MaxEIRP   *float32 `yaml:"max-eirp,omitempty"`
}

SubBandParameters contains duty-cycle and maximum EIRP overrides for a sub-band.

func (*SubBandParameters) Clone

func (sb *SubBandParameters) Clone() *SubBandParameters

Clone returns a cloned SubBandParameters.

func (SubBandParameters) Comprises

func (sb SubBandParameters) Comprises(frequency uint64) bool

Comprises returns whether the given frequency falls in the sub-band.

type TimeOffAir

type TimeOffAir struct {
	Fraction float32       `yaml:"fraction,omitempty"`
	Duration time.Duration `yaml:"duration,omitempty"`
}

TimeOffAir contains the time-off-air settings.

func (*TimeOffAir) Clone

func (toa *TimeOffAir) Clone() *TimeOffAir

Clone returns a cloned TimeOffAir.

Jump to

Keyboard shortcuts

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