Skip to content

Commit

Permalink
Nrf prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Jan 20, 2023
1 parent b70a923 commit 40d7915
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Meshtastic.Cli/CommandHandlers/UpdateCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ private async Task StartInteractiveFlashUpdate(HardwareModel hardwareModel)

if (HardwareModelMappings.NrfHardwareModels.Contains(hardwareModel))
{
var _ = AnsiConsole.Prompt(new SelectionPrompt<string>()
.AddChoices(new[] { "Yes" })
.Title("Have you double-pressed the RST button to enter DFU mode?"));
var drive = GetSelectedDrive();
await Uf2Update(drive, filePath);
}
Expand All @@ -54,9 +57,16 @@ private async Task StartInteractiveFlashUpdate(HardwareModel hardwareModel)

private static async Task Uf2Update(string drive, string uf2Path)
{
AnsiConsole.WriteLine($"Copying uf2 file to {drive}");
await RunAsync("cp", uf2Path);
AnsiConsole.WriteLine($"Copying complete");
await AnsiConsole.Status()
.Spinner(Spinner.Known.Dots)
.StartAsync("Flashing", async (ctx) =>
{
AnsiConsole.WriteLine($"Copying uf2 file to {drive}");
File.Copy(uf2Path, Path.Combine(drive, new FileInfo(uf2Path).Name));
await Task.Delay(2000);
File.Delete(uf2Path);
AnsiConsole.Write("Completed device update!");
});
}

private static void EsptoolUpdate(string binPath, string port)
Expand Down Expand Up @@ -107,7 +117,7 @@ private static void SetEsptoolProcessInfo(ProcessStartInfo processStartInfo, str
private static string GetSelectedDrive()
{
return AnsiConsole.Prompt(new SelectionPrompt<string>()
.Title("Which drive?")
.Title("Which drive is the device?")
.AddChoices(Directory.GetLogicalDrives()));
}

Expand Down

0 comments on commit 40d7915

Please sign in to comment.