Merge branch 'master' into feature/offline-maps

This commit is contained in:
Jackson Rosenthal 2022-03-12 17:10:59 -05:00
commit b42149de05
25 changed files with 80 additions and 61 deletions

View file

@ -72,7 +72,7 @@ jobs:
run: |
rm -rf ./app/src/main/assets/firmware
mkdir -p ./app/src/main/assets/firmware
unzip -qq ./firmware.zip 'spiffs-*.bin' 'firmware-heltec*.bin' 'firmware-tbeam*.bin' 'firmware-tlora*.bin' -d ./app/src/main/assets/firmware
unzip -qq ./firmware.zip 'littlefs-*.bin' 'firmware-heltec*.bin' 'firmware-tbeam*.bin' 'firmware-tlora*.bin' -d ./app/src/main/assets/firmware
rm ./firmware.zip
- name: Validate Gradle wrapper

View file

@ -43,8 +43,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 30 // 30 can't work until an explicit location permissions dialog is added
versionCode 20258 // format is Mmmss (where M is 1+the numeric major number
versionName "1.2.58"
versionCode 20303 // format is Mmmss (where M is 1+the numeric major number
versionName "1.3.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// per https://developer.android.com/studio/write/vector-asset-studio
@ -122,8 +122,6 @@ protobuf {
dependencies {
def room_version = '2.4.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
@ -134,13 +132,12 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation "androidx.room:room-runtime:$room_version"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "androidx.room:room-compiler:$room_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"
@ -161,14 +158,14 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
// For now I'm not using javalite, because I want JSON printing
implementation('com.google.protobuf:protobuf-java:3.15.8')
implementation 'com.google.protobuf:protobuf-java:3.15.8'
// For UART access
// implementation 'com.google.android.things:androidthings:1.0'
implementation 'com.github.mik3y:usb-serial-for-android:3.4.3'
// mapbox
implementation('com.mapbox.maps:android:10.2.0')
implementation 'com.mapbox.maps:android:10.2.0'
// mapbox specifies a really old version of okhttp3 which causes lots of API warnings. trying a newer version
implementation 'com.squareup.okhttp3:okhttp:4.9.0'

View file

@ -105,7 +105,7 @@ class MeshService : Service(), Logging {
/** The minimmum firmware version we know how to talk to. We'll still be able to talk to 1.0 firmwares but only well enough to ask them to firmware update
*/
val minFirmwareVersion = DeviceVersion("1.2.0")
val minFirmwareVersion = DeviceVersion("1.3.0")
}
enum class ConnectionState {
@ -1304,13 +1304,14 @@ class MeshService : Service(), Logging {
myInfo.myNodeNum // Note: can't use the normal property because myNodeInfo not yet setup
val ni = nodeDBbyNodeNum[nodeNum] // can't use toNodeInfo because too early
val hwModelStr = ni?.user?.hwModelString
setFirmwareUpdateFilename(hwModelStr)
val mi = with(myInfo) {
MyNodeInfo(
myNodeNum,
hasGps,
hwModelStr,
firmwareVersion,
firmwareUpdateFilename != null,
firmwareUpdateFilename?.appLoad != null && firmwareUpdateFilename?.littlefs != null,
isBluetoothInterface && SoftwareUpdateService.shouldUpdate(
this@MeshService,
DeviceVersion(firmwareVersion)
@ -1323,9 +1324,7 @@ class MeshService : Service(), Logging {
airUtilTx
)
}
newMyNodeInfo = mi
setFirmwareUpdateFilename(mi)
}
}
@ -1531,7 +1530,7 @@ class MeshService : Service(), Logging {
try {
val mi = myNodeInfo
if (mi != null) {
debug("Sending our position/time to=$destNum lat=$lat, lon=$lon, alt=$alt")
debug("Sending our position/time to=$destNum lat=${lat.anonymize}, lon=${lon.anonymize}, alt=$alt")
val position = MeshProtos.Position.newBuilder().also {
it.longitudeI = Position.degI(lon)
@ -1641,12 +1640,12 @@ class MeshService : Service(), Logging {
/***
* Return the filename we will install on the device
*/
private fun setFirmwareUpdateFilename(info: MyNodeInfo) {
private fun setFirmwareUpdateFilename(model: String?) {
firmwareUpdateFilename = try {
if (info.firmwareVersion != null && info.model != null)
if (model != null)
SoftwareUpdateService.getUpdateFilename(
this,
info.model
model
)
else
null

View file

@ -70,7 +70,7 @@ fun toNetworkByteArray(value: Int, formatType: Int): ByteArray {
}
data class UpdateFilenames(val appLoad: String?, val spiffs: String?)
data class UpdateFilenames(val appLoad: String?, val littlefs: String?)
/**
* typical flow
@ -172,7 +172,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
private val SW_UPDATE_RESULT_CHARACTER =
UUID.fromString("5e134862-7411-4424-ac4a-210937432c77") // read|notify result code, readable but will notify when the OTA operation completes
private val SW_UPDATE_REGION_CHARACTER =
UUID.fromString("5e134862-7411-4424-ac4a-210937432c67") // write - used to set the region we are setting (appload vs spiffs)
UUID.fromString("5e134862-7411-4424-ac4a-210937432c67") // write - used to set the region we are setting (appload vs littlefs)
private val SW_VERSION_CHARACTER = longBLEUUID("2a28")
private val MANUFACTURE_CHARACTER = longBLEUUID("2a29")
@ -208,11 +208,11 @@ class SoftwareUpdateService : JobIntentService(), Logging {
/**
* Update our progress indication for GUIs
*
* @param isAppload if false, we don't report failure indications (because we consider spiffs non critical for now). But do report to analytics
* @param isAppload if false, we don't report failure indications (because we consider littlefs non critical for now). But do report to analytics
*/
fun sendProgress(context: Context, p: Int, isAppload: Boolean) {
if (!isAppload && p < 0)
errormsg("Error while writing spiffs $p") // treat errors writing spiffs as non fatal for now (user partition probably missized and most people don't need it)
errormsg("Error while writing littlefs $p") // treat errors writing littlefs as non fatal for now (user partition probably missized and most people don't need it)
else
if (progress != p) {
progress = p
@ -243,7 +243,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
false // If we fail parsing our update info
}
/** Return a Pair of apploadfilename, spiffs filename this device needs to use as an update (or null if no update needed)
/** Return a Pair of appload filename, littlefs filename this device needs to use as an update (or null if no update needed)
*/
fun getUpdateFilename(
context: Context,
@ -255,15 +255,15 @@ class SoftwareUpdateService : JobIntentService(), Logging {
val firmwareFiles = context.assets.list("firmware") ?: arrayOf()
val appLoad = "firmware-$mfg-$curVer.bin"
val spiffs = "spiffs-$curVer.bin"
val littlefs = "littlefs-$curVer.bin"
return UpdateFilenames(
if (firmwareFiles.contains(appLoad))
"firmware/$appLoad"
else
null,
if (firmwareFiles.contains(spiffs))
"firmware/$spiffs"
if (firmwareFiles.contains(littlefs))
"firmware/$littlefs"
else
null
)
@ -290,24 +290,30 @@ class SoftwareUpdateService : JobIntentService(), Logging {
* you can use it for the software update.
*/
fun doUpdate(context: Context, sync: SafeBluetooth, assets: UpdateFilenames) {
// we must attempt spiffs first, because if we update the appload the device will reboot afterwards
// calculate total firmware size (littlefs + appLoad)
var totalFirmwareSize = 0
if (assets.appLoad != null && assets.littlefs != null) {
totalFirmwareSize += context.assets.open(assets.appLoad).available()
totalFirmwareSize += context.assets.open(assets.littlefs).available()
}
// we must attempt littlefs first, because if we update the appload the device will reboot afterwards
try {
assets.spiffs?.let { doUpdate(context, sync, it, FLASH_REGION_SPIFFS) }
assets.littlefs?.let { doUpdate(context, sync, it, FLASH_REGION_LITTLEFS, totalFirmwareSize) }
} catch (_: BLECharacteristicNotFoundException) {
// If we can't update spiffs (because not supported by target), do not fail
errormsg("Ignoring failure to update spiffs on old appload")
// If we can't update littlefs (because not supported by target), do not fail
errormsg("Ignoring failure to update littlefs on old appload")
} catch (_: DeviceRejectedException) {
// the spi filesystem of this device is malformatted, fail silently because most users don't need the web server
errormsg("Device rejected invalid spiffs partition")
errormsg("Device rejected invalid littlefs partition")
}
assets.appLoad?.let { doUpdate(context, sync, it, FLASH_REGION_APPLOAD) }
assets.appLoad?.let { doUpdate(context, sync, it, FLASH_REGION_APPLOAD, totalFirmwareSize) }
sendProgress(context, ProgressSuccess, true)
}
// writable region codes in the ESP32 update code
private val FLASH_REGION_APPLOAD = 0
private val FLASH_REGION_SPIFFS = 100
private val FLASH_REGION_LITTLEFS = 100
/**
* A public function so that if you have your own SafeBluetooth connection already open
@ -317,7 +323,8 @@ class SoftwareUpdateService : JobIntentService(), Logging {
context: Context,
sync: SafeBluetooth,
assetName: String,
flashRegion: Int = FLASH_REGION_APPLOAD
flashRegion: Int = FLASH_REGION_APPLOAD,
totalFirmwareSize: Int = 0
) {
val isAppload = flashRegion == FLASH_REGION_APPLOAD
@ -341,9 +348,9 @@ class SoftwareUpdateService : JobIntentService(), Logging {
val crc32Desc = getCharacteristic(SW_UPDATE_CRC32_CHARACTER)
val updateResultDesc = getCharacteristic(SW_UPDATE_RESULT_CHARACTER)
/// Try to set the destination region for programming (spiffs vs appload etc)
/// Try to set the destination region for programming (littlefs vs appload etc)
/// Old apploads don't have this feature, but we only fail if the user was trying to set a
/// spiffs - otherwise we assume appload.
/// littlefs - otherwise we assume appload.
try {
val updateRegionDesc = getCharacteristic(SW_UPDATE_REGION_CHARACTER)
sync.writeCharacteristic(
@ -378,13 +385,15 @@ class SoftwareUpdateService : JobIntentService(), Logging {
// Send all the blocks
var oldProgress = -1 // used to limit # of log spam
while (firmwareNumSent < firmwareSize) {
// If we are doing the spiffs partition, we limit progress to a max of 50%, so that the user doesn't think we are done
// yet
val maxProgress = if (flashRegion != FLASH_REGION_APPLOAD)
50 else 100
// If we are doing the littlefs partition, we limit progress to a max of maxProgress
// when updating the appload partition, progress from (100 - maxProgress) to 100%
// maxProgress = littlefs% = 100% - appLoad%; (int * 10 + 5) / 10 used for rounding
val maxProgress = ((firmwareSize * 1000 / totalFirmwareSize) + 5) / 10
val minProgress = if (flashRegion != FLASH_REGION_APPLOAD)
0 else (100 - maxProgress)
sendProgress(
context,
firmwareNumSent * maxProgress / firmwareSize,
minProgress + firmwareNumSent * maxProgress / firmwareSize,
isAppload
)
if (progress != oldProgress) {

View file

@ -24,6 +24,7 @@ import android.widget.*
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import com.geeksville.analytics.DataPair
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.android.hideKeyboard
@ -474,6 +475,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
model.meshService?.let { service ->
debug("User started firmware update")
GeeksvilleApplication.analytics.track(
"firmware_update",
DataPair("content_type", "start")
)
binding.updateFirmwareButton.isEnabled = false // Disable until things complete
binding.updateProgressBar.visibility = View.VISIBLE
binding.updateProgressBar.progress = 0 // start from scratch
@ -515,6 +520,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
} else
when (progress) {
ProgressSuccess -> {
GeeksvilleApplication.analytics.track(
"firmware_update",
DataPair("content_type", "success")
)
binding.scanStatusText.setText(R.string.update_successful)
binding.updateProgressBar.visibility = View.GONE
}
@ -523,6 +532,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
binding.updateProgressBar.visibility = View.GONE
}
else -> {
GeeksvilleApplication.analytics.track(
"firmware_update",
DataPair("content_type", "failure")
)
binding.scanStatusText.setText(R.string.update_failed)
binding.updateProgressBar.visibility = View.VISIBLE
}

View file

@ -48,7 +48,7 @@
<string name="share">Sdílet</string>
<string name="disconnected">Odpojeno</string>
<string name="device_sleeping">Zařízení spí</string>
<string name="connected_count">Pripojeno: %s z %s je online</string>
<string name="connected_count">Pripojeno: %1$s z %2$s je online</string>
<string name="list_of_nodes">Seznam vysílačů v síti</string>
<string name="update_firmware">Aktualizace softwaru</string>
<string name="connected_to">Připojeno k vysílači (%s)</string>

View file

@ -48,7 +48,7 @@
<string name="share">Κοινοποίηση</string>
<string name="disconnected">Αποσυνδεδεμένο</string>
<string name="device_sleeping">Συσκευή σε ύπνωση</string>
<string name="connected_count">Συνδεδεμένος: %s από %s online</string>
<string name="connected_count">Συνδεδεμένος: %1$s από %2$s online</string>
<string name="list_of_nodes">Λίστα κόμβων δικτύου</string>
<string name="update_firmware">Αναβάθμιση Firmware</string>
<string name="connected">Συνδεδεμένο στο radio</string>

View file

@ -45,7 +45,7 @@
<string name="share">Compartir</string>
<string name="disconnected">Desconectado</string>
<string name="device_sleeping">Dispositivo en reposo</string>
<string name="connected_count">Conectado: %s de %s en línea</string>
<string name="connected_count">Conectado: %1$s de %2$s en línea</string>
<string name="list_of_nodes">Una lista de nodos en la red</string>
<string name="update_firmware">Actualizar el firmware</string>
<string name="connected">Conectado a la radio</string>

View file

@ -49,7 +49,7 @@
<string name="share">Partager</string>
<string name="disconnected">Déconnecté</string>
<string name="device_sleeping">Appareil en veille</string>
<string name="connected_count">Connecté: %s sur %s en ligne</string>
<string name="connected_count">Connecté: %1$s sur %2$s en ligne</string>
<string name="list_of_nodes">Une liste de nœuds dans le réseau</string>
<string name="update_firmware">Mise à jour du Firmware</string>
<string name="connected">Connecté à une radio</string>

View file

@ -46,7 +46,7 @@
<string name="share">Pataje</string>
<string name="disconnected">Dekonekte</string>
<string name="device_sleeping">Aparèy ap dòmi</string>
<string name="connected_count">Konekte: %s nan %s disponib</string>
<string name="connected_count">Konekte: %1$s nan %2$s disponib</string>
<string name="list_of_nodes">Yon lis ne elektwonik nan rezo a</string>
<string name="update_firmware">Mete ajou mikrolojisyèl</string>
<string name="connected">Konekte ak radyo</string>

View file

@ -47,7 +47,7 @@
<string name="share">Megosztás</string>
<string name="disconnected">Szétkapcsolva</string>
<string name="device_sleeping">Az eszköz alszik</string>
<string name="connected_count">Kapcsolódva: %s a %s-ból(ből) elérhető</string>
<string name="connected_count">Kapcsolódva: %1$s a %2$s-ból(ből) elérhető</string>
<string name="list_of_nodes">Hálózati állomások listája</string>
<string name="update_firmware">Firmware frissítés</string>
<string name="connected">Kapcsolódva a rádióhoz</string>

View file

@ -48,7 +48,7 @@ mapboxの有償プランまたは代替地図プロバイダを検討さ
<string name="share">シェア</string>
<string name="disconnected">切断</string>
<string name="device_sleeping">スリープ</string>
<string name="connected_count">接続済み:%s人オンライン%s人中</string>
<string name="connected_count">接続済み:%1$s人オンライン%2$s人中</string>
<string name="list_of_nodes">ネットワーク内のノードリスト</string>
<string name="update_firmware">ファームウェアアップデート</string>
<string name="connected_to">Meshtasticデバイスに接続しました。(%s)</string>

View file

@ -46,7 +46,7 @@
<string name="share">공유</string>
<string name="disconnected">연결 해제</string>
<string name="device_sleeping">장치 잠자기</string>
<string name="connected_count">연결: %s 온라인( 전체 %s)</string>
<string name="connected_count">연결: %1$s 온라인( 전체 %2$s)</string>
<string name="list_of_nodes">네트워크안은 모든 노드의 목록</string>
<string name="update_firmware">펌웨어 업데이트</string>
<string name="connected">라디오로 연결됨</string>

View file

@ -48,7 +48,7 @@
<string name="share">Deel</string>
<string name="disconnected">Niet verbonden</string>
<string name="device_sleeping">Apparaat in slaapstand</string>
<string name="connected_count">Verbonden: %s van %s online</string>
<string name="connected_count">Verbonden: %1$s van %2$s online</string>
<string name="list_of_nodes">Een lijst van de aansluitpunten in het netwerk</string>
<string name="update_firmware">Programma Updaten</string>
<string name="connected">Verbonden met een radio</string>

View file

@ -48,7 +48,7 @@
<string name="share">Del</string>
<string name="disconnected">Frakoblet</string>
<string name="device_sleeping">Enhet sover</string>
<string name="connected_count">Tilkoblet: %s av %s på nett</string>
<string name="connected_count">Tilkoblet: %1$s av %2$s på nett</string>
<string name="list_of_nodes">En liste over noder i nettverket</string>
<string name="update_firmware">Oppdater Firmware</string>
<string name="connected">Tilkoblet radio</string>

View file

@ -53,7 +53,7 @@
<string name="share">Udostępnij</string>
<string name="disconnected">Rozłączone</string>
<string name="device_sleeping">Urządzenie uśpione.</string>
<string name="connected_count">Połączono: %s of %s online</string>
<string name="connected_count">Połączono: %1$s of %2$s online</string>
<string name="list_of_nodes">Lista użytkowników w sieci</string>
<string name="update_firmware">Aktualizuj oprogramowanie.</string>
<string name="connected">Połączony z urządzeniem</string>

View file

@ -48,7 +48,7 @@
<string name="share">Compartilhar</string>
<string name="disconnected">Desconectado</string>
<string name="device_sleeping">Dispositivo em suspensão (sleep)</string>
<string name="connected_count">Conectado: %s de %s online</string>
<string name="connected_count">Conectado: %1$s de %2$s online</string>
<string name="list_of_nodes">Lista de dispositivos na rede</string>
<string name="update_firmware">Atualizar Firmware</string>
<string name="connected">Conectado ao rádio</string>

View file

@ -47,7 +47,7 @@
<string name="share">Partilha</string>
<string name="disconnected">Desconectado</string>
<string name="device_sleeping">Dispositivo a dormir</string>
<string name="connected_count">Conectado: %s de %s online</string>
<string name="connected_count">Conectado: %1$s de %2$s online</string>
<string name="list_of_nodes">Lista de nós na rede</string>
<string name="update_firmware">Atualizar Firmware</string>
<string name="connected">Conectado ao rádio</string>

View file

@ -48,7 +48,7 @@
<string name="share">Distribuie</string>
<string name="disconnected">Deconectat</string>
<string name="device_sleeping">Dispozitiv în sleep mode</string>
<string name="connected_count">Connectat: %s din %s online</string>
<string name="connected_count">Connectat: %1$s din %2$s online</string>
<string name="list_of_nodes">O lista cu nodurile din rețea</string>
<string name="update_firmware">Updateaza firmware-ul</string>
<string name="connected">Connectat la dispozitiv</string>

View file

@ -48,7 +48,7 @@
<string name="share">Zdieľať</string>
<string name="disconnected">Odpojené</string>
<string name="device_sleeping">Vysielač uspatý</string>
<string name="connected_count">Pripojený: %s z %s je online</string>
<string name="connected_count">Pripojený: %1$s z %2$s je online</string>
<string name="list_of_nodes">Zoznam vysielačov v sieti</string>
<string name="update_firmware">Aktualizácia firmvéru</string>
<string name="connected">Pripojené k vysielaču</string>

View file

@ -46,7 +46,7 @@
<string name="share">Deliti</string>
<string name="disconnected">Prekinjeno</string>
<string name="device_sleeping">Naprava je v "spanju"</string>
<string name="connected_count">Povezano: %s od %s je na mreži</string>
<string name="connected_count">Povezano: %1$s od %2$s je na mreži</string>
<string name="list_of_nodes">Seznam vozlišč v omrežju</string>
<string name="update_firmware">Posodobite vdelano programsko opremo</string>
<string name="connected">Povezana z radiem</string>

View file

@ -48,7 +48,7 @@
<string name="share">Paylaş</string>
<string name="disconnected">Bağlantı sonlandı</string>
<string name="device_sleeping">Cihaz uyku durumunda</string>
<string name="connected_count">Bağlandı: %s / %s online</string>
<string name="connected_count">Bağlandı: %1$s / %2$s online</string>
<string name="list_of_nodes">Ağdaki node listesi</string>
<string name="update_firmware">Yazılım güncelle</string>
<string name="connected">Radyoya bağlandı</string>

View file

@ -48,7 +48,7 @@
<string name="share">分享</string>
<string name="disconnected">断开连接</string>
<string name="device_sleeping">设备休眠中</string>
<string name="connected_count">连接: %s 中 %s 在线</string>
<string name="connected_count">连接: %1$s 中 %2$s 在线</string>
<string name="list_of_nodes">网络中节点列表</string>
<string name="update_firmware">更新固件</string>
<string name="connected">连接设备</string>

View file

@ -52,7 +52,7 @@
<string name="share">Share</string>
<string name="disconnected">Disconnected</string>
<string name="device_sleeping">Device sleeping</string>
<string name="connected_count">Connected: %s of %s online</string>
<string name="connected_count">Connected: %1$s of %2$s online</string>
<string name="list_of_nodes">A list of nodes in the network</string>
<string name="update_firmware">Update Firmware</string>
<string name="connected">Connected to radio</string>

View file

@ -2,7 +2,8 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.coroutines_version = "1.5.2"
ext.coroutines_version = '1.6.0'
ext.room_version = '2.4.2'
ext.hilt_version = '2.40.5'
repositories {
@ -10,7 +11,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"