feat: Add ESP32 Unified OTA update support (#4095)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
James Rich 2026-01-14 21:22:30 -06:00 committed by GitHub
parent 6b5dd24249
commit 2a60480bd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 3410 additions and 717 deletions

View file

@ -18,6 +18,7 @@ package com.geeksville.mesh.service
import com.geeksville.mesh.concurrent.handledLaunch
import com.geeksville.mesh.util.ignoreException
import com.google.protobuf.ByteString
import dagger.Lazy
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -302,6 +303,16 @@ constructor(
commandSender.sendAdmin(destNum, requestId) { rebootSeconds = DEFAULT_REBOOT_DELAY }
}
fun handleRequestRebootOta(requestId: Int, destNum: Int, mode: Int, hash: ByteArray?) {
val otaMode = AdminProtos.OTAMode.forNumber(mode) ?: AdminProtos.OTAMode.NO_REBOOT_OTA
val otaEventBuilder = AdminProtos.AdminMessage.OTAEvent.newBuilder()
otaEventBuilder.rebootOtaMode = otaMode
if (hash != null) {
otaEventBuilder.otaHash = ByteString.copyFrom(hash)
}
commandSender.sendAdmin(destNum, requestId) { otaRequest = otaEventBuilder.build() }
}
fun handleRequestFactoryReset(requestId: Int, destNum: Int) {
commandSender.sendAdmin(destNum, requestId) { factoryResetDevice = 1 }
}

View file

@ -52,6 +52,7 @@ import org.meshtastic.core.service.ServiceRepository
import javax.inject.Inject
@AndroidEntryPoint
@Suppress("TooManyFunctions", "LargeClass")
class MeshService : Service() {
@Inject lateinit var radioInterfaceService: RadioInterfaceService
@ -342,5 +343,10 @@ class MeshService : Service() {
override fun requestTelemetry(requestId: Int, destNum: Int, type: Int) = toRemoteExceptions {
router.actionHandler.handleRequestTelemetry(requestId, destNum, type)
}
override fun requestRebootOta(requestId: Int, destNum: Int, mode: Int, hash: ByteArray?) =
toRemoteExceptions {
router.actionHandler.handleRequestRebootOta(requestId, destNum, mode, hash)
}
}
}