don't filter devices that are not currently connected

This commit is contained in:
geeksville 2020-06-09 07:46:19 -07:00
parent e3a082c168
commit 4ba7acc307
2 changed files with 19 additions and 3 deletions

View file

@ -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]

View file

@ -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);