radio

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TriggerFirmwareUpdate added in v0.1.1

func TriggerFirmwareUpdate(firmwarePath string)

TriggerFirmwareUpdate initiates the firmware update process using the given firmware file. This method may not return cleanly even if successful since the update utility will terminate this process.

Types

type AllianceVlans added in v0.1.11

type AllianceVlans string

AllianceVlans represents which three VLANs are used for the teams of an alliance.

const (
	Vlans102030 AllianceVlans = "10_20_30"
	Vlans405060 AllianceVlans = "40_50_60"
	Vlans708090 AllianceVlans = "70_80_90"
)

type ConfigurationRequest

type ConfigurationRequest struct {
	// 5GHz or 6GHz channel number for the radio to use. Set to 0 to leave unchanged.
	Channel int `json:"channel"`

	// Channel bandwidth mode for the radio to use. Valid values are "20MHz" and "40MHz". Set to an empty string to
	// leave unchanged.
	ChannelBandwidth string `json:"channelBandwidth"`

	// VLANs to use for the teams of the red alliance. Valid values are "10_20_30", "40_50_60", and "70_80_90".
	RedVlans AllianceVlans `json:"redVlans"`

	// VLANs to use for the teams of the blue alliance. Valid values are "10_20_30", "40_50_60", and "70_80_90".
	BlueVlans AllianceVlans `json:"blueVlans"`

	// SSID and WPA key for each team station, keyed by alliance and number (e.g. "red1", "blue3). If a station is not
	// included, its network will be disabled by setting its SSID to a placeholder.
	StationConfigurations map[string]StationConfiguration `json:"stationConfigurations"`

	// IP address of the syslog server to send logs to (via UDP on port 514).
	SyslogIpAddress string `json:"syslogIpAddress"`
}

ConfigurationRequest represents a JSON request to configure the radio.

func (ConfigurationRequest) Validate

func (request ConfigurationRequest) Validate(radio *Radio) error

Validate checks that all parameters within the configuration request have valid values.

type NetworkStatus added in v0.1.10

type NetworkStatus struct {
	// SSID for the network.
	Ssid string `json:"ssid"`

	// SHA-256 hash of the WPA key and salt for the network, encoded as a hexadecimal string. The WPA key is not exposed
	// directly to prevent unauthorized users from learning its value. However, a user who already knows the WPA key can
	// verify that it is correct by concatenating it with the WpaKeySalt and hashing the result using SHA-256; the
	// result should match the HashedWpaKey.
	HashedWpaKey string `json:"hashedWpaKey"`

	// Randomly generated salt used to hash the WPA key.
	WpaKeySalt string `json:"wpaKeySalt"`

	// Whether this network is currently associated with a remote device.
	IsLinked bool `json:"isLinked"`

	// MAC address of the remote device currently associated with this network. Blank if not associated.
	MacAddress string `json:"macAddress"`

	// Signal strength of the link to the remote device, in decibel-milliwatts. Zero if not associated.
	SignalDbm int `json:"signalDbm"`

	// Noise level of the link to the remote device, in decibel-milliwatts. Zero if not associated.
	NoiseDbm int `json:"noiseDbm"`

	// Current signal-to-noise ratio (SNR) in decibels. Zero if not associated.
	SignalNoiseRatio int `json:"signalNoiseRatio"`

	// Upper-bound link receive rate (from the remote device to this one) in megabits per second. Zero if not
	// associated.
	RxRateMbps float64 `json:"rxRateMbps"`

	// Number of packets received from the remote device. Zero if not associated.
	RxPackets int `json:"rxPackets"`

	// Number of bytes received from the remote device. Zero if not associated.
	RxBytes int `json:"rxBytes"`

	// Upper-bound link transmit rate (from this device to the remote one) in megabits per second. Zero if not
	// associated.
	TxRateMbps float64 `json:"txRateMbps"`

	// Number of packets transmitted to the remote device. Zero if not associated.
	TxPackets int `json:"txPackets"`

	// Number of bytes transmitted to the remote device. Zero if not associated.
	TxBytes int `json:"txBytes"`

	// Current five-second average total (rx + tx) bandwidth in megabits per second.
	BandwidthUsedMbps float64 `json:"bandwidthUsedMbps"`

	// Human-readable string describing connection quality to the remote device. Based on RX rate. Blank if not associated.
	ConnectionQuality string `json:"connectionQuality"`

	// Flag representing whether the interface is for a robot.
	IsRobot bool `json:"-"`
}

NetworkStatus encapsulates the status of a single Wi-Fi interface on the device (i.e. a team SSID network on the access point or one of the two interfaces on the robot radio).

type Radio

type Radio struct {
	// 5GHz or 6GHz channel number the radio is broadcasting on.
	Channel int `json:"channel"`

	// Channel bandwidth mode for the radio to use. Valid values are "20MHz" and "40MHz".
	ChannelBandwidth string `json:"channelBandwidth"`

	// VLANs to use for the teams of the red alliance. Valid values are "10_20_30", "40_50_60", and "70_80_90".
	RedVlans AllianceVlans `json:"redVlans"`

	// VLANs to use for the teams of the blue alliance. Valid values are "10_20_30", "40_50_60", and "70_80_90".
	BlueVlans AllianceVlans `json:"blueVlans"`

	// Enum representing the current configuration stage of the radio.
	Status radioStatus `json:"status"`

	// Map of team station names to their current status.
	StationStatuses map[string]*NetworkStatus `json:"stationStatuses"`

	// IP address of the syslog server to send logs to (via UDP on port 514).
	SyslogIpAddress string `json:"syslogIpAddress"`

	// Version of the radio software.
	Version string `json:"version"`

	// Queue for receiving and buffering configuration requests.
	ConfigurationRequestChannel chan ConfigurationRequest `json:"-"`

	// Hardware type of the radio.
	Type RadioType `json:"-"`
	// contains filtered or unexported fields
}

Radio holds the current state of the access point's configuration and any robot radios connected to it.

func NewRadio

func NewRadio() *Radio

NewRadio creates a new Radio instance and initializes its fields to default values.

func (*Radio) Run

func (radio *Radio) Run()

Run loops indefinitely, handling configuration requests and polling the Wi-Fi status.

type RadioType added in v0.1.5

type RadioType int

RadioType represents the hardware type of the radio.

const (
	TypeUnknown RadioType = iota
	TypeLinksys
	TypeVividHosting
)

func (RadioType) String added in v0.1.5

func (i RadioType) String() string

type StationConfiguration

type StationConfiguration struct {
	// Team-specific SSID for the station, usually equal to the team number as a string.
	Ssid string `json:"ssid"`

	// Team-specific WPA key for the station. Must be at least eight characters long.
	WpaKey string `json:"wpaKey"`
}

StationConfiguration represents the configuration for a single team station.

Jump to

Keyboard shortcuts

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