From 92621e07aa3978e0aa56692c31437109d730b83b Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 15 Aug 2020 11:19:23 -0700 Subject: [PATCH] don't spam autobugs if we get an exception reading fromnum when the device is leaving --- .../mesh/service/BluetoothInterface.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 eb256d149..d5582696d 100644 --- a/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt +++ b/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt @@ -176,7 +176,9 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String /// Our BLE device - val device get() = safe?.gatt ?: throw RadioNotConnectedException("No GATT") + val device + get() = (safe ?: throw RadioNotConnectedException("No SafeBluetooth")).gatt + ?: throw RadioNotConnectedException("No GATT") /// Our service - note - it is possible to get back a null response for getService if the device services haven't yet been found val bservice @@ -314,10 +316,15 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String fromNumChanged = true debug("fromNum changed") service.serviceScope.handledLaunch { - if (fromNumChanged) { - fromNumChanged = false - debug("fromNum changed, so we are reading new messages") - doReadFromRadio(false) + try { + if (fromNumChanged) { + fromNumChanged = false + debug("fromNum changed, so we are reading new messages") + doReadFromRadio(false) + } + } catch (e: RadioNotConnectedException) { + // Don't report autobugs for this, getting an exception here is expected behavior + errormsg("Ending FromNum read, radio not connected", e) } } }