- Fix NPE : pumpStatus not set in RileyLinkCommunicationManager

- added possibility to disable tunning (not supported for Omnipod, but required for Medtronic)
This commit is contained in:
Andy Rozman 2019-11-24 20:32:53 +00:00
parent 3a1e5f5741
commit 32097ee8ad
5 changed files with 29 additions and 10 deletions

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
/** /**
@ -99,6 +100,7 @@ public abstract class RileyLinkCommunicationManager {
rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam()); rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam());
if (rfSpyResponse.wasTimeout()) { if (rfSpyResponse.wasTimeout()) {
if (hasTunning()) {
timeoutCount++; timeoutCount++;
long diff = System.currentTimeMillis() - pumpStatus.lastConnection; long diff = System.currentTimeMillis() - pumpStatus.lastConnection;
@ -108,6 +110,7 @@ public abstract class RileyLinkCommunicationManager {
ServiceTaskExecutor.startTask(new WakeAndTuneTask()); ServiceTaskExecutor.startTask(new WakeAndTuneTask());
timeoutCount = 0; timeoutCount = 0;
} }
}
throw new RileyLinkCommunicationException(RileyLinkBLEError.Timeout); throw new RileyLinkCommunicationException(RileyLinkBLEError.Timeout);
} else if (rfSpyResponse.wasInterrupted()) { } else if (rfSpyResponse.wasInterrupted()) {
@ -136,6 +139,10 @@ public abstract class RileyLinkCommunicationManager {
return rfspy != null ? rfspy.notConnectedCount : 0; return rfspy != null ? rfspy.notConnectedCount : 0;
} }
public boolean hasTunning() {
return true;
}
// FIXME change wakeup // FIXME change wakeup
// TODO we might need to fix this. Maybe make pump awake for shorter time (battery factor for pump) - Andy // TODO we might need to fix this. Maybe make pump awake for shorter time (battery factor for pump) - Andy
@ -449,4 +456,7 @@ public abstract class RileyLinkCommunicationManager {
return L.isEnabled(L.PUMPCOMM); return L.isEnabled(L.PUMPCOMM);
} }
public void setPumpStatus(PumpStatus pumpStatus) {
this.pumpStatus = pumpStatus;
}
} }

View file

@ -24,8 +24,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
return instance; return instance;
} }
public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) { public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) {
delegate = new OmnipodManagerAAPS(communicationService, podState); delegate = new OmnipodManagerAAPS(communicationService, podState, pumpStatus);
this.pumpStatus = pumpStatus;
instance = this; instance = this;
} }

View file

@ -58,6 +58,11 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
return new byte[0]; return new byte[0];
} }
@Override
public boolean hasTunning() {
return false;
}
@Override @Override
public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) { public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) {
return (E) new OmnipodPacket(payload); return (E) new OmnipodPacket(payload);

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunication
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntry; import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntry;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntryType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntryType;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged; import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
@ -26,8 +27,9 @@ import info.nightscout.androidaps.utils.SP;
public class OmnipodManagerAAPS extends OmnipodManager //implements OmnipodCommunicationManagerInterface public class OmnipodManagerAAPS extends OmnipodManager //implements OmnipodCommunicationManagerInterface
{ {
public OmnipodManagerAAPS(OmnipodCommunicationService communicationService, PodSessionState podState) { public OmnipodManagerAAPS(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) {
super(communicationService, podState); super(communicationService, podState);
communicationService.setPumpStatus(pumpStatus);
} }

View file

@ -55,6 +55,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
LOG.debug("RileyLinkOmnipodService newly constructed"); LOG.debug("RileyLinkOmnipodService newly constructed");
OmnipodUtil.setOmnipodService(this); OmnipodUtil.setOmnipodService(this);
pumpStatus = (OmnipodPumpStatus) OmnipodPumpPlugin.getPlugin().getPumpStatusData(); pumpStatus = (OmnipodPumpStatus) OmnipodPumpPlugin.getPlugin().getPumpStatusData();
//LOG.debug("RRRRRRRRRR: " + pumpStatus);
} }
@ -124,7 +125,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
LOG.error("Could not deserialize Pod state: " + ex.getClass().getSimpleName() + ": " + ex.getMessage()); LOG.error("Could not deserialize Pod state: " + ex.getClass().getSimpleName() + ": " + ex.getMessage());
} }
} }
omnipodCommunicationManager = new AapsOmnipodManager(new OmnipodCommunicationService(rfspy), podState); omnipodCommunicationManager = new AapsOmnipodManager(new OmnipodCommunicationService(rfspy), podState, pumpStatus);
} else { } else {
omnipodCommunicationManager = AapsOmnipodManager.getInstance(); omnipodCommunicationManager = AapsOmnipodManager.getInstance();
} }