-
-
Notifications
You must be signed in to change notification settings - Fork 487
fix(firmware): Keep bundled release discovery available #6082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a26e7bd
8ec4ef1
091c05a
4a8fea8
00e5e29
864f6d5
d019ae0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,57 +172,56 @@ class FirmwareUpdateViewModel( | |
| enterRecoveryModeOrError() | ||
| return@launch | ||
| } | ||
| getDeviceHardware(ourNode)?.let { deviceHardware -> | ||
| _deviceHardware.value = deviceHardware | ||
| _currentFirmwareVersion.value = ourNode.firmwareVersion | ||
|
|
||
| val releaseFlow = | ||
| if (_selectedReleaseType.value == FirmwareReleaseType.LOCAL) { | ||
| flowOf(null) | ||
| } else { | ||
| firmwareReleaseRepository.getReleaseFlow(_selectedReleaseType.value) | ||
| } | ||
|
|
||
| releaseFlow.collectLatest { release -> | ||
| _selectedRelease.value = release | ||
| val dismissed = bootloaderWarningDataSource.isDismissed(address) | ||
| val firmwareUpdateMethod = | ||
| when { | ||
| radioPrefs.isSerial() -> { | ||
| // Serial OTA is not yet supported for ESP32 — only nRF52/RP2040 UF2. | ||
| if (deviceHardware.isEsp32Arc) { | ||
| FirmwareUpdateMethod.Unknown | ||
| } else { | ||
| FirmwareUpdateMethod.Usb | ||
| } | ||
| val deviceHardware = getDeviceHardware(ourNode) ?: return@launch | ||
| _deviceHardware.value = deviceHardware | ||
| _currentFirmwareVersion.value = ourNode.firmwareVersion | ||
|
|
||
| val releaseFlow = | ||
| if (_selectedReleaseType.value == FirmwareReleaseType.LOCAL) { | ||
| flowOf(null) | ||
| } else { | ||
| firmwareReleaseRepository.getReleaseFlow(_selectedReleaseType.value) | ||
| } | ||
| releaseFlow.collectLatest { release -> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description says release collection now starts before hardware resolution, but |
||
| _selectedRelease.value = release | ||
|
|
||
| val dismissed = bootloaderWarningDataSource.isDismissed(address) | ||
| val firmwareUpdateMethod = | ||
| when { | ||
| radioPrefs.isSerial() -> { | ||
| // Serial OTA is not yet supported for ESP32 — only nRF52/RP2040 UF2. | ||
| if (deviceHardware.isEsp32Arc) { | ||
| FirmwareUpdateMethod.Unknown | ||
| } else { | ||
| FirmwareUpdateMethod.Usb | ||
| } | ||
| } | ||
|
|
||
| radioPrefs.isBle() -> FirmwareUpdateMethod.Ble | ||
| radioPrefs.isBle() -> FirmwareUpdateMethod.Ble | ||
|
|
||
| radioPrefs.isTcp() -> { | ||
| // WiFi OTA is ESP32-only; nRF52/RP2040 have no TCP update path. | ||
| if (deviceHardware.isEsp32Arc) { | ||
| FirmwareUpdateMethod.Wifi | ||
| } else { | ||
| FirmwareUpdateMethod.Unknown | ||
| } | ||
| radioPrefs.isTcp() -> { | ||
| // WiFi OTA is ESP32-only; nRF52/RP2040 have no TCP update path. | ||
| if (deviceHardware.isEsp32Arc) { | ||
| FirmwareUpdateMethod.Wifi | ||
| } else { | ||
| FirmwareUpdateMethod.Unknown | ||
| } | ||
|
|
||
| else -> FirmwareUpdateMethod.Unknown | ||
| } | ||
| _state.value = | ||
| FirmwareUpdateState.Ready( | ||
| release = release, | ||
| deviceHardware = deviceHardware, | ||
| address = address, | ||
| showBootloaderWarning = | ||
| deviceHardware.requiresBootloaderUpgradeForOta == true && | ||
| !dismissed && | ||
| radioPrefs.isBle(), | ||
| updateMethod = firmwareUpdateMethod, | ||
| currentFirmwareVersion = ourNode.firmwareVersion, | ||
| ) | ||
| } | ||
|
|
||
| else -> FirmwareUpdateMethod.Unknown | ||
| } | ||
| _state.value = | ||
| FirmwareUpdateState.Ready( | ||
| release = release, | ||
| deviceHardware = deviceHardware, | ||
| address = address, | ||
| showBootloaderWarning = | ||
| deviceHardware.requiresBootloaderUpgradeForOta == true && | ||
| !dismissed && | ||
| radioPrefs.isBle(), | ||
| updateMethod = firmwareUpdateMethod, | ||
| currentFirmwareVersion = ourNode.firmwareVersion, | ||
| ) | ||
| } | ||
| } | ||
| .onFailure { e -> | ||
|
|
@@ -244,12 +243,14 @@ class FirmwareUpdateViewModel( | |
| private suspend fun enterRecoveryModeOrError() { | ||
| val recovery = firmwareRecoveryDataSource.pending.first() | ||
| if (recovery == null) { | ||
| clearDeviceMetadata() | ||
| _state.value = FirmwareUpdateState.Error(UiText.Resource(Res.string.firmware_update_no_device)) | ||
| return | ||
| } | ||
| pendingRecovery = recovery | ||
| val hardware = | ||
| deviceHardwareRepository.getDeviceHardwareByModel(recovery.hwModel, recovery.pioEnv).getOrElse { | ||
| clearDeviceMetadata() | ||
| _state.value = | ||
| FirmwareUpdateState.Error( | ||
| UiText.Resource(Res.string.firmware_update_unknown_hardware, recovery.hwModel), | ||
|
|
@@ -571,15 +572,23 @@ class FirmwareUpdateViewModel( | |
|
|
||
| return if (hwModelInt != null) { | ||
| deviceHardwareRepository.getDeviceHardwareByModel(hwModelInt, target).getOrElse { | ||
| clearDeviceMetadata() | ||
|
jamesarich marked this conversation as resolved.
|
||
| _state.value = | ||
| FirmwareUpdateState.Error(UiText.Resource(Res.string.firmware_update_unknown_hardware, hwModelInt)) | ||
| null | ||
| } | ||
| } else { | ||
| clearDeviceMetadata() | ||
| _state.value = FirmwareUpdateState.Error(UiText.Resource(Res.string.firmware_update_node_info_missing)) | ||
| null | ||
| } | ||
| } | ||
|
|
||
| private fun clearDeviceMetadata() { | ||
| _selectedRelease.value = null | ||
| _deviceHardware.value = null | ||
| _currentFirmwareVersion.value = null | ||
| } | ||
| } | ||
|
|
||
| private suspend fun cleanupTemporaryFiles( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.