Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor flash and update to share more code. #567

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

floitsch
Copy link
Member

No description provided.

Short: "Update the firmware on a Jaguar device",
Long: "Update the firmware on a Jaguar device via WiFi. The device name and\n" +
"id are preserved across the operation.",
Use: "update [envelope]",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much no change in this file, except that the shared code has been moved out and the areas I added a comment to (in the PR).

cmd.Flags().MarkHidden("uart-endpoint-rx")
cmd.Flags().Uint("uart-endpoint-baud", 0, "set the baud rate for the UART endpoint")
cmd.Flags().MarkHidden("uart-endpoint-baud")
addFirmwareFlashFlags(cmd, "", "new name of the device, if given")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have the option of changing the name.

"id are preserved across the operation.",
Use: "update [envelope]",
Short: "Update the firmware on a Jaguar device",
Long: "Update the firmware on a Jaguar device via WiFi",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the help, since the ID was already changing, and we now have a way to change the name.

}

func withFirmware(cmd *cobra.Command, args []string, device Device, fun callback) error {
ctx := cmd.Context()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this code was copied out from firmware.go and flash.go.

if device != nil {
chip = device.Chip()
} else {
return fmt.Errorf("chip type must be specified")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change here: the old flash command had the message "auto isn't implemented yet".

return fun(id.String(), envelopeFile, config)
}

func BuildFirmwareEnvelope(ctx context.Context, envelope EnvelopeOptions, device DeviceOptions, uartEndpointOptions map[string]interface{}) (*os.File, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything below this line is copied verbatim without any change.

@floitsch floitsch requested a review from kasperl October 28, 2024 08:56
Copy link
Member

@kasperl kasperl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@floitsch floitsch merged commit 5b4d28a into main Nov 8, 2024
7 checks passed
@floitsch floitsch deleted the floitsch/extract.10.refactor branch November 8, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants