Fix bug in alert configurations

This commit is contained in:
Bart Sopers 2019-12-08 17:16:04 +01:00
parent 2132bf1675
commit 680a3922b8
5 changed files with 11 additions and 13 deletions

View file

@ -26,7 +26,6 @@ public class InsertCannulaService {
public StatusResponse executeExpirationRemindersAlertCommand(OmnipodCommunicationService communicationService, public StatusResponse executeExpirationRemindersAlertCommand(OmnipodCommunicationService communicationService,
PodSessionState podState) { PodSessionState podState) {
AlertConfiguration lowReservoirAlertConfiguration = AlertConfigurationFactory.createLowReservoirAlertConfiguration(OmnipodConst.LOW_RESERVOIR_ALERT); AlertConfiguration lowReservoirAlertConfiguration = AlertConfigurationFactory.createLowReservoirAlertConfiguration(OmnipodConst.LOW_RESERVOIR_ALERT);
DateTime endOfServiceTime = podState.getActivatedAt().plus(OmnipodConst.SERVICE_DURATION); DateTime endOfServiceTime = podState.getActivatedAt().plus(OmnipodConst.SERVICE_DURATION);

View file

@ -63,8 +63,8 @@ public class AlertConfiguration {
encodedData = ByteUtil.concat(encodedData, ByteUtil.getBytesFromInt16(durationInMinutes)); encodedData = ByteUtil.concat(encodedData, ByteUtil.getBytesFromInt16(durationInMinutes));
} }
encodedData = ByteUtil.concat(encodedData, beepType.getValue());
encodedData = ByteUtil.concat(encodedData, beepRepeat.getValue()); encodedData = ByteUtil.concat(encodedData, beepRepeat.getValue());
encodedData = ByteUtil.concat(encodedData, beepType.getValue());
return encodedData; return encodedData;
} }

View file

@ -5,12 +5,12 @@ import org.joda.time.Duration;
public class AlertConfigurationFactory { public class AlertConfigurationFactory {
public static AlertConfiguration createLowReservoirAlertConfiguration(Double units) { public static AlertConfiguration createLowReservoirAlertConfiguration(Double units) {
return new AlertConfiguration(AlertType.LOW_RESERVOIR_ALERT, AlertSlot.SLOT4, true, false, Duration.ZERO, return new AlertConfiguration(AlertType.LOW_RESERVOIR_ALERT, AlertSlot.SLOT4, true, false, Duration.ZERO,
new UnitsRemainingAlertTrigger(units), BeepType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, BeepRepeat.EVERY_15_MINUTES); new UnitsRemainingAlertTrigger(units), BeepType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, BeepRepeat.EVERY_MINUTE_FOR_3_MINUTES_REPEAT_EVERY_60_MINUTES);
} }
public static AlertConfiguration createExpirationAdvisoryAlertConfiguration(Duration timeUntilAlert, Duration duration) { public static AlertConfiguration createExpirationAdvisoryAlertConfiguration(Duration timeUntilAlert, Duration duration) {
return new AlertConfiguration(AlertType.EXPIRATION_ADVISORY_ALERT, AlertSlot.SLOT7, true, false, duration, return new AlertConfiguration(AlertType.EXPIRATION_ADVISORY_ALERT, AlertSlot.SLOT7, true, false, duration,
new TimerAlertTrigger(timeUntilAlert), BeepType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, BeepRepeat.EVERY_60_MINUTES); new TimerAlertTrigger(timeUntilAlert), BeepType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, BeepRepeat.EVERY_MINUTE_FOR_3_MINUTES_REPEAT_EVERY_15_MINUTES);
} }
public static AlertConfiguration createShutdownImminentAlertConfiguration(Duration timeUntilAlert) { public static AlertConfiguration createShutdownImminentAlertConfiguration(Duration timeUntilAlert) {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
import android.text.TextUtils; import android.text.TextUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
@ -92,9 +93,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
sendEvent(new EventOmnipodAcknowledgeAlertsChanged()); sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
} }
} else { } else {
if (pumpStatus.ackAlertsAvailable) { if (pumpStatus.ackAlertsAvailable || StringUtils.isNotEmpty(pumpStatus.ackAlertsText)) {
pumpStatus.ackAlertsText = null;
pumpStatus.ackAlertsAvailable = false; pumpStatus.ackAlertsAvailable = false;
sendEvent(new EventOmnipodAcknowledgeAlertsChanged()); sendEvent(new EventOmnipodAcknowledgeAlertsChanged());
} }
} }

View file

@ -20,8 +20,6 @@ import static org.junit.Assert.assertArrayEquals;
public class ConfigureAlertsCommandTest { public class ConfigureAlertsCommandTest {
@Test @Test
public void testEncoding() { public void testEncoding() {
// from https://github.com/ps2/rileylink_ios/blob/master/OmniKitTests/MessageTests.swift
Duration softExpirationTime = Duration.standardHours(72).minus(Duration.standardMinutes(1)); Duration softExpirationTime = Duration.standardHours(72).minus(Duration.standardMinutes(1));
AlertConfiguration alertConfiguration1 = new AlertConfiguration( // AlertConfiguration alertConfiguration1 = new AlertConfiguration( //
AlertType.EXPIRATION_ADVISORY_ALERT, AlertType.EXPIRATION_ADVISORY_ALERT,
@ -34,7 +32,7 @@ public class ConfigureAlertsCommandTest {
BeepRepeat.EVERY_MINUTE_FOR_15_MINUTES); BeepRepeat.EVERY_MINUTE_FOR_15_MINUTES);
assertArrayEquals( // assertArrayEquals( //
ByteUtil.fromHexString("79a410df0502"), // ByteUtil.fromHexString("79a410df0205"), //
alertConfiguration1.getRawData()); alertConfiguration1.getRawData());
Duration hardExpirationTime = Duration.standardHours(79).minus(Duration.standardMinutes(1)); Duration hardExpirationTime = Duration.standardHours(79).minus(Duration.standardMinutes(1));
@ -49,7 +47,7 @@ public class ConfigureAlertsCommandTest {
BeepRepeat.EVERY_MINUTE_FOR_15_MINUTES); BeepRepeat.EVERY_MINUTE_FOR_15_MINUTES);
assertArrayEquals( // assertArrayEquals( //
ByteUtil.fromHexString("280012830602"), // ByteUtil.fromHexString("280012830206"), //
alertConfiguration2.getRawData()); alertConfiguration2.getRawData());
AlertConfiguration alertConfiguration3 = new AlertConfiguration( // AlertConfiguration alertConfiguration3 = new AlertConfiguration( //
@ -71,7 +69,7 @@ public class ConfigureAlertsCommandTest {
Arrays.asList(alertConfiguration1, alertConfiguration2, alertConfiguration3)); Arrays.asList(alertConfiguration1, alertConfiguration2, alertConfiguration3));
assertArrayEquals( // assertArrayEquals( //
ByteUtil.fromHexString("1916feb6268b79a410df0502280012830602020f00000202"), // ByteUtil.fromHexString("1916feb6268b79a410df0205280012830206020f00000202"), //
configureAlertsCommand.getRawData()); configureAlertsCommand.getRawData());
} }
@ -84,8 +82,8 @@ public class ConfigureAlertsCommandTest {
false, // false, //
Duration.ZERO, // Duration.ZERO, //
new UnitsRemainingAlertTrigger(10.0), // new UnitsRemainingAlertTrigger(10.0), //
BeepType.BEEP_BEEP_BEEP_BEEP, // BeepType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, //
BeepRepeat.EVERY_MINUTE_FOR_15_MINUTES); BeepRepeat.EVERY_MINUTE_FOR_3_MINUTES_REPEAT_EVERY_60_MINUTES);
ConfigureAlertsCommand configureAlertsCommand = new ConfigureAlertsCommand( // ConfigureAlertsCommand configureAlertsCommand = new ConfigureAlertsCommand( //
0xae01a66c, // 0xae01a66c, //