Beispiel #1
0
        partial void DeployAction(NSObject sender)
        {
            var productId = Convert.ToByte(Globals.DeviceTypes.SingleOrDefault(x => x.Name == DeviceType.SelectedItem.Title).ProductID);

            FirmwareManager manager = new FirmwareManager();

            manager.FirmwareUpdateProgress += (string status) =>
            {
                InvokeOnMainThread(() => { DeployButton.Title = "Deploying... " + status + "%"; });
            };

            Task.Run(() =>
            {
                if (string.IsNullOrEmpty(_configFile) || string.IsNullOrEmpty(_flashFile) || string.IsNullOrEmpty(_bootFile))
                {
                    return;
                }

                InvokeOnMainThread(() =>
                {
                    DeployButton.Enabled         = false;
                    UpdateFirmwareButton.Enabled = false;
                    NetworkUpdateButton.Enabled  = false;
                    OutputToConsole("Started deploy");
                });

                try
                {
                    manager.EraseAndUploadDevice(0, productId, _configFile, _flashFile, _bootFile);
                }
                catch (Exception e)
                {
                    InvokeOnMainThread(() => OutputToConsole("Firmware update failed:\n" + e));
                }
                finally
                {
                    InvokeOnMainThread(() =>
                    {
                        _networkConfig = new NetworkConfig();
                        LoadNetworkSettings(true);

                        DeployButton.Title   = "Deploy";
                        DeployButton.Enabled = true;

                        NetworkUpdateButton.Enabled  = true;
                        UpdateFirmwareButton.Enabled = true;

                        BootFile   = string.Empty;
                        ConfigFile = string.Empty;
                        FlashFile  = string.Empty;

                        OutputToConsole("Finished deploy");
                    });
                }
            });
        }
Beispiel #2
0
        partial void UpdateFirmwareAction(NSObject sender)
        {
            var productId = Convert.ToByte(Globals.DeviceTypes.SingleOrDefault(x => x.Name == DeviceType.SelectedItem.Title).ProductID);

            FirmwareManager manager = new FirmwareManager();

            manager.FirmwareUpdateProgress += (string status) =>
            {
                if (status != "100")
                {
                    InvokeOnMainThread(() => UpdateFirmwareButton.Title = "Updating... " + status + "%");
                }
            };

            Task.Run(() =>
            {
                InvokeOnMainThread(() =>
                {
                    OutputToConsole("Started firmware update");
                    UpdateFirmwareButton.Enabled = false;
                    NetworkUpdateButton.Enabled  = false;
                });

                try
                {
                    manager.EraseAndUploadDevice(0, productId);
                }
                catch (Exception e)
                {
                    InvokeOnMainThread(() => OutputToConsole("Firmware update failed:\n" + e));
                    return;
                }
                finally
                {
                    InvokeOnMainThread(() =>
                    {
                        UpdateFirmwareButton.Enabled = true;
                        NetworkUpdateButton.Enabled  = true;
                        UpdateFirmwareButton.Title   = "Update Firmware";
                        _networkConfig = new NetworkConfig();
                        LoadNetworkSettings(true);
                        OutputToConsole("Finished firmware update");
                    });
                }
            });
        }