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 ¶
- func FactoryReset(ctx context.Context, c *amplifi.Client) error
- func Reboot(ctx context.Context, c *amplifi.Client) error
- func UpdateDisplay(ctx context.Context, c *amplifi.Client, u DisplayUpdate) error
- func Upgrade(ctx context.Context, c *amplifi.Client) error
- type Board
- type Config
- type Display
- type DisplayUpdate
- type Firmware
- type Health
- type InterfaceMAC
- type InternetCheck
- type Property
- type Throughput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FactoryReset ¶
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 ¶
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 ¶
UpdateDisplay changes the display settings set in u, keeping the others.
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.
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.
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 ¶
GetDisplay fetches the unit's display settings.
func (Display) MarshalJSON ¶
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.
type Health ¶
type Health int
Health is the traffic light result of an internet check.
func ParseHealth ¶
ParseHealth parses a health name: red, yellow or green.
func (Health) MarshalText ¶
MarshalText renders the health by name.
type InterfaceMAC ¶
InterfaceMAC is one of the unit's MAC addresses and the interface it belongs to.
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 ¶
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 ¶
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 ¶
GetThroughput fetches the unit's throughput counters.