frequencyplan

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

View Source
var Bands = []string{"2.4", "5", "6"}

Bands are the bands we draw an overview for, in display order.

Functions

func BandFrequencyRange

func BandFrequencyRange(band string) (min, max int, ok bool)

BandFrequencyRange returns the inclusive MHz range for a band; ok is false for an unknown band.

func FrequencyToBand

func FrequencyToBand(frequency int) string

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

func FrequencyToChannel(freqMHz int) (int, bool)

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

func HtmodeWidth(htmode string) (int, bool)

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

func WidthForbidden(width int, flags []string) bool

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

type BondingGroup struct {
	Frequencies []int
	StartIndex  int
	Span        int
	Complete    bool
}

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

type Channel struct {
	Number    int
	Frequency int
}

Channel is a single 20 MHz channel in a band's standard plan.

func StandardChannels

func StandardChannels(band string) []Channel

StandardChannels returns the standard 20 MHz channel plan for a band in column order, or nil for an unknown band.

type DeviceRef

type DeviceRef struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

DeviceRef identifies a device for display and for linking to its radios.

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

type HtModes struct {
	Device string
	Radio  int
	Modes  []string
}

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.

type Radio

type Radio struct {
	Device    string
	Frequency int
	Htmode    string
}

Radio is a configured radio (already filtered to the requested scope).

type Tier

type Tier struct {
	Width  int     `json:"width"`
	Groups []Block `json:"groups"`
}

Tier is one channel-width row within a band.

Jump to

Keyboard shortcuts

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