Add method RuffyCommands.isConnected().

This commit is contained in:
Johannes Mockenhaupt 2017-11-14 22:57:23 +01:00
parent 7c662345ae
commit 51d242a3fb
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 18 additions and 1 deletions

View file

@ -23,6 +23,9 @@ public interface RuffyCommands {
/** Indicate of the pump is busy processing a command. */
boolean isPumpBusy();
/** Whether there's an active BT connection to the pump. */
boolean isConnected();
/** Read the state of the pump, which encompasses all information displayed on the main menu. */
CommandResult readPumpState();

View file

@ -68,6 +68,11 @@ public class RuffyCommandsV1Impl implements RuffyCommands {
return delegate.isPumpBusy();
}
@Override
public boolean isConnected() {
return delegate.isConnected();
}
@Override
public CommandResult readPumpState() {
return delegate.readPumpState();

View file

@ -203,6 +203,15 @@ public class RuffyScripter implements RuffyCommands {
return activeCmd != null;
}
@Override
public boolean isConnected() {
try {
return ruffyService.isConnected();
} catch (RemoteException e) {
return false;
}
}
@Override
public CommandResult readPumpState() {
return runCommand(new ReadPumpStateCommand());
@ -485,7 +494,7 @@ public class RuffyScripter implements RuffyCommands {
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
} else if (menuType == MenuType.WARNING_OR_ERROR) {
state.alertCodes = readWarningOrErrorCode();
state.activeAlert = readWarningOrErrorCode();
} else if (menuType == MenuType.STOP) {
state.suspended = true;
state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));