This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
2018-09-21 12:31:52 +02:00
|
|
|
package updater
|
|
|
|
|
2018-09-26 12:05:55 +02:00
|
|
|
import "context"
|
|
|
|
|
2018-09-21 12:31:52 +02:00
|
|
|
const (
|
|
|
|
eventUpdate = "update"
|
|
|
|
eventOPKGUpdateResult = "opkg update result"
|
|
|
|
)
|
|
|
|
|
|
|
|
// UpdateStatus embeds informations about update status
|
|
|
|
type UpdateStatus struct {
|
|
|
|
Active bool `json:"active"`
|
|
|
|
Locked bool `json:"locked"`
|
|
|
|
State string `json:"state"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update asks the ReachRS module to start an OPKG update
|
2018-09-26 12:05:55 +02:00
|
|
|
func (c *Client) Update(ctx context.Context) (*UpdateStatus, error) {
|
2018-09-21 12:31:52 +02:00
|
|
|
res := &UpdateStatus{}
|
2018-09-26 12:05:55 +02:00
|
|
|
if err := c.ReqResp(ctx, eventUpdate, nil, eventOPKGUpdateResult, res); err != nil {
|
2018-09-21 12:31:52 +02:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
c.Logf(
|
|
|
|
"opkg update result: active: %v, state: %v, locked: %v",
|
|
|
|
res.Active, res.State, res.Locked,
|
|
|
|
)
|
|
|
|
return res, nil
|
|
|
|
}
|