diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index f69257a7..44195e5c 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,6 +1,22 @@ + + diff --git a/app/build.gradle b/app/build.gradle index 4c6fe493..abf8e9bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -122,7 +122,7 @@ dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' // kotlin serialization - implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc" // rate this app implementation "com.vorlonsoft:androidrate:1.2.1" diff --git a/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt b/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt index d5582696..a2abf163 100644 --- a/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt +++ b/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt @@ -218,20 +218,20 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String /// Send a packet/command out the radio link - override fun handleSendToRadio(a: ByteArray) { + override fun handleSendToRadio(p: ByteArray) { try { safe?.let { s -> val uuid = BTM_TORADIO_CHARACTER - debug("queuing ${a.size} bytes to $uuid") + debug("queuing ${p.size} bytes to $uuid") // Note: we generate a new characteristic each time, because we are about to // change the data and we want the data stored in the closure val toRadio = getCharacteristic(uuid) - s.asyncWriteCharacteristic(toRadio, a) { r -> + s.asyncWriteCharacteristic(toRadio, p) { r -> try { r.getOrThrow() - debug("write of ${a.size} bytes to $uuid completed") + debug("write of ${p.size} bytes to $uuid completed") if (isFirstSend) { isFirstSend = false diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 3235da7e..d2e1808f 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -36,7 +36,6 @@ import com.google.protobuf.InvalidProtocolBufferException import kotlinx.coroutines.* import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonConfiguration import java.util.* import java.util.concurrent.TimeUnit import kotlin.math.absoluteValue @@ -558,8 +557,8 @@ class MeshService : Service(), Logging { nodeDB = nodeDBbyNodeNum.values.toTypedArray(), messages = recentDataPackets.toTypedArray() ) - val json = Json(JsonConfiguration.Default) - val asString = json.stringify(SavedSettings.serializer(), settings) + val json = Json { isLenient = true } + val asString = json.encodeToString(SavedSettings.serializer(), settings) debug("Saving settings") getPrefs().edit(commit = true) { // FIXME, not really ideal to store this bigish blob in preferences @@ -593,8 +592,8 @@ class MeshService : Service(), Logging { try { getPrefs().getString("json", null)?.let { asString -> - val json = Json(JsonConfiguration.Default) - val settings = json.parse(SavedSettings.serializer(), asString) + val json = Json { isLenient = true } + val settings = json.decodeFromString(SavedSettings.serializer(), asString) installNewNodeDB(settings.myInfo, settings.nodeDB) // Note: we do not haveNodeDB = true because that means we've got a valid db from a real device (rather than this possibly stale hint) @@ -866,7 +865,11 @@ class MeshService : Service(), Logging { } /// Update our DB of users based on someone sending out a Position subpacket - private fun handleReceivedPosition(fromNum: Int, p: MeshProtos.Position, defaultTime: Int = Position.currentTime()) { + private fun handleReceivedPosition( + fromNum: Int, + p: MeshProtos.Position, + defaultTime: Int = Position.currentTime() + ) { updateNodeInfo(fromNum) { it.position = Position(p) updateNodeInfoTime(it, defaultTime) diff --git a/build.gradle b/build.gradle index ca5347ab..70a2cdb5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.0' ext.coroutines_version = "1.3.9" repositories {