Don't rebind ruffy and retry command in case of failure.
RuffyService is now immeditately rebound when connection was lost, therefore retrying a command after blindly rebinding the service doesn't make sense anymore,more so given that ruffy is less prone to crashing now.
This commit is contained in:
parent
8178b6ff00
commit
f0d9f0e86a
|
@ -208,6 +208,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
ruffyScripter.stop();
|
ruffyScripter.stop();
|
||||||
log.debug("ruffy service disconnected");
|
log.debug("ruffy service disconnected");
|
||||||
|
// try to reconnect ruffy service unless unbind was explicitely requested
|
||||||
|
// via unbindRuffyService
|
||||||
if(!keepUnbound) {
|
if(!keepUnbound) {
|
||||||
SystemClock.sleep(250);
|
SystemClock.sleep(250);
|
||||||
bindRuffyService();
|
bindRuffyService();
|
||||||
|
@ -427,41 +429,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
|
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
CommandResult commandResult = ruffyScripter.runCommand(command);
|
||||||
// TODO extract this into a recovery method and check the logic of restarting and rebinding ruffy
|
|
||||||
if (!commandResult.success && commandResult.exception != null) {
|
|
||||||
log.error("CommandResult has exception, rebinding ruffy service", commandResult.exception);
|
|
||||||
|
|
||||||
// attempt to rebind the ruffy service, will start ruffy again if it crashed
|
|
||||||
try {
|
|
||||||
unbindRuffyService();
|
|
||||||
SystemClock.sleep(5000);
|
|
||||||
} catch (Exception e) {
|
|
||||||
/*String msg = "No connection to ruffy. Pump control not available.";
|
|
||||||
statusSummary = msg;
|
|
||||||
return new CommandResult().message(msg);*/
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
bindRuffyService();
|
|
||||||
SystemClock.sleep(5000);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String msg = "No connection to ruffy. Pump control not available.";
|
|
||||||
statusSummary = msg;
|
|
||||||
return new CommandResult().message(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ruffyScripter == null) {
|
|
||||||
log.error("Rebinding failed");
|
|
||||||
} else if (!commandResult.enacted && !(command instanceof BolusCommand)) {
|
|
||||||
// retry command, but make sure it wasn't enacted and don't retry
|
|
||||||
// bolus commands (user is interacting with AAPS right now so he can
|
|
||||||
// deal with it and we don't want to deliver a bolus twice)
|
|
||||||
CommandResult retriedCommandResult = ruffyScripter.runCommand(command);
|
|
||||||
if (retriedCommandResult.success) {
|
|
||||||
commandResult = retriedCommandResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug("RuffyScripter returned from command invocation, result: " + commandResult);
|
log.debug("RuffyScripter returned from command invocation, result: " + commandResult);
|
||||||
if (commandResult.exception != null) {
|
if (commandResult.exception != null) {
|
||||||
log.error("Exception received from pump", commandResult.exception);
|
log.error("Exception received from pump", commandResult.exception);
|
||||||
|
|
Loading…
Reference in a new issue