Skip to content

Commit

Permalink
feat: ✨ provide a possibility to reboot to the SWUpdate
Browse files Browse the repository at this point in the history
The SWUpdate mode allows the installation of a firmware image

Signed-off-by: Christian Ege <[email protected]>
  • Loading branch information
graugans committed Feb 20, 2024
1 parent 905677d commit cee18db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/ovp8xx/cmd/reboot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func rebootCommand(cmd *cobra.Command, args []string) error {

var swu bool
host, err := rootCmd.PersistentFlags().GetString("ip")
if err != nil {
return err
Expand All @@ -19,6 +19,14 @@ func rebootCommand(cmd *cobra.Command, args []string) error {
ovp8xx.WithHost(host),
)

if swu, err = cmd.Flags().GetBool("swupdate"); err != nil {
return err
}

if swu {
return o3r.RebootToSWUpdate()
}

return o3r.Reboot()
}

Expand All @@ -31,4 +39,5 @@ var rebootCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(rebootCmd)
rebootCmd.Flags().Bool("swupdate", false, "Reboot to the SWUpdate mode")
}
13 changes: 13 additions & 0 deletions pkg/ovp8xx/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ func (device *Client) Reboot() error {
return client.Call("reboot", nil, nil)
}

// RebootToSWUpdate reboots the OVP8xx device into software update mode.
// It establishes a connection with the device using XML-RPC and calls the "rebootToRecovery" method.
// This method is typically used to initiate a firmware update on the device.
// Returns an error if there was a problem establishing the connection or calling the method.
func (device *Client) RebootToSWUpdate() error {
client, err := xmlrpc.NewClient(device.url)
if err != nil {
return err
}
defer client.Close()
return client.Call("rebootToRecovery", nil, nil)
}

func (device *DiagnosisClient) GetFiltered(conf Config) (Config, error) {
client, err := xmlrpc.NewClient(device.url)
if err != nil {
Expand Down

0 comments on commit cee18db

Please sign in to comment.