private async Task _processMore(int start) { if (start == 0) { return; } imm_reportprogress(0, "Firmware update started"); YFirmwareFile firmware; try { //1% -> 5% if (_firmwarepath.StartsWith("www.yoctopuce.com") || _firmwarepath.StartsWith("http://www.yoctopuce.com")) { this.imm_reportprogress(1, "Downloading firmware"); byte[] bytes = await YFirmwareUpdate._downloadfile(_firmwarepath); firmware = YFirmwareFile.imm_Parse(_firmwarepath, bytes); } else { imm_reportprogress(1, "Loading firmware"); firmware = YFirmwareUpdate._loadFirmwareFile(_firmwarepath); } //5% -> 10% imm_reportprogress(5, "check if module is already in bootloader"); YGenericHub hub = null; YModule module = YModule.FindModuleInContext(_yctx, _serial + ".module"); if (await module.isOnline()) { YDevice yDevice = await module.getYDevice(); hub = yDevice.Hub; } else { // test if already in bootloader foreach (YGenericHub h in _yctx._hubs) { List <string> bootloaders = await h.getBootloaders(); if (bootloaders.Contains(_serial)) { hub = h; break; } } } if (hub == null) { imm_reportprogress(-1, "Device " + _serial + " is not detected"); return; } await hub.firmwareUpdate(_serial, firmware, _settings, imm_firmware_progress); //80%-> 98% imm_reportprogress(80, "wait to the device restart"); ulong timeout = YAPI.GetTickCount() + 60000; await module.clearCache(); while (!await module.isOnline() && timeout > YAPI.GetTickCount()) { await Task.Delay(5000); try { await _yctx.UpdateDeviceList(); } catch (YAPI_Exception) { } } if (await module.isOnline()) { if (_settings != null) { await module.set_allSettingsAndFiles(_settings); await module.saveToFlash(); } imm_reportprogress(100, "Success"); } else { imm_reportprogress(-1, "Device did not reboot correctly"); } } catch (YAPI_Exception e) { imm_reportprogress(e.errorType, e.Message); Debug.WriteLine(e.ToString()); Debug.Write(e.StackTrace); } }