Merge branch 'omnipod_eros_dev' into omnipod_eros_dev_upstream_merge
This commit is contained in:
commit
1a137360c8
|
@ -90,6 +90,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandPlay
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandUpdateAlertConfiguration;
|
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandUpdateAlertConfiguration;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommandType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.service.RileyLinkOmnipodService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.service.RileyLinkOmnipodService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment;
|
import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil;
|
||||||
|
@ -137,8 +138,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
private final DateUtil dateUtil;
|
private final DateUtil dateUtil;
|
||||||
private final PumpDescription pumpDescription;
|
private final PumpDescription pumpDescription;
|
||||||
private final ServiceConnection serviceConnection;
|
private final ServiceConnection serviceConnection;
|
||||||
|
private final OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager;
|
||||||
private final PumpType pumpType = PumpType.Insulet_Omnipod;
|
private final PumpType pumpType = PumpType.Insulet_Omnipod;
|
||||||
|
|
||||||
private final CompositeDisposable disposables = new CompositeDisposable();
|
private final CompositeDisposable disposables = new CompositeDisposable();
|
||||||
private final NSUpload nsUpload;
|
private final NSUpload nsUpload;
|
||||||
|
|
||||||
|
@ -175,7 +176,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
RileyLinkUtil rileyLinkUtil,
|
RileyLinkUtil rileyLinkUtil,
|
||||||
OmnipodAlertUtil omnipodAlertUtil,
|
OmnipodAlertUtil omnipodAlertUtil,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
NSUpload nsUpload
|
NSUpload nsUpload,
|
||||||
|
OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription() //
|
super(new PluginDescription() //
|
||||||
.mainType(PluginType.PUMP) //
|
.mainType(PluginType.PUMP) //
|
||||||
|
@ -202,6 +204,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
this.omnipodAlertUtil = omnipodAlertUtil;
|
this.omnipodAlertUtil = omnipodAlertUtil;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
this.nsUpload = nsUpload;
|
this.nsUpload = nsUpload;
|
||||||
|
this.omnipodRileyLinkCommunicationManager = omnipodRileyLinkCommunicationManager;
|
||||||
|
|
||||||
pumpDescription = new PumpDescription(pumpType);
|
pumpDescription = new PumpDescription(pumpType);
|
||||||
|
|
||||||
|
@ -613,7 +616,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryLevel() {
|
public int getBatteryLevel() {
|
||||||
if (aapsOmnipodManager.isUseRileyLinkBatteryLevel()) {
|
if (aapsOmnipodManager.isUseRileyLinkBatteryLevel()) {
|
||||||
return rileyLinkServiceData.batteryLevel == null ? 0 : rileyLinkServiceData.batteryLevel;
|
Integer batteryLevel = omnipodRileyLinkCommunicationManager.getBatteryLevel();
|
||||||
|
return batteryLevel == null ? 0 : batteryLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
|
@ -15,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLink
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.OmnipodAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.OmnipodAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.MessageBlock;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.MessageBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage;
|
||||||
|
@ -50,6 +52,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateMa
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunicationManager<OmnipodPacket> {
|
public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunicationManager<OmnipodPacket> {
|
||||||
|
private Integer batteryLevel;
|
||||||
|
|
||||||
// This empty constructor must be kept, otherwise dagger injection might break!
|
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||||
@Inject
|
@Inject
|
||||||
public OmnipodRileyLinkCommunicationManager() {
|
public OmnipodRileyLinkCommunicationManager() {
|
||||||
|
@ -81,6 +85,21 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
|
||||||
// We don't use PumpDeviceState in the Omnipod driver
|
// We don't use PumpDeviceState in the Omnipod driver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override protected OmnipodPacket sendAndListen(OmnipodPacket msg, int timeout_ms, int repeatCount, int retryCount, Integer extendPreamble_ms) throws RileyLinkCommunicationException {
|
||||||
|
OmnipodPacket response = super.sendAndListen(msg, timeout_ms, repeatCount, retryCount, extendPreamble_ms);
|
||||||
|
|
||||||
|
PumpInterface activePump = activePluginProvider.getActivePump();
|
||||||
|
if (activePump instanceof OmnipodPumpPlugin && ((OmnipodPumpPlugin) activePump).isUseRileyLinkBatteryLevel()) {
|
||||||
|
updateBatteryLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBatteryLevel() {
|
||||||
|
return batteryLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public <T extends MessageBlock> T sendCommand(Class<T> responseClass, PodStateManager podStateManager, MessageBlock command) {
|
public <T extends MessageBlock> T sendCommand(Class<T> responseClass, PodStateManager podStateManager, MessageBlock command) {
|
||||||
return sendCommand(responseClass, podStateManager, command, true);
|
return sendCommand(responseClass, podStateManager, command, true);
|
||||||
}
|
}
|
||||||
|
@ -384,4 +403,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
|
||||||
throw new RileyLinkUnreachableException();
|
throw new RileyLinkUnreachableException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBatteryLevel() {
|
||||||
|
batteryLevel = rfspy.getBatteryLevel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class OmnipodPumpPluginTest {
|
||||||
OmnipodPumpPlugin plugin = new OmnipodPumpPlugin(injector, aapsLogger, rxBusWrapper, null,
|
OmnipodPumpPlugin plugin = new OmnipodPumpPlugin(injector, aapsLogger, rxBusWrapper, null,
|
||||||
resourceHelper, activePluginProvider, null, null, aapsOmnipodManager, commandQueueProvider,
|
resourceHelper, activePluginProvider, null, null, aapsOmnipodManager, commandQueueProvider,
|
||||||
null, null, null, null,
|
null, null, null, null,
|
||||||
rileyLinkUtil, null, null, null
|
rileyLinkUtil, null, null, null, null
|
||||||
);
|
);
|
||||||
when(activePluginProvider.getActiveTreatments().getTempBasalFromHistory(anyLong())).thenReturn(null);
|
when(activePluginProvider.getActiveTreatments().getTempBasalFromHistory(anyLong())).thenReturn(null);
|
||||||
when(rileyLinkUtil.getRileyLinkHistory()).thenReturn(new ArrayList<>());
|
when(rileyLinkUtil.getRileyLinkHistory()).thenReturn(new ArrayList<>());
|
||||||
|
|
|
@ -81,8 +81,6 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
|
||||||
RadioResponse radioResponse = rfSpyResponse.getRadioResponse(injector);
|
RadioResponse radioResponse = rfSpyResponse.getRadioResponse(injector);
|
||||||
T response = createResponseMessage(radioResponse.getPayload());
|
T response = createResponseMessage(radioResponse.getPayload());
|
||||||
|
|
||||||
updateBatteryLevel();
|
|
||||||
|
|
||||||
if (response.isValid()) {
|
if (response.isValid()) {
|
||||||
// Mark this as the last time we heard from the pump.
|
// Mark this as the last time we heard from the pump.
|
||||||
rememberLastGoodDeviceCommunicationTime();
|
rememberLastGoodDeviceCommunicationTime();
|
||||||
|
@ -118,10 +116,6 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBatteryLevel() {
|
|
||||||
rileyLinkServiceData.batteryLevel = rfspy.getBatteryLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public abstract T createResponseMessage(byte[] payload);
|
public abstract T createResponseMessage(byte[] payload);
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ public class RileyLinkServiceData {
|
||||||
// radio version
|
// radio version
|
||||||
public String versionCC110;
|
public String versionCC110;
|
||||||
|
|
||||||
public Integer batteryLevel;
|
|
||||||
|
|
||||||
public RileyLinkTargetDevice targetDevice;
|
public RileyLinkTargetDevice targetDevice;
|
||||||
|
|
||||||
// Medtronic Pump
|
// Medtronic Pump
|
||||||
|
|
Loading…
Reference in a new issue