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 ¶
- func GetConfig(ctx context.Context, c *amplifi.Client) (map[string]any, error)
- func SetConfig(ctx context.Context, c *amplifi.Client, cfg map[string]any) error
- func StartCheck(ctx context.Context, c *amplifi.Client) error
- func StartUpgrade(ctx context.Context, c *amplifi.Client) error
- type CheckResult
- type Progress
- type State
- type StatusCode
- type UnitProgress
- type UnitVersion
- type Version
- type Versions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfig ¶
GetConfig reads the automatic update settings as the router sends them; their schema is unknown.
func SetConfig ¶
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 ¶
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.
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.
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 ¶
ParseState parses a state name such as "idle" or "in_progress".
func (State) MarshalText ¶
MarshalText renders the state by name.
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.