Validate returns an error if the frequency plan is invalid.
()
| 423 | |
| 424 | // Validate returns an error if the frequency plan is invalid. |
| 425 | func (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. |
| 449 | func (fp *FrequencyPlan) RespectsDwellTime(isDownlink bool, frequency uint64, duration time.Duration) bool { |
nothing calls this directly
no test coverage detected