private void DeviceConnected(bool isConnected) { if (isConnected) { var dataflash = m_updater.ReadDataFlash(); m_connectedDeviceProductId = dataflash.ProductId; var deviceName = FirmwareUpdater.GetDeviceName(m_connectedDeviceProductId); UpdateUI(() => { DeviceNameTextBox.Text = deviceName; HardwareVersionTextBox.Text = dataflash.HardwareVersion.ToString("0.00", CultureInfo.InvariantCulture); FirmwareVersionTextBox.Text = dataflash.FirmwareVersion.ToString("0.00", CultureInfo.InvariantCulture); SetUpdaterButtonsState(true); }); } else { UpdateUI(() => { DeviceNameTextBox.Clear(); HardwareVersionTextBox.Clear(); FirmwareVersionTextBox.Clear(); SetUpdaterButtonsState(false); }); m_connectedDeviceProductId = null; } }
private void SetUpdaterButtonsState(bool enabled) { LogoButton.Enabled = enabled && FirmwareUpdater.GetCanUploadLogo(m_connectedDeviceProductId); UpdateButton.Enabled = enabled && m_firmware != null; UpdateFromFileButton.Enabled = enabled; ResetDataflashButton.Enabled = enabled; ReadDataflashButton.Enabled = enabled; WriteDataflashButton.Enabled = enabled; }
public bool UpdateDevice(Update updates) { bool status = false; string appFw = updates.GetAppDataString(); string bslFw = updates.GetRamBslDataString(); firmwareUpdater = new FirmwareUpdater(appFw, bslFw, false); firmwareUpdater.ProgressUpdated += OnProgressUpdated; int retryAttempt = 0; while (retryAttempt < 10) { Logger.Debug("retry attempt: {0}", retryAttempt); if (firmwareUpdater.Connected) { Logger.Debug("device found"); firmwareUpdater.startFirmwareUpdate(); while (firmwareUpdater.Status == FirmwareUpdater.CONNECTED || firmwareUpdater.Status == FirmwareUpdater.SENDINGDATA) { Thread.Sleep(1000); } if (firmwareUpdater.Status == FirmwareUpdater.COMPLETE) { Logger.Debug("update completed"); status = true; break; } else if (firmwareUpdater.Status == FirmwareUpdater.CANCELED) { Logger.Debug("update canceled"); } else { Logger.Debug("update failed"); } } else { Logger.Debug("device not found"); } Thread.Sleep(1000); retryAttempt++; } return(status); }
protected override void OnDispose(bool disposing) { if (disposing) { this._updater.Dispose(); this._updater = null; this.UpdateCollection = null; this.CurrentStep = null; } base.OnDispose(disposing); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. status.Text = device.State.ToString(); deviceName.Text = device.Name; deviceId.Text = device.Id.ToString(); var picker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Open); picker.WasCancelled += Picker_WasCancelled; uploadFile.TouchUpInside += delegate { picker.DidPickDocumentAtUrls += (object s, UIDocumentPickedAtUrlsEventArgs e) => { Console.WriteLine("url = {0}", e.Urls[0].AbsoluteString); //bool success = await MoveFileToApp(didPickDocArgs.Url); var success = true; string filename = e.Urls[0].LastPathComponent; string extension = Path.GetExtension(filename);; string msg = success ? string.Format("Successfully imported file '{0}'", filename) : string.Format("Failed to import file '{0}'", filename); // Some invaild file url returns null NSData data = NSData.FromUrl(e.Urls[0]); if (data != null) { byte[] dataBytes = new byte[data.Length]; System.Runtime.InteropServices.Marshal.Copy(data.Bytes, dataBytes, 0, Convert.ToInt32(data.Length)); for (int i = 0; i < dataBytes.Length; i++) { Console.WriteLine(dataBytes[i]); } } Console.WriteLine(data + "Completed"); var alertController = UIAlertController.Create("import", msg, UIAlertControllerStyle.Alert); var okButton = UIAlertAction.Create("OK", UIAlertActionStyle.Default, (obj) => { alertController.DismissViewController(true, null); }); alertController.AddAction(okButton); PresentViewController(alertController, true, null); }; PresentViewController(picker, true, null); }; updateFirmware.TouchUpInside += delegate { FirmwareUpdaterDelegate firmwareUpdater = new FirmwareUpdater(device.NativeDevice as CBPeripheral); firmwareUpdater.Start(); }; }
private void DeviceConnected(bool isConnected) { if (isConnected) { System.Diagnostics.Trace.WriteLine("Connected " + DateTime.Now); Dataflash dataflash; try { dataflash = m_updater.ReadDataflash(); } catch { return; } m_connectedDeviceProductId = dataflash.ProductId; m_deviceInfo = FirmwareUpdater.GetDeviceInfo(m_connectedDeviceProductId); m_hardwareVersion = dataflash.HardwareVersion.ToString("0.00", CultureInfo.InvariantCulture); m_firmwareVersion = dataflash.FirmwareVersion.ToString("0.00", CultureInfo.InvariantCulture); UpdateUI(() => { DeviceNameTextBox.Text = m_deviceInfo.Name; HardwareVersionTextBox.Text = m_hardwareVersion; FirmwareVersionTextBox.Text = m_firmwareVersion; BootModeTextBox.Text = dataflash.LoadFromLdrom ? "LDROM" : "APROM"; UpdateStatusLabel.Text = @"Device is ready."; SetUpdaterButtonsState(true); }); } else { System.Diagnostics.Trace.WriteLine("Disconnected " + DateTime.Now); UpdateUI(() => { DeviceNameTextBox.Clear(); HardwareVersionTextBox.Clear(); FirmwareVersionTextBox.Clear(); BootModeTextBox.Clear(); UpdateStatusLabel.Text = @"Waiting for device..."; SetUpdaterButtonsState(false); }); m_connectedDeviceProductId = null; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.firmware_update); _abortButton = FindViewById <Button>(Resource.Id.fwUpdateAbort); _pauseButton = FindViewById <Button>(Resource.Id.fwUpdatePause); _continueButton = FindViewById <Button>(Resource.Id.fwUpdateContinue); _statusTextView = FindViewById <TextView>(Resource.Id.fwStatusText); _errorTextView = FindViewById <TextView>(Resource.Id.fwErrorText); _successTextView = FindViewById <TextView>(Resource.Id.fwSuccessText); var fwTitleText = FindViewById <TextView>(Resource.Id.fwTitleText); _fwProgressBar = FindViewById <ProgressBar>(Resource.Id.fwProgressBar); _fwProgressSpinner = FindViewById <ProgressBar>(Resource.Id.fwSpinner); fwTitleText.Text = $"Updating device {CurrentParameters.CurrentDevice.Name} with firmware {CurrentParameters.CurrentFirmwareUri.LastPathSegment}:"; _progressListener = new DfuProgressListener(); _updater = new FirmwareUpdater(CurrentParameters.CurrentDevice.Address, CurrentParameters.CurrentFirmwareUri, _progressListener); _updater.Start(); }
public void FirmwareUpdateTestMethod() { FirmwareUpdater firmwareUpdater = new FirmwareUpdater("COM3", "D:\\3.hex"); }
internal UIFirmwareUpdater(UIDevice device, FirmwareUpdater updater) { this._device = device; this._updater = updater; this.ResetState(); }