MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Validate

Method Validate

pkg/frequencyplans/frequencyplans.go:425–446  ·  view source on GitHub ↗

Validate returns an error if the frequency plan is invalid.

()

Source from the content-addressed store, hash-verified

423
424// Validate returns an error if the frequency plan is invalid.
425func (fp FrequencyPlan) Validate() error {
426 _, err := band.GetLatest(fp.BandID)
427 if err != nil {
428 return err
429 }
430 fpdt := fp.DwellTime
431 if (fpdt.GetUplinks() || fpdt.GetDownlinks()) && fpdt.Duration == nil {
432 return errNoDwellTimeDuration.New()
433 }
434 for _, channels := range [][]Channel{fp.UplinkChannels, fp.DownlinkChannels} {
435 for i, channel := range channels {
436 chdt := channel.DwellTime
437 if chdt == nil || chdt.Enabled == nil {
438 continue
439 }
440 if *chdt.Enabled && fpdt.Duration == nil && chdt.Duration == nil {
441 return errInvalidChannel.WithAttributes("index", i).WithCause(errNoDwellTimeDuration)
442 }
443 }
444 }
445 return nil
446}
447
448// RespectsDwellTime returns whether the transmission respects the frequency plan's dwell time restrictions.
449func (fp *FrequencyPlan) RespectsDwellTime(isDownlink bool, frequency uint64, duration time.Duration) bool {

Callers

nothing calls this directly

Calls 6

GetLatestFunction · 0.92
NewMethod · 0.65
GetUplinksMethod · 0.45
GetDownlinksMethod · 0.45
WithCauseMethod · 0.45
WithAttributesMethod · 0.45

Tested by

no test coverage detected