diff --git a/Source/v2/Meadow.CLI/Commands/Current/Firmware/FirmwareUpdater.cs b/Source/v2/Meadow.CLI/Commands/Current/Firmware/FirmwareUpdater.cs index 4b5e5351..83af0413 100644 --- a/Source/v2/Meadow.CLI/Commands/Current/Firmware/FirmwareUpdater.cs +++ b/Source/v2/Meadow.CLI/Commands/Current/Firmware/FirmwareUpdater.cs @@ -21,7 +21,7 @@ public class FirmwareUpdater where T : BaseDeviceCommand private readonly ISettingsManager settings; private readonly FileManager fileManager; - private int _lastWriteProgress = 0; + private int lastWriteProgress = 0; private BaseDeviceCommand command; @@ -103,7 +103,18 @@ public async Task UpdateFirmware() if (!string.IsNullOrWhiteSpace(serialNumber)) { connection = await GetConnectionAndDisableRuntime(await MeadowConnectionManager.GetRouteFromSerialNumber(serialNumber)); - deviceInfo = await connection.GetDeviceInfo(cancellationToken); + if (connection != null) + { + if (provisioninInProgress) + { + connection.ConnectionMessage += (o, e) => + { + UpdateProgress?.Invoke(this, (e, 0)); + }; + } + + deviceInfo = await connection.GetDeviceInfo(cancellationToken); + } } if (firmwareFileTypes.Contains(FirmwareType.Runtime) || Path.GetFileName(individualFile) == F7FirmwarePackageCollection.F7FirmwareFiles.RuntimeFile) @@ -303,15 +314,15 @@ private async Task GetConnectionAndDisableRuntime(string? rou await connection.Device.RuntimeDisable(); } - _lastWriteProgress = 0; + lastWriteProgress = 0; connection.FileWriteProgress += (s, e) => { var p = (int)(e.completed / (double)e.total * 100d); // don't report < 10% increments (decrease spew on large files) - if (p - _lastWriteProgress < 10) { return; } + if (p - lastWriteProgress < 10) { return; } - _lastWriteProgress = p; + lastWriteProgress = p; logger?.LogInformation($"{Strings.Writing} {e.fileName}: {p:0}% {(p < 100 ? string.Empty : "\r\n")}"); }; diff --git a/Source/v2/Meadow.CLI/Commands/Current/Provision/ProvisionCommand.cs b/Source/v2/Meadow.CLI/Commands/Current/Provision/ProvisionCommand.cs index 6e6088b6..14781c20 100644 --- a/Source/v2/Meadow.CLI/Commands/Current/Provision/ProvisionCommand.cs +++ b/Source/v2/Meadow.CLI/Commands/Current/Provision/ProvisionCommand.cs @@ -244,7 +244,10 @@ await AnsiConsole.Progress() var firmareUpdater = new FirmwareUpdater(this, settingsManager, fileManager, this.connectionManager, null, null, true, OsVersion, deviceSerialNumber, null, CancellationToken); firmareUpdater.UpdateProgress += (o, e) => { - task.Value = e.percentage; + if (e.percentage > 0) + { + task.Value = e.percentage; + } task.Description = $"{formatedDevice}: {e.message}"; };