From 5f4a90d068609c0152a1386476a4718c99202f0e Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 17 Dec 2017 10:27:07 +0100 Subject: [PATCH] Explicit disconnect during recovery. BT connection might still be there, but no menu updates coming in. Thus, explicitely close the connection before attempting to reconnect. --- .../main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index d54097e18d..3aa5d3d40a 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -282,8 +282,14 @@ public class RuffyScripter implements RuffyCommands { // on connection loss try to reconnect, confirm warning alerts caused by // the disconnected and then return the command as failed (the caller // can retry if needed). + log.debug("Connection unusable, aborting command and attempting reconnect ..."); cmdThread.interrupt(); activeCmd.getResult().success = false; + + // the BT connection might be still there, but we might not be receiving + // menu updates, so force a disconnect before connecting again + disconnect(); + SystemClock.sleep(500); for (int attempts = 2; attempts > 0; attempts--) { boolean reconnected = recoverFromConnectionLoss(); if (reconnected) {