-
Notifications
You must be signed in to change notification settings - Fork 9
/
firmwareupdate.go
30 lines (26 loc) · 959 Bytes
/
firmwareupdate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package linksys
import "time"
// GetLastUpgradeCheck returns the date of the last firmware upgrade check.
func (client Client) GetLastUpgradeCheck() (time.Time, error) {
var check struct {
LastCheck string `json:"lastSuccessfulCheckTime"`
AvailableUpdate *struct {
Version string `json:"firmwareVersion"`
Date string `json:"firmwareDate"`
Description string `json:"description"`
} `json:"availableUpdate"`
PendingOperation *struct {
Operation string `json:"operation"`
Progress int `json:"progressPercent"`
}
}
err := client.MakeRequest("firmwareupdate/GetFirmwareUpdateStatus", nil, &check)
if err != nil {
return time.Unix(0, 0), err
}
return time.Parse(time.RFC3339, check.LastCheck)
}
// UpgradeFirmware checks for an update and updates if available. Requires authorization.
func (client Client) UpgradeFirmware() error {
return client.MakeRequest("firmwareupdate/UpdateFirmwareNow", nil, nil)
}