Merge branch 'omnipod_eros_dev' into omnipod_eros_dev_upstream_merge

This commit is contained in:
Bart Sopers 2020-12-23 00:45:54 +01:00
commit 1a137360c8
5 changed files with 30 additions and 12 deletions

View file

@ -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.OmnipodCustomCommand;
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.ui.OmnipodOverviewFragment;
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 PumpDescription pumpDescription;
private final ServiceConnection serviceConnection;
private final OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager;
private final PumpType pumpType = PumpType.Insulet_Omnipod;
private final CompositeDisposable disposables = new CompositeDisposable();
private final NSUpload nsUpload;
@ -175,7 +176,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
RileyLinkUtil rileyLinkUtil,
OmnipodAlertUtil omnipodAlertUtil,
ProfileFunction profileFunction,
NSUpload nsUpload
NSUpload nsUpload,
OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager
) {
super(new PluginDescription() //
.mainType(PluginType.PUMP) //
@ -202,6 +204,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
this.omnipodAlertUtil = omnipodAlertUtil;
this.profileFunction = profileFunction;
this.nsUpload = nsUpload;
this.omnipodRileyLinkCommunicationManager = omnipodRileyLinkCommunicationManager;
pumpDescription = new PumpDescription(pumpType);
@ -613,7 +616,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
@Override
public int getBatteryLevel() {
if (aapsOmnipodManager.isUseRileyLinkBatteryLevel()) {
return rileyLinkServiceData.batteryLevel == null ? 0 : rileyLinkServiceData.batteryLevel;
Integer batteryLevel = omnipodRileyLinkCommunicationManager.getBatteryLevel();
return batteryLevel == null ? 0 : batteryLevel;
}
return 0;

View file

@ -8,6 +8,7 @@ import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
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.RileyLinkBLEError;
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.message.MessageBlock;
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
public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunicationManager<OmnipodPacket> {
private Integer batteryLevel;
// This empty constructor must be kept, otherwise dagger injection might break!
@Inject
public OmnipodRileyLinkCommunicationManager() {
@ -81,6 +85,21 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
// 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) {
return sendCommand(responseClass, podStateManager, command, true);
}
@ -384,4 +403,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
throw new RileyLinkUnreachableException();
}
private void updateBatteryLevel() {
batteryLevel = rfspy.getBatteryLevel();
}
}

View file

@ -60,7 +60,7 @@ public class OmnipodPumpPluginTest {
OmnipodPumpPlugin plugin = new OmnipodPumpPlugin(injector, aapsLogger, rxBusWrapper, null,
resourceHelper, activePluginProvider, null, null, aapsOmnipodManager, commandQueueProvider,
null, null, null, null,
rileyLinkUtil, null, null, null
rileyLinkUtil, null, null, null, null
);
when(activePluginProvider.getActiveTreatments().getTempBasalFromHistory(anyLong())).thenReturn(null);
when(rileyLinkUtil.getRileyLinkHistory()).thenReturn(new ArrayList<>());

View file

@ -81,8 +81,6 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
RadioResponse radioResponse = rfSpyResponse.getRadioResponse(injector);
T response = createResponseMessage(radioResponse.getPayload());
updateBatteryLevel();
if (response.isValid()) {
// Mark this as the last time we heard from the pump.
rememberLastGoodDeviceCommunicationTime();
@ -118,10 +116,6 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
return response;
}
private void updateBatteryLevel() {
rileyLinkServiceData.batteryLevel = rfspy.getBatteryLevel();
}
public abstract T createResponseMessage(byte[] payload);

View file

@ -43,8 +43,6 @@ public class RileyLinkServiceData {
// radio version
public String versionCC110;
public Integer batteryLevel;
public RileyLinkTargetDevice targetDevice;
// Medtronic Pump