mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
move to new esp32 firmware build tree (regionless/universal ROMs)
This commit is contained in:
parent
f61cd45847
commit
1bebdf8689
4 changed files with 32 additions and 33 deletions
|
|
@ -1 +0,0 @@
|
|||
../../../../../meshtastic-esp32/release/latest/bins
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.geeksville.mesh.service
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.*
|
||||
import android.app.Service
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
|
@ -20,14 +20,16 @@ import com.geeksville.concurrent.handledLaunch
|
|||
import com.geeksville.mesh.*
|
||||
import com.geeksville.mesh.MeshProtos.MeshPacket
|
||||
import com.geeksville.mesh.MeshProtos.ToRadio
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.database.MeshtasticDatabase
|
||||
import com.geeksville.mesh.database.PacketRepository
|
||||
import com.geeksville.mesh.database.entity.Packet
|
||||
import com.geeksville.util.*
|
||||
import com.google.android.gms.common.api.ApiException
|
||||
import com.google.android.gms.common.api.ResolvableApiException
|
||||
import com.google.android.gms.location.*
|
||||
import com.google.android.gms.location.FusedLocationProviderClient
|
||||
import com.google.android.gms.location.LocationRequest
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.google.android.gms.location.LocationSettingsRequest
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.InvalidProtocolBufferException
|
||||
import kotlinx.coroutines.*
|
||||
|
|
@ -234,7 +236,11 @@ class MeshService : Service(), Logging {
|
|||
})
|
||||
}
|
||||
|
||||
private fun updateNotification() = serviceNotifications.updateNotification(recentReceivedTextPacket, notificationSummary, getSenderName())
|
||||
private fun updateNotification() = serviceNotifications.updateNotification(
|
||||
recentReceivedTextPacket,
|
||||
notificationSummary,
|
||||
getSenderName()
|
||||
)
|
||||
|
||||
/**
|
||||
* tell android not to kill us
|
||||
|
|
@ -247,7 +253,11 @@ class MeshService : Service(), Logging {
|
|||
|
||||
// We always start foreground because that's how our service is always started (if we didn't then android would kill us)
|
||||
// but if we don't really need foreground we immediately stop it.
|
||||
val notification = serviceNotifications.createNotification(recentReceivedTextPacket, notificationSummary, getSenderName())
|
||||
val notification = serviceNotifications.createNotification(
|
||||
recentReceivedTextPacket,
|
||||
notificationSummary,
|
||||
getSenderName()
|
||||
)
|
||||
startForeground(serviceNotifications.notifyId, notification)
|
||||
if (!wantForeground) {
|
||||
stopForeground(true)
|
||||
|
|
@ -1272,8 +1282,6 @@ class MeshService : Service(), Logging {
|
|||
if (info.region != null && info.firmwareVersion != null && info.hwModel != null)
|
||||
SoftwareUpdateService.getUpdateFilename(
|
||||
this,
|
||||
info.region,
|
||||
info.firmwareVersion,
|
||||
info.hwModel
|
||||
)
|
||||
else
|
||||
|
|
@ -1286,6 +1294,9 @@ class MeshService : Service(), Logging {
|
|||
debug("setFirmwareUpdateFilename $firmwareUpdateFilename")
|
||||
}
|
||||
|
||||
/// We only allow one update to be running at a time
|
||||
private var updateJob: Job? = null
|
||||
|
||||
private fun doFirmwareUpdate() {
|
||||
// Run in the IO thread
|
||||
val filename = firmwareUpdateFilename ?: throw Exception("No update filename")
|
||||
|
|
@ -1293,9 +1304,13 @@ class MeshService : Service(), Logging {
|
|||
BluetoothInterface.safe
|
||||
?: throw Exception("Can't update - no bluetooth connected")
|
||||
|
||||
serviceScope.handledLaunch {
|
||||
SoftwareUpdateService.doUpdate(this@MeshService, safe, filename)
|
||||
}
|
||||
if (updateJob?.isActive == true)
|
||||
throw Exception("Firmware update already running")
|
||||
else
|
||||
updateJob = serviceScope.handledLaunch {
|
||||
info("Starting firmware update coroutine")
|
||||
SoftwareUpdateService.doUpdate(this@MeshService, safe, filename)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ class SoftwareUpdateService : JobIntentService(), Logging {
|
|||
val deviceVersion =
|
||||
verStringToInt(if (swVer.isEmpty() || swVer == "unset") "99.99.99" else swVer)
|
||||
|
||||
(curVer > deviceVersion) && (deviceVersion >= minVer)
|
||||
// (curVer > deviceVersion) && (deviceVersion >= minVer)
|
||||
true
|
||||
} catch (ex: Exception) {
|
||||
errormsg("Error finding swupdate info", ex)
|
||||
false // If we fail parsing our update info
|
||||
|
|
@ -214,21 +215,11 @@ class SoftwareUpdateService : JobIntentService(), Logging {
|
|||
*/
|
||||
fun getUpdateFilename(
|
||||
context: Context,
|
||||
hwVerIn: String,
|
||||
swVer: String,
|
||||
mfg: String
|
||||
): String? {
|
||||
val curver = context.getString(R.string.cur_firmware_version)
|
||||
|
||||
val regionRegex = Regex(".+-(.+)")
|
||||
|
||||
val hwVer = if (hwVerIn.isEmpty() || hwVerIn == "unset")
|
||||
"1.0-US" else hwVerIn // lie and claim US, because that's what the device load will be doing without hwVer set
|
||||
|
||||
val (region) = regionRegex.find(hwVer)?.destructured
|
||||
?: throw Exception("Malformed hw version")
|
||||
|
||||
val base = "firmware-$mfg-$region-$curver.bin"
|
||||
val base = "firmware-$mfg-$curver.bin"
|
||||
|
||||
// Check to see if the file exists (some builds might not include update files for size reasons)
|
||||
val firmwareFiles = context.assets.list("firmware") ?: arrayOf()
|
||||
|
|
@ -239,24 +230,19 @@ class SoftwareUpdateService : JobIntentService(), Logging {
|
|||
}
|
||||
|
||||
/** Return the filename this device needs to use as an update (or null if no update needed)
|
||||
* No longer used, because we get update info inband from our radio API
|
||||
*/
|
||||
fun getUpdateFilename(context: Context, sync: SafeBluetooth): String? {
|
||||
val service = sync.gatt!!.services.find { it.uuid == SW_UPDATE_UUID }!!
|
||||
|
||||
val hwVerDesc = service.getCharacteristic(HW_VERSION_CHARACTER)
|
||||
//val hwVerDesc = service.getCharacteristic(HW_VERSION_CHARACTER)
|
||||
val mfgDesc = service.getCharacteristic(MANUFACTURE_CHARACTER)
|
||||
val swVerDesc = service.getCharacteristic(SW_VERSION_CHARACTER)
|
||||
|
||||
// looks like 1.0-US
|
||||
var hwVer = sync.readCharacteristic(hwVerDesc).getStringValue(0)
|
||||
//val swVerDesc = service.getCharacteristic(SW_VERSION_CHARACTER)
|
||||
|
||||
// looks like HELTEC
|
||||
val mfg = sync.readCharacteristic(mfgDesc).getStringValue(0)
|
||||
|
||||
// looks like 0.0.12
|
||||
val swVer = sync.readCharacteristic(swVerDesc).getStringValue(0)
|
||||
|
||||
return getUpdateFilename(context, hwVer, swVer, mfg)
|
||||
return getUpdateFilename(context, mfg)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
../../../../../meshtastic-esp32/release/latest/bins
|
||||
Loading…
Add table
Add a link
Reference in a new issue