- 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:
parent
3a1e5f5741
commit
32097ee8ad
|
@ -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.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -99,14 +100,16 @@ public abstract class RileyLinkCommunicationManager {
|
|||
rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam());
|
||||
|
||||
if (rfSpyResponse.wasTimeout()) {
|
||||
timeoutCount++;
|
||||
if (hasTunning()) {
|
||||
timeoutCount++;
|
||||
|
||||
long diff = System.currentTimeMillis() - pumpStatus.lastConnection;
|
||||
long diff = System.currentTimeMillis() - pumpStatus.lastConnection;
|
||||
|
||||
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
||||
LOG.warn("We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||
timeoutCount = 0;
|
||||
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
||||
LOG.warn("We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||
timeoutCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RileyLinkCommunicationException(RileyLinkBLEError.Timeout);
|
||||
|
@ -136,6 +139,10 @@ public abstract class RileyLinkCommunicationManager {
|
|||
return rfspy != null ? rfspy.notConnectedCount : 0;
|
||||
}
|
||||
|
||||
public boolean hasTunning() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// FIXME change wakeup
|
||||
// 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);
|
||||
}
|
||||
|
||||
public void setPumpStatus(PumpStatus pumpStatus) {
|
||||
this.pumpStatus = pumpStatus;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
return instance;
|
||||
}
|
||||
|
||||
public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
||||
delegate = new OmnipodManagerAAPS(communicationService, podState);
|
||||
public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) {
|
||||
delegate = new OmnipodManagerAAPS(communicationService, podState, pumpStatus);
|
||||
this.pumpStatus = pumpStatus;
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,11 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
|
|||
return new byte[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTunning() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) {
|
||||
return (E) new OmnipodPacket(payload);
|
||||
|
|
|
@ -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.PodInitReceiver;
|
||||
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.PodDbEntryType;
|
||||
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 OmnipodManagerAAPS(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
||||
public OmnipodManagerAAPS(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) {
|
||||
super(communicationService, podState);
|
||||
communicationService.setPumpStatus(pumpStatus);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
LOG.debug("RileyLinkOmnipodService newly constructed");
|
||||
OmnipodUtil.setOmnipodService(this);
|
||||
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());
|
||||
}
|
||||
}
|
||||
omnipodCommunicationManager = new AapsOmnipodManager(new OmnipodCommunicationService(rfspy), podState);
|
||||
omnipodCommunicationManager = new AapsOmnipodManager(new OmnipodCommunicationService(rfspy), podState, pumpStatus);
|
||||
} else {
|
||||
omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue