Fetch pump status after pairing

This commit is contained in:
TebbeUbben 2019-02-09 22:25:07 +01:00
parent baac836d64
commit 317f171286
4 changed files with 17 additions and 9 deletions

View file

@ -48,7 +48,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer
public void onServiceConnected(ComponentName name, IBinder binder) { public void onServiceConnected(ComponentName name, IBinder binder) {
connectionService = ((InsightConnectionService.LocalBinder) binder).getService(); connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
connectionService.registerStateCallback(InsightAlertService.this); connectionService.registerStateCallback(InsightAlertService.this);
stateChanged(connectionService.getState()); onStateChanged(connectionService.getState());
} }
@Override @Override
@ -114,7 +114,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer
} }
@Override @Override
public void stateChanged(InsightState state) { public void onStateChanged(InsightState state) {
if (state == InsightState.CONNECTED) { if (state == InsightState.CONNECTED) {
thread = new Thread(this::queryActiveAlert); thread = new Thread(this::queryActiveAlert);
thread.start(); thread.start();

View file

@ -41,6 +41,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L; 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.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
@ -1510,7 +1511,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
} }
@Override @Override
public void stateChanged(InsightState state) { public void onStateChanged(InsightState state) {
if (state == InsightState.CONNECTED) statusLoaded = false; if (state == InsightState.CONNECTED) statusLoaded = false;
else if (state == InsightState.NOT_PAIRED) { else if (state == InsightState.NOT_PAIRED) {
connectionService.withdrawConnectionRequest(this); 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())); new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI()));
} }
@Override
public void onPumpPaired() {
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Pump paired", null);
}
} }

View file

@ -21,7 +21,6 @@ import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -56,7 +55,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight
service.requestConnection(InsightPairingActivity.this); service.requestConnection(InsightPairingActivity.this);
service.registerStateCallback(InsightPairingActivity.this); service.registerStateCallback(InsightPairingActivity.this);
service.registerExceptionCallback(InsightPairingActivity.this); service.registerExceptionCallback(InsightPairingActivity.this);
stateChanged(service.getState()); onStateChanged(service.getState());
} }
} }
@ -116,7 +115,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight
} }
@Override @Override
public void stateChanged(InsightState state) { public void onStateChanged(InsightState state) {
runOnUiThread(() -> { runOnUiThread(() -> {
switch (state) { switch (state) {
case NOT_PAIRED: case NOT_PAIRED:

View file

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.logging.L; 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.AppLayerMessage;
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.ReadParameterBlockMessage; import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.ReadParameterBlockMessage;
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration.CloseConfigurationWriteSessionMessage; import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration.CloseConfigurationWriteSessionMessage;
@ -245,7 +244,7 @@ public class InsightConnectionService extends Service implements ConnectionEstab
wakeLock.release(); wakeLock.release();
else if (!wakeLock.isHeld()) wakeLock.acquire(); else if (!wakeLock.isHeld()) wakeLock.acquire();
this.state = state; this.state = state;
for (StateCallback stateCallback : stateCallbacks) stateCallback.stateChanged(state); for (StateCallback stateCallback : stateCallbacks) stateCallback.onStateChanged(state);
log.info("Insight state changed: " + state.name()); log.info("Insight state changed: " + state.name());
} }
@ -704,6 +703,7 @@ public class InsightConnectionService extends Service implements ConnectionEstab
pairingDataStorage.setPaired(true); pairingDataStorage.setPaired(true);
log.info("Pairing completed YEE-HAW ♪ ┏(・o・)┛ ♪ ┗( ・o・)┓ ♪"); log.info("Pairing completed YEE-HAW ♪ ┏(・o・)┛ ♪ ┗( ・o・)┓ ♪");
setState(InsightState.CONNECTED); setState(InsightState.CONNECTED);
for (StateCallback stateCallback : stateCallbacks) stateCallback.onPumpPaired();
} }
} else processGenericAppLayerMessage(message); } else processGenericAppLayerMessage(message);
} }
@ -771,7 +771,10 @@ public class InsightConnectionService extends Service implements ConnectionEstab
} }
public interface StateCallback { public interface StateCallback {
void stateChanged(InsightState state); void onStateChanged(InsightState state);
default void onPumpPaired() {
}
} }
public interface ExceptionCallback { public interface ExceptionCallback {