firmware

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 firmware checks for and installs firmware upgrades across an AmpliFi mesh (the FwUpdate interface), reports their progress, and reads and writes the automatic update settings. Upgrading only the unit a session is connected to is device.Upgrade.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(ctx context.Context, c *amplifi.Client) (map[string]any, error)

GetConfig reads the automatic update settings as the router sends them; their schema is unknown.

func SetConfig

func SetConfig(ctx context.Context, c *amplifi.Client, cfg map[string]any) error

SetConfig writes the automatic update settings. cfg should be the full object read with GetConfig, with changes applied. Sending it as a JSON argument is untested.

func StartCheck

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

StartCheck asks the router to look for new firmware for every unit in the mesh. The check runs in the background; follow it with GetProgress and read the result with GetVersions.

func StartUpgrade

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

StartUpgrade starts upgrading every unit in the mesh that has an upgrade available. The units download, flash and reboot on their own; follow the progress with GetProgress until the router goes away.

Types

type CheckResult

type CheckResult struct {
	Code   StatusCode `json:"code"`
	Status string     `json:"status"`
}

CheckResult is the outcome of a unit's last update check.

type Progress

type Progress struct {
	State State          `json:"state"`
	Units []UnitProgress `json:"units"`
}

Progress is the progress of a firmware check or upgrade across the mesh, the router first.

func GetProgress

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

GetProgress reports the progress of a firmware check or upgrade.

type State

type State string

State is the phase of a mesh-wide firmware check or upgrade (app: FwUpdateStatus).

const (
	StateIdle        State = "idle"
	StateChecking    State = "checking"
	StateDownloading State = "downloading"
	StateStarted     State = "started"
	StateInProgress  State = "in_progress"
	StateUpToDate    State = "up_to_date"
)

Firmware update states.

func ParseState

func ParseState(s string) (State, error)

ParseState parses a state name such as "idle" or "in_progress".

func (State) Busy

func (s State) Busy() bool

Busy reports whether a check, download or upgrade is in progress.

func (State) MarshalText

func (s State) MarshalText() ([]byte, error)

MarshalText renders the state by name.

func (State) String

func (s State) String() string

String returns the state as the router names it.

type StatusCode

type StatusCode int

StatusCode is a firmware update status code, reported in Version.Code and CheckResult.Code (app: FirmwareStatusCode).

const (
	CodeValid          StatusCode = 1
	CodeGenuine        StatusCode = 2
	CodeInvalidFile    StatusCode = 3
	CodeReady          StatusCode = 4
	CodeNotAvailable   StatusCode = 5
	CodeUpgradeError   StatusCode = 6
	CodeUpgradeStarted StatusCode = 7
	CodeDownloadError  StatusCode = 8
	CodeSamePending    StatusCode = 9
	CodeDownloading    StatusCode = 16
	CodeAvailable      StatusCode = 32
	CodeUpgrading      StatusCode = 64
	CodeCheckError     StatusCode = 128
)

Firmware update status codes.

type UnitProgress

type UnitProgress struct {
	UnitVersion
	Check CheckResult `json:"check"`
}

UnitProgress is one unit's part of a Progress.

type UnitVersion

type UnitVersion struct {
	MAC       amplifi.MAC  `json:"mac"`
	Role      amplifi.Role `json:"role"`
	Current   Version      `json:"current"`
	Upgrade   Version      `json:"upgrade"`
	LastCheck time.Time    `json:"last_check,omitzero"`
}

UnitVersion is the firmware one unit runs and the upgrade available to it, if any.

func (UnitVersion) HasUpgrade

func (u UnitVersion) HasUpgrade() bool

HasUpgrade reports whether an upgrade other than the running firmware is available.

type Version

type Version struct {
	Version  string     `json:"version"`
	Revision string     `json:"revision"`
	Status   string     `json:"status"`
	Code     StatusCode `json:"code"`
}

Version identifies a firmware image.

type Versions

type Versions struct {
	State State         `json:"state"`
	Units []UnitVersion `json:"units"`
}

Versions is the mesh-wide firmware state: what each unit runs and what it can upgrade to, the router first.

func GetVersions

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

GetVersions reports the firmware each unit in the mesh runs and any upgrade the router has found for it. It does not start a new check.

Jump to

Keyboard shortcuts

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