From 4ba7acc307974a21ddc2388dad44827e70d29825 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 9 Jun 2020 07:46:19 -0700 Subject: [PATCH] don't filter devices that are not currently connected --- .../mesh/service/RadioInterfaceService.kt | 18 +++++++++++++++++- .../geeksville/mesh/service/SerialInterface.kt | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt b/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt index f76d67ca0..2ca2afabf 100644 --- a/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/RadioInterfaceService.kt @@ -68,7 +68,7 @@ class RadioInterfaceService : Service(), Logging { * and t is an interface specific address (macaddr or a device path) */ @SuppressLint("NewApi") - fun getBondedDeviceAddress(context: Context): String? { + fun getDeviceAddress(context: Context): String? { // If the user has unpaired our device, treat things as if we don't have one val prefs = getPrefs(context) var address = prefs.getString(DEVADDR_KEY, null) @@ -79,6 +79,22 @@ class RadioInterfaceService : Service(), Logging { address = "x$rest" // Add the bluetooth prefix } + return address + } + + + /** Like getDeviceAddress, but filtered to return only devices we are currently bonded with + * + * at + * + * where a is either x for bluetooth or s for serial + * and t is an interface specific address (macaddr or a device path) + */ + @SuppressLint("NewApi") + fun getBondedDeviceAddress(context: Context): String? { + // If the user has unpaired our device, treat things as if we don't have one + var address = getDeviceAddress(context) + /// Interfaces can filter addresses to indicate that address is no longer acceptable if (address != null) { val c = address[0] diff --git a/app/src/main/java/com/geeksville/mesh/service/SerialInterface.kt b/app/src/main/java/com/geeksville/mesh/service/SerialInterface.kt index f6ae01018..be21ec11b 100644 --- a/app/src/main/java/com/geeksville/mesh/service/SerialInterface.kt +++ b/app/src/main/java/com/geeksville/mesh/service/SerialInterface.kt @@ -65,12 +65,12 @@ class SerialInterface(private val service: RadioInterfaceService, val address: S connection port.open(connection) - port.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) + port.setParameters(921600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) uart = port debug("Starting serial reader thread") val io = SerialInputOutputManager(port, this) - io.readTimeout = 500 // To save battery we only timeout every 500ms + io.readTimeout = 200 // To save battery we only timeout ever so often ioManager = io Executors.newSingleThreadExecutor().submit(io);