device

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package device reads and changes the state of the unit a session is connected to: its board, running firmware, throughput, internet check, MAC addresses, identity configuration, properties and display settings, and reboots, upgrades or factory resets it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FactoryReset

func FactoryReset(ctx context.Context, c *amplifi.Client) error

FactoryReset erases the unit's configuration and reboots it. It is irreversible. Like Reboot, a dropped connection counts as success, and the session is unusable afterwards.

func Reboot

func Reboot(ctx context.Context, c *amplifi.Client) error

Reboot asks the unit to reboot. The unit typically drops the connection instead of replying, which counts as success. The session is unusable afterwards.

func UpdateDisplay

func UpdateDisplay(ctx context.Context, c *amplifi.Client, u DisplayUpdate) error

UpdateDisplay changes the display settings set in u, keeping the others.

func Upgrade

func Upgrade(ctx context.Context, c *amplifi.Client) error

Upgrade upgrades only the unit this session is connected to, with the upgrade it has already found. The unit may drop the connection to flash and reboot, which counts as success; the session is unusable afterwards. Mesh-wide upgrades are in package firmware.

Types

type Board

type Board struct {
	Name     string         `json:"name"`
	Revision int            `json:"revision"`
	Fields   map[string]any `json:"fields"`
}

Board is a unit's system board description. Fields holds every option code returned, so unmapped ones are still visible.

func GetBoard

func GetBoard(ctx context.Context, c *amplifi.Client) (*Board, error)

GetBoard fetches the unit's board description.

type Config

type Config struct {
	InitialSetupDone         bool           `json:"initial_setup_done"`
	FirmwareUpgradeAvailable bool           `json:"firmware_upgrade_available"`
	ProtocolVersion          int            `json:"protocol_version"`
	FriendlyName             string         `json:"friendly_name"`
	PlatformName             string         `json:"platform_name"`
	UniqueName               string         `json:"unique_name"`
	ModelName                string         `json:"model_name"`
	SystemName               string         `json:"system_name"`
	BoardName                string         `json:"board_name"`
	BoardRevision            int            `json:"board_revision"`
	Country                  string         `json:"country"`
	Timezone                 string         `json:"timezone"`
	ZoneName                 string         `json:"zone_name"`
	HostName                 string         `json:"host_name"`
	Role                     amplifi.Role   `json:"role,omitempty"`
	ConnectivityMode         string         `json:"connectivity_mode"`
	Fields                   map[string]any `json:"fields"`
}

Config is the unit's identity and locale configuration. Fields holds every option code returned, so unmapped ones are still visible.

func GetConfig

func GetConfig(ctx context.Context, c *amplifi.Client) (*Config, error)

GetConfig fetches the unit's device configuration.

type Display

type Display struct {
	SystemSoundVolume int           `json:"system_sound_volume"`
	TapSoundVolume    int           `json:"tap_sound_volume"`
	LCDBrightness     int           `json:"lcd_brightness"`
	LEDBrightness     int           `json:"led_brightness"`
	ClockType         int           `json:"clock_type"`
	ClockTimeout      int           `json:"clock_timeout"`
	OffTimeout        int           `json:"off_timeout"`
	NightStart        time.Duration `json:"night_start"`
	NightEnd          time.Duration `json:"night_end"`
	NightMode         bool          `json:"night_mode"`
}

Display is the unit's touchscreen, LED and sound settings (UiConfig). NightStart and NightEnd are times of day as durations since midnight. The units of the timeouts are unconfirmed; they are the unit's raw values.

func GetDisplay

func GetDisplay(ctx context.Context, c *amplifi.Client) (*Display, error)

GetDisplay fetches the unit's display settings.

func (Display) MarshalJSON

func (d Display) MarshalJSON() ([]byte, error)

MarshalJSON renders NightStart and NightEnd in seconds.

type DisplayUpdate

type DisplayUpdate struct {
	SystemSoundVolume *int
	TapSoundVolume    *int
	LCDBrightness     *int
	LEDBrightness     *int
	ClockType         *int
	ClockTimeout      *int
	OffTimeout        *int
	NightStart        *time.Duration
	NightEnd          *time.Duration
	NightMode         *bool
}

DisplayUpdate holds the display settings to change; nil fields are left as they are. NightStart and NightEnd are rounded down to whole minutes.

type Firmware

type Firmware struct {
	Type            string `json:"type"`
	Version         string `json:"version"`
	Revision        string `json:"revision"`
	UpgradeVersion  string `json:"upgrade_version"`
	UpgradeRevision string `json:"upgrade_revision"`
}

Firmware describes the unit's own running firmware and, when one is pending, the upgrade the unit has found. Mesh-wide updates are in package firmware.

func GetFirmware

func GetFirmware(ctx context.Context, c *amplifi.Client) (*Firmware, error)

GetFirmware fetches the unit's firmware versions.

type Health

type Health int

Health is the traffic light result of an internet check.

const (
	HealthRed    Health = 1
	HealthYellow Health = 2
	HealthGreen  Health = 3
)

Health values.

func ParseHealth

func ParseHealth(s string) (Health, error)

ParseHealth parses a health name: red, yellow or green.

func (Health) MarshalText

func (h Health) MarshalText() ([]byte, error)

MarshalText renders the health by name.

func (Health) String

func (h Health) String() string

String returns the health's name, or "#N" for an unknown value.

type InterfaceMAC

type InterfaceMAC struct {
	Role string      `json:"role"`
	MAC  amplifi.MAC `json:"mac"`
}

InterfaceMAC is one of the unit's MAC addresses and the interface it belongs to.

func MACs

func MACs(ctx context.Context, c *amplifi.Client) ([]InterfaceMAC, error)

MACs lists the unit's MAC addresses by role, in role code order.

type InternetCheck

type InternetCheck struct {
	Health         Health `json:"inet_status"`
	HealthText     string `json:"inet_status_str"`
	Reason         int    `json:"inet_reason"`
	ReasonText     string `json:"inet_reason_str"`
	IPv6Health     Health `json:"ipv6_inet_status"`
	IPv6HealthText string `json:"ipv6_inet_status_str"`
	IPv6Reason     int    `json:"ipv6_inet_reason"`
	IPv6ReasonText string `json:"ipv6_inet_reason_str"`
	LinkSpeed      int    `json:"link_speed"`
	ISP            string `json:"local_isp"`
}

InternetCheck is the result of the unit's internet connectivity check, with the unit's own text for each value. The unit of LinkSpeed is unconfirmed.

func CheckInternet

func CheckInternet(ctx context.Context, c *amplifi.Client) (*InternetCheck, error)

CheckInternet runs the unit's internet connectivity check (Device.InetCheck) and waits for the result.

type Property

type Property struct {
	Interface string `json:"interface"`
	Name      string `json:"name"`
	Value     any    `json:"value,omitempty"`
	Error     string `json:"error,omitempty"`
}

Property is one property value read by Properties. Error is set instead of Value when the unit refused to read it.

func Properties

func Properties(ctx context.Context, c *amplifi.Client) ([]Property, error)

Properties reads every known Device and ClusterNode property and Unsecure.Uptime. Properties the unit refuses (not every firmware has all of them) are returned with Error set; any other failure aborts the read. Use c.Property to read a single property.

type Throughput

type Throughput struct {
	RxKbps    int `json:"rx_kbps"`
	TxKbps    int `json:"tx_kbps"`
	RxMaxKbps int `json:"rx_max_kbps"`
	TxMaxKbps int `json:"tx_max_kbps"`
}

Throughput is the unit's current and peak WAN throughput.

func GetThroughput

func GetThroughput(ctx context.Context, c *amplifi.Client) (*Throughput, error)

GetThroughput fetches the unit's throughput counters.

Jump to

Keyboard shortcuts

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