feat: EspFlasher split assets server/client based on deviceMode
This commit is contained in:
parent
793c8f190c
commit
ccfd7cb693
1 changed files with 9 additions and 4 deletions
|
|
@ -28,6 +28,11 @@ class EspFlasher(private val context: Context) {
|
|||
fun onProgress(percent: Int, message: String)
|
||||
}
|
||||
|
||||
private fun assetPath(baseName: String): String {
|
||||
val prefix = if (PrefsHelper.getDeviceMode(context) == "client") "client/" else "server/"
|
||||
return "firmware/$prefix$baseName"
|
||||
}
|
||||
|
||||
suspend fun flashDevice(usbManager: UsbManager, device: UsbDevice, callback: FlashCallback) {
|
||||
try {
|
||||
withContext(kotlinx.coroutines.Dispatchers.IO) {
|
||||
|
|
@ -77,10 +82,10 @@ class EspFlasher(private val context: Context) {
|
|||
coroutineContext.ensureActive()
|
||||
|
||||
val assets = context.assets
|
||||
val bootloader = assets.open("firmware/bootloader.bin").readBytes()
|
||||
val partitions = assets.open("firmware/partitions.bin").readBytes()
|
||||
val bootApp0 = assets.open("firmware/boot_app0.bin").readBytes()
|
||||
val firmware = assets.open("firmware/firmware.bin").readBytes()
|
||||
val bootloader = assets.open(assetPath("bootloader.bin")).readBytes()
|
||||
val partitions = assets.open(assetPath("partitions.bin")).readBytes()
|
||||
val bootApp0 = assets.open(assetPath("boot_app0.bin")).readBytes()
|
||||
val firmware = assets.open(assetPath("firmware.bin")).readBytes()
|
||||
|
||||
val steps = listOf(
|
||||
FlashStep(R.string.flash_step_bootloader, 0x0, bootloader, 30, 10, false),
|
||||
|
|
|
|||
Loading…
Reference in a new issue