From 9e83bfd790012a2e9e8c07c772e16b945fac14e1 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 4 Feb 2020 16:06:33 -0800 Subject: [PATCH] disable sim and switch back to protobuf lite --- TODO.md | 4 ++-- app/build.gradle | 8 +++---- .../geeksville/mesh/RadioInterfaceService.kt | 21 ++++++++----------- .../mesh/{SimRadio.kt => SimRadio.disabled} | 0 4 files changed, 15 insertions(+), 18 deletions(-) rename app/src/main/java/com/geeksville/mesh/{SimRadio.kt => SimRadio.disabled} (100%) diff --git a/TODO.md b/TODO.md index 42dfd5a50..f1800864f 100644 --- a/TODO.md +++ b/TODO.md @@ -31,8 +31,6 @@ * remove mixpanel analytics * require user auth to pair with the device (i.e. press button on device to allow a new phone to pair with it). Don't leave device discoverable. Don't let unpaired users do things with device -* remove example code boilerplate from the service -* switch from protobuf-java to protobuf-javalite - much faster and smaller, just no JSON debug printing * if the rxpacket queue on the device overflows (because android hasn't connected in a while) send a special packet to android which means 'X packets have been dropped because you were offline' -drop oldest packets first # Low priority @@ -69,3 +67,5 @@ Don't leave device discoverable. Don't let unpaired users do things with device * implement android side of mesh radio bluetooth link * use the lora net code on my current protoboard * investigate a 16 bit node number. If possible it would make collisions super rare. Much easier to just pick a nodenum and go. +* remove example code boilerplate from the service +* switch from protobuf-java to protobuf-javalite - much faster and smaller, just no JSON debug printing diff --git a/app/build.gradle b/app/build.gradle index 3b1125e73..ca6e61c45 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ protobuf { task.builtins { java { // turned off for now so I can use json printing - // option "lite" + option "lite" } } } @@ -74,9 +74,9 @@ dependencies { // You need to depend on the lite runtime library, not protobuf-java // For now I'm not using javalite, because I want JSON printing - implementation 'com.google.protobuf:protobuf-java:3.11.1' - implementation 'com.google.protobuf:protobuf-java-util:3.11.1' - // implementation 'com.google.protobuf:protobuf-javalite:3.11.1' + //implementation 'com.google.protobuf:protobuf-java:3.11.1' + //implementation 'com.google.protobuf:protobuf-java-util:3.11.1' + implementation 'com.google.protobuf:protobuf-javalite:3.11.1' // You also need to include the following Compose toolkit dependencies. implementation("androidx.compose:compose-runtime:$compose_version") diff --git a/app/src/main/java/com/geeksville/mesh/RadioInterfaceService.kt b/app/src/main/java/com/geeksville/mesh/RadioInterfaceService.kt index f042c8c79..9d5ec0c9e 100644 --- a/app/src/main/java/com/geeksville/mesh/RadioInterfaceService.kt +++ b/app/src/main/java/com/geeksville/mesh/RadioInterfaceService.kt @@ -8,11 +8,10 @@ import android.bluetooth.BluetoothManager import android.content.Context import android.content.Intent import android.os.IBinder -import com.geeksville.android.DebugLogFile +import com.geeksville.android.BinaryLogFile import com.geeksville.android.Logging import com.geeksville.concurrent.DeferredExecution import com.geeksville.util.toRemoteExceptions -import com.google.protobuf.util.JsonFormat import java.util.* /* Info for the esp32 device side code. See that source for the 'gold' standard docs on this interface. @@ -138,10 +137,7 @@ class RadioInterfaceService : Service(), Logging { private lateinit var fromRadio: BluetoothGattCharacteristic private lateinit var fromNum: BluetoothGattCharacteristic - lateinit var sentPacketsLog: DebugLogFile // inited in onCreate - - // for debug logging only - private val jsonPrinter = JsonFormat.printer() + lateinit var sentPacketsLog: BinaryLogFile // inited in onCreate private var isConnected = false @@ -160,11 +156,12 @@ class RadioInterfaceService : Service(), Logging { private fun handleSendToRadio(p: ByteArray) { // For debugging/logging purposes ONLY we convert back into a protobuf for readability - val proto = MeshProtos.ToRadio.parseFrom(p) + // al proto = MeshProtos.ToRadio.parseFrom(p) - val json = jsonPrinter.print(proto).replace('\n', ' ') - info("TODO sending to radio: $json") - sentPacketsLog.log(json) + debug("sending to radio") + doWrite(BTM_TORADIO_CHARACTER, p) + sentPacketsLog.write(p) + sentPacketsLog.flush() } // Handle an incoming packet from the radio, broadcasts it as an android intent @@ -242,7 +239,7 @@ class RadioInterfaceService : Service(), Logging { } } - sentPacketsLog = DebugLogFile(this, "sent_log.json") + sentPacketsLog = BinaryLogFile(this, "sent_log.pb") } override fun onDestroy() { @@ -301,7 +298,7 @@ class RadioInterfaceService : Service(), Logging { override fun readMyNode() = doRead(BTM_MYNODE_CHARACTER)!! - override fun sendToRadio(a: ByteArray) = doWrite(BTM_TORADIO_CHARACTER, a) + override fun sendToRadio(a: ByteArray) = handleSendToRadio(a) override fun readRadioConfig() = doRead(BTM_RADIO_CHARACTER)!! diff --git a/app/src/main/java/com/geeksville/mesh/SimRadio.kt b/app/src/main/java/com/geeksville/mesh/SimRadio.disabled similarity index 100% rename from app/src/main/java/com/geeksville/mesh/SimRadio.kt rename to app/src/main/java/com/geeksville/mesh/SimRadio.disabled