diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/InsightAlertService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/InsightAlertService.java index 9122132de8..dbedf83867 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/InsightAlertService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/InsightAlertService.java @@ -48,7 +48,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer public void onServiceConnected(ComponentName name, IBinder binder) { connectionService = ((InsightConnectionService.LocalBinder) binder).getService(); connectionService.registerStateCallback(InsightAlertService.this); - stateChanged(connectionService.getState()); + onStateChanged(connectionService.getState()); } @Override @@ -114,7 +114,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer } @Override - public void stateChanged(InsightState state) { + public void onStateChanged(InsightState state) { if (state == InsightState.CONNECTED) { thread = new Thread(this::queryActiveAlert); thread.start(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java index 5fc3ac3f0b..e13894ecd3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java @@ -41,6 +41,7 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; @@ -1510,7 +1511,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con } @Override - public void stateChanged(InsightState state) { + public void onStateChanged(InsightState state) { if (state == InsightState.CONNECTED) statusLoaded = false; else if (state == InsightState.NOT_PAIRED) { connectionService.withdrawConnectionRequest(this); @@ -1527,4 +1528,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con } new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI())); } + + @Override + public void onPumpPaired() { + ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Pump paired", null); + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/activities/InsightPairingActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/activities/InsightPairingActivity.java index 390e9a233e..f97a74e94a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/activities/InsightPairingActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/activities/InsightPairingActivity.java @@ -21,7 +21,6 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; -import android.widget.Toast; import java.util.ArrayList; import java.util.List; @@ -56,7 +55,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight service.requestConnection(InsightPairingActivity.this); service.registerStateCallback(InsightPairingActivity.this); service.registerExceptionCallback(InsightPairingActivity.this); - stateChanged(service.getState()); + onStateChanged(service.getState()); } } @@ -116,7 +115,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight } @Override - public void stateChanged(InsightState state) { + public void onStateChanged(InsightState state) { runOnUiThread(() -> { switch (state) { case NOT_PAIRED: diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/connection_service/InsightConnectionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/connection_service/InsightConnectionService.java index b4ee726a6b..bb086a541e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/connection_service/InsightConnectionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/connection_service/InsightConnectionService.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import info.nightscout.androidaps.logging.L; -import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.BolusProgressReporter; import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage; import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.ReadParameterBlockMessage; import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration.CloseConfigurationWriteSessionMessage; @@ -245,7 +244,7 @@ public class InsightConnectionService extends Service implements ConnectionEstab wakeLock.release(); else if (!wakeLock.isHeld()) wakeLock.acquire(); this.state = state; - for (StateCallback stateCallback : stateCallbacks) stateCallback.stateChanged(state); + for (StateCallback stateCallback : stateCallbacks) stateCallback.onStateChanged(state); log.info("Insight state changed: " + state.name()); } @@ -704,6 +703,7 @@ public class InsightConnectionService extends Service implements ConnectionEstab pairingDataStorage.setPaired(true); log.info("Pairing completed YEE-HAW ♪ ┏(・o・)┛ ♪ ┗( ・o・)┓ ♪"); setState(InsightState.CONNECTED); + for (StateCallback stateCallback : stateCallbacks) stateCallback.onPumpPaired(); } } else processGenericAppLayerMessage(message); } @@ -771,7 +771,10 @@ public class InsightConnectionService extends Service implements ConnectionEstab } public interface StateCallback { - void stateChanged(InsightState state); + void onStateChanged(InsightState state); + default void onPumpPaired() { + + } } public interface ExceptionCallback {