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.
This commit is contained in:
parent
a28efb4be0
commit
cb8a22582a
1 changed files with 10 additions and 3 deletions
|
@ -294,8 +294,11 @@ public class RuffyScripter {
|
||||||
log.debug("Connect init successful: " + connectInitSuccessful);
|
log.debug("Connect init successful: " + connectInitSuccessful);
|
||||||
while (currentMenu == null) {
|
while (currentMenu == null) {
|
||||||
log.debug("Waiting for first menu update to be sent");
|
log.debug("Waiting for first menu update to be sent");
|
||||||
// waitForMenuUpdate times out after 60s and throws a CommandException
|
// waitForMenuUpdate times out after 60s and throws a CommandException.
|
||||||
waitForMenuUpdate();
|
// 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) {
|
} catch (RemoteException e) {
|
||||||
throw new CommandException().exception(e).message("Unexpected exception while initiating/restoring pump connection");
|
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
|
* Wait until the menu update is in
|
||||||
*/
|
*/
|
||||||
public void waitForMenuUpdate() {
|
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;
|
long initialUpdateTime = menuLastUpdated;
|
||||||
while (initialUpdateTime == menuLastUpdated) {
|
while (initialUpdateTime == menuLastUpdated) {
|
||||||
if (System.currentTimeMillis() > timeoutExpired) {
|
if (System.currentTimeMillis() > timeoutExpired) {
|
||||||
|
|
Loading…
Reference in a new issue