Documentation
¶
Overview ¶
Package frequencyplan contains the pure Wi-Fi channel/band math and the channel-bonding overview generation used by the dashboard's "Frequency Overview" card. It has no PocketBase (or any other I/O) dependency so it can be unit-tested in isolation; the HTTP handler in package main feeds it plain structs.
Index ¶
- Variables
- func BandFrequencyRange(band string) (min, max int, ok bool)
- func FrequencyToBand(frequency int) string
- func FrequencyToChannel(freqMHz int) (int, bool)
- func HtmodeWidth(htmode string) (int, bool)
- func WidthForbidden(width int, flags []string) bool
- type BandOverview
- type Block
- type BondingGroup
- type Channel
- type DeviceRef
- type Frequency
- type HtModes
- type Radio
- type Tier
Constants ¶
This section is empty.
Variables ¶
var BandLabels = map[string]string{
"2.4": "2.4 GHz",
"5": "5 GHz",
"6": "6 GHz",
"60": "60 GHz",
}
BandLabels maps a band key to its human label.
var BandWidths = map[string][]int{
"2.4": {20, 40},
"5": {20, 40, 80, 160},
"6": {20, 40, 80, 160, 320},
}
BandWidths lists the channel widths (MHz) drawn per band. 2.4 GHz only supports 20/40 MHz; 5/6 GHz support the wider bonded widths.
var Bands = []string{"2.4", "5", "6"}
Bands are the bands we draw an overview for, in display order.
Functions ¶
func BandFrequencyRange ¶
BandFrequencyRange returns the inclusive MHz range for a band; ok is false for an unknown band.
func FrequencyToBand ¶
FrequencyToBand maps a frequency in MHz to a band string. Ported verbatim from opensoho.go so it remains the single source of truth.
func FrequencyToChannel ¶
FrequencyToChannel maps a frequency in MHz to a channel number. The bool is false when the frequency is outside the known ranges. Ported verbatim from opensoho.go (incl. 60 GHz handling).
func HtmodeWidth ¶
HtmodeWidth returns the channel width (MHz) for an htmode such as "HT20", "VHT40", "HE160". A blank htmode is treated as 20 MHz, the conservative Wi-Fi default. The bool is false for an unrecognised value.
func WidthForbidden ¶
WidthForbidden reports whether the radio_frequencies flags forbid the given channel width. Mirrors validateRadioHtModeFlags in opensoho.go.
Types ¶
type BandOverview ¶
type BandOverview struct {
Band string `json:"band"`
Label string `json:"label"`
Cols int `json:"cols"`
FreqMin int `json:"freqMin"` // inclusive band frequency bounds (MHz), for filtering
FreqMax int `json:"freqMax"`
Tiers []Tier `json:"tiers"`
}
BandOverview is the rendered model for a single band.
func BuildOverview ¶
func BuildOverview(radios []Radio, freqs []Frequency, htModes []HtModes, deviceNames map[string]string) []BandOverview
BuildOverview turns the in-scope radios and advertised frequencies into the per-band channel-bonding model the dashboard renders. It is a pure function: scope filtering happens in the caller. Output ordering is deterministic.
type Block ¶
type Block struct {
StartIndex int `json:"startIndex"`
Span int `json:"span"`
State string `json:"state"` // "used" | "available" | "invalid"
Label string `json:"label"`
Channels []int `json:"channels"`
Frequencies []int `json:"frequencies"`
Devices []DeviceRef `json:"devices"` // devices that have this mode configured (in use)
SupportedBy []DeviceRef `json:"supportedBy"` // devices whose capabilities support this mode
UnsupportedBy []DeviceRef `json:"unsupportedBy"` // known-capability devices that don't support it
}
Block is one rendered block in a width tier.
type BondingGroup ¶
BondingGroup is one block in a width tier: the contiguous channels it bonds, the column index of its first channel and its column span.
func BondingGroups ¶
func BondingGroups(band string, width int) []BondingGroup
BondingGroups returns the channel-bonding groups for a band at a given width, in column order. For 5/6 GHz, channels are grouped within frequency-contiguous runs (consecutive plan entries 20 MHz apart) into chunks of width/20; this prevents bonding across band gaps (e.g. the 5 GHz 64->100 jump and the 144->149 boundary). For 2.4 GHz, whose channels overlap at 5 MHz spacing, groups are consecutive adjacent-channel chunks (an accepted approximation). A trailing chunk shorter than width/20 has Complete == false.
type Channel ¶
Channel is a single 20 MHz channel in a band's standard plan.
func StandardChannels ¶
StandardChannels returns the standard 20 MHz channel plan for a band in column order, or nil for an unknown band.
type Frequency ¶
type Frequency struct {
Device string
Radio int // per-device radio index, matches HtModes.Radio
Frequency int
Flags []string
}
Frequency is a hardware-advertised frequency row (already scope-filtered).
type HtModes ¶ added in v0.15.0
HtModes lists the channel modes one radio advertises (iwinfo's htmodes), already scope-filtered. A device with no entry for a radio has unknown capabilities for that radio and is not constrained by it.