refactor(firmware): Simplify ESP32 firmware check (#4272)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-20 20:42:16 -06:00 committed by GitHub
parent 85a6900b74
commit b73a304452
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 37 additions and 247 deletions

View file

@ -236,7 +236,6 @@ constructor(
}
base.copy(
requiresBootloaderUpgradeForOta = matchedQuirk.requiresBootloaderUpgradeForOta,
supportsUnifiedOta = matchedQuirk.supportsUnifiedOta,
bootloaderInfoUrl = matchedQuirk.infoUrl,
)
} else {

View file

@ -96,6 +96,19 @@ class DeviceHardwareRepositoryTest {
assertEquals("tdeck-pro", result?.platformioTarget)
}
@Test
fun `getDeviceHardwareByModel correctly sets isEsp32Arc for ESP32 devices`() = runTest(testDispatcher) {
val hwModel = 50
val entities = listOf(createEntity(hwModel, "t-deck", "T-Deck").copy(architecture = "esp32-s3"))
coEvery { localDataSource.getByHwModel(hwModel) } returns entities
every { bootloaderOtaQuirksJsonDataSource.loadBootloaderOtaQuirksFromJsonAsset() } returns emptyList()
val result = repository.getDeviceHardwareByModel(hwModel).getOrNull()
assertEquals(true, result?.isEsp32Arc)
}
private fun createEntity(hwModel: Int, target: String, displayName: String) = DeviceHardwareEntity(
activelySupported = true,
architecture = "esp32-s3",

View file

@ -30,11 +30,6 @@ data class BootloaderOtaQuirk(
* one-time bootloader upgrade (typically via USB) before DFU updates from the app work.
*/
@SerialName("requiresBootloaderUpgradeForOta") val requiresBootloaderUpgradeForOta: Boolean = false,
/**
* Indicates that the device supports the ESP32 Unified OTA protocol. When true, the app will use the unified OTA
* handler instead of Nordic DFU.
*/
@SerialName("supportsUnifiedOta") val supportsUnifiedOta: Boolean = false,
/** Optional URL pointing to documentation on how to update the bootloader. */
@SerialName("infoUrl") val infoUrl: String? = null,
)

View file

@ -38,7 +38,10 @@ data class DeviceHardware(
val requiresBootloaderUpgradeForOta: Boolean? = null,
/** Optional URL pointing to documentation for upgrading the bootloader. */
val bootloaderInfoUrl: String? = null,
val supportsUnifiedOta: Boolean = false,
val supportLevel: Int? = null,
val tags: List<String>? = null,
)
) {
/** Returns true if the device architecture is ESP32-based. */
val isEsp32Arc: Boolean
get() = architecture.startsWith("esp32", ignoreCase = true)
}