From cb8a22582ab6ea8d394d28ba4959aeea490417ce Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 20 Jul 2017 18:28:39 +0200 Subject: [PATCH] Wait up to 90s before timing out on connection attempt. Might take longer if we need to wait for the pump display to time out due to recent user activity. --- .../java/de/jotomo/ruffyscripter/RuffyScripter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 4c76abeea5..c6e2ca29f1 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -294,8 +294,11 @@ public class RuffyScripter { log.debug("Connect init successful: " + connectInitSuccessful); while (currentMenu == null) { log.debug("Waiting for first menu update to be sent"); - // waitForMenuUpdate times out after 60s and throws a CommandException - waitForMenuUpdate(); + // waitForMenuUpdate times out after 60s and throws a CommandException. + // if the user just pressed a button on the combo, the screen needs to time first + // before a connection is possible. In that case, it takes 45s before the + // connection comes up. + waitForMenuUpdate(90); } } catch (RemoteException e) { throw new CommandException().exception(e).message("Unexpected exception while initiating/restoring pump connection"); @@ -343,7 +346,11 @@ public class RuffyScripter { * Wait until the menu update is in */ public void waitForMenuUpdate() { - long timeoutExpired = System.currentTimeMillis() + 60 * 1000; + waitForMenuUpdate(60); + } + + public void waitForMenuUpdate(long timeoutInSeconds) { + long timeoutExpired = System.currentTimeMillis() + timeoutInSeconds * 1000; long initialUpdateTime = menuLastUpdated; while (initialUpdateTime == menuLastUpdated) { if (System.currentTimeMillis() > timeoutExpired) {