Documentation ¶
Overview ¶
Package frequencyplans contains abstractions to fetch and manipulate frequency plans.
Example ¶
package main import ( "fmt" "go.thethings.network/lorawan-stack/v3/pkg/fetch" "go.thethings.network/lorawan-stack/v3/pkg/frequencyplans" ) func main() { fetcher, err := fetch.FromHTTP("https://raw.githubusercontent.com/TheThingsNetwork/lorawan-frequency-plans", true) 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 ¶
- func CFList(fp FrequencyPlan, version ttnpb.PHYVersion) *ttnpb.CFList
- func FallbackIDFromContext(ctx context.Context) (string, bool)
- func WithFallbackID(ctx context.Context, id string) context.Context
- type Channel
- type ChannelDwellTime
- type DwellTime
- type FSKChannel
- type FrequencyPlan
- func (fp FrequencyPlan) Extend(ext FrequencyPlan) FrequencyPlan
- func (fp *FrequencyPlan) FindSubBand(frequency uint64) (SubBandParameters, bool)
- func (fp *FrequencyPlan) RespectsDwellTime(isDownlink bool, frequency uint64, duration time.Duration) bool
- func (fp *FrequencyPlan) ToConcentratorConfig() (*ttnpb.ConcentratorConfig, error)
- func (fp FrequencyPlan) Validate() error
- type FrequencyPlanDescription
- type LBT
- type LoRaStandardChannel
- type RPCServer
- type Radio
- type RadioTxConfiguration
- type Store
- type SubBandParameters
- type TimeOffAir
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 ¶
FallbackIDFromContext returns the fallback frequency plan ID and whether it's set using WithFallbackID.
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) 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) GetDownlinks ¶
GetDownlinks returns whether the dwell time is applicable to downlinks.
func (*DwellTime) GetUplinks ¶
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(ext 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) 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 ¶
func (lsc *LoRaStandardChannel) Clone() *LoRaStandardChannel
Clone returns a cloned LoRaStandardChannel.
func (*LoRaStandardChannel) ToConcentratorConfig ¶
func (lsc *LoRaStandardChannel) ToConcentratorConfig(phy band.Band) (*ttnpb.ConcentratorConfig_LoRaStandardChannel, error)
ToConcentratorConfig returns the LoRa standard channel configuration in the protobuf format.
type RPCServer ¶
type RPCServer struct {
// contains filtered or unexported fields
}
func NewRPCServer ¶
func (*RPCServer) ListFrequencyPlans ¶
func (s *RPCServer) ListFrequencyPlans(ctx context.Context, req *ttnpb.ListFrequencyPlansRequest) (*ttnpb.ListFrequencyPlansResponse, error)
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) 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 ¶
func (txc *RadioTxConfiguration) Clone() *RadioTxConfiguration
Clone returns a cloned RadioTxConfiguration.
type Store ¶
Store contains frequency plans.
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.