orion/emlid/updater/update.go

35 lines
864 B
Go

package updater
import "context"
const (
eventUpdate = "update"
eventOPKGUpdateResult = "opkg update result"
eventSkipUpdate = "skip update"
)
// 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
func (c *Client) Update(ctx context.Context) (*UpdateStatus, error) {
res := &UpdateStatus{}
if err := c.ReqResp(ctx, eventUpdate, nil, eventOPKGUpdateResult, res); err != nil {
return nil, err
}
c.Logf(
"opkg update result: active: %v, state: %v, locked: %v",
res.Active, res.State, res.Locked,
)
return res, nil
}
// SkipUpdate asks the ReachRS module to skip the update
func (c *Client) SkipUpdate() error {
return c.Emit(eventSkipUpdate, nil)
}