diff --git a/cmd/ovp8xx/cmd/reboot.go b/cmd/ovp8xx/cmd/reboot.go index da670e2..8dd17a1 100644 --- a/cmd/ovp8xx/cmd/reboot.go +++ b/cmd/ovp8xx/cmd/reboot.go @@ -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 @@ -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() } @@ -31,4 +39,5 @@ var rebootCmd = &cobra.Command{ func init() { rootCmd.AddCommand(rebootCmd) + rebootCmd.Flags().Bool("swupdate", false, "Reboot to the SWUpdate mode") } diff --git a/pkg/ovp8xx/rpc.go b/pkg/ovp8xx/rpc.go index 87fb969..8490a5f 100644 --- a/pkg/ovp8xx/rpc.go +++ b/pkg/ovp8xx/rpc.go @@ -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 {