diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/RuffyCommands.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/RuffyCommands.java index dd15ea867c..88e4b0da02 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/RuffyCommands.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/RuffyCommands.java @@ -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(); diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyCommandsV1Impl.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyCommandsV1Impl.java index 1be00a5e69..d788c7fade 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyCommandsV1Impl.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyCommandsV1Impl.java @@ -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(); diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 3fa8fd6d8c..4bbc892dc2 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -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));