diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 92c41cda19..318c37b2dd 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -124,16 +124,16 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, private final CompositeDisposable disposables = new CompositeDisposable(); // variables for handling statuses and history - protected boolean firstRun = true; - protected boolean hasTimeDateOrTimeZoneChanged = false; - protected boolean displayConnectionMessages = false; + private boolean firstRun = true; + private boolean hasTimeDateOrTimeZoneChanged = false; + private final boolean displayConnectionMessages = false; private RileyLinkOmnipodService rileyLinkOmnipodService; private boolean busy = false; private int timeChangeRetries; private long nextPodCheck; private boolean sentIdToFirebase; private long lastConnectionTimeMillis; - private Handler loopHandler = new Handler(); + private final Handler loopHandler = new Handler(); private final Runnable statusChecker; @@ -858,8 +858,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, this.firstRun = false; } - @NonNull - protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) { + @NonNull private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) { PumpEnactResult result = executeCommand(OmnipodCommandType.SetBolus, () -> aapsOmnipodManager.bolus(detailedBolusInfo)); if (result.success) { @@ -893,7 +892,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, sp.putLong(statsKey, currentCount); } - protected TemporaryBasal readTBR() { + private TemporaryBasal readTBR() { return activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis()); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java index 721dfede6a..ad103b69e6 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java @@ -9,7 +9,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; public class RLHistoryItemOmnipod extends RLHistoryItem { - private OmnipodCommandType omnipodCommandType; + private final OmnipodCommandType omnipodCommandType; public RLHistoryItemOmnipod(OmnipodCommandType omnipodCommandType) { super(new LocalDateTime(), RLHistoryItemSource.OmnipodCommand, RileyLinkTargetDevice.Omnipod); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java index bf4cf9d60e..1f689bd807 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.definition; import info.nightscout.androidaps.plugins.pump.omnipod.R; public class OmnipodStorageKeys { - static final String Prefix = "AAPS.Omnipod."; + private static final String Prefix = "AAPS.Omnipod."; public static class Prefs { public static final String PodState = Prefix + "pod_state"; @@ -17,7 +17,7 @@ public class OmnipodStorageKeys { } public static class Statistics { - public static final String StatsPrefix = "omnipod_"; + static final String StatsPrefix = "omnipod_"; public static final String TBRsSet = StatsPrefix + "tbrs_set"; public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered"; public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered"; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java index c56711e3d2..1007c18cbc 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java @@ -40,7 +40,7 @@ public enum PodHistoryEntryType { UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry); private int code; - private static Map instanceMap; + private static final Map instanceMap; @StringRes private int resourceId; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/MessageBlock.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/MessageBlock.java index ce248597f4..8cfb0277f2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/MessageBlock.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/MessageBlock.java @@ -8,7 +8,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Message public abstract class MessageBlock { protected byte[] encodedData = new byte[0]; - public MessageBlock() { + protected MessageBlock() { } public abstract MessageBlockType getType(); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/response/podinfo/PodInfo.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/response/podinfo/PodInfo.java index dbadfc9ab1..4a65b678cb 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/response/podinfo/PodInfo.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/response/podinfo/PodInfo.java @@ -5,7 +5,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfo public abstract class PodInfo { private final byte[] encodedData; - public PodInfo(byte[] encodedData) { + PodInfo(byte[] encodedData) { this.encodedData = encodedData; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertSlot.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertSlot.java index 3233e0098f..194f5f940b 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertSlot.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertSlot.java @@ -10,7 +10,7 @@ public enum AlertSlot { SLOT6((byte) 0x06), SLOT7((byte) 0x07); - private byte value; + private final byte value; AlertSlot(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertTrigger.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertTrigger.java index 1e9fdacd08..d2835388f7 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertTrigger.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/AlertTrigger.java @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.definition; -public abstract class AlertTrigger { - protected T value; +abstract class AlertTrigger { + private final T value; - public AlertTrigger(T value) { + AlertTrigger(T value) { this.value = value; } @@ -11,4 +11,3 @@ public abstract class AlertTrigger { return value; } } - diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepConfigType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepConfigType.java index 8ff2b4f6a1..00f91a0af7 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepConfigType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepConfigType.java @@ -19,7 +19,7 @@ public enum BeepConfigType { FIVE_SECONDS_BEEP((byte) 0xE), // can only be used if Pod is currently suspended NO_BEEP((byte) 0xF); - private byte value; + private final byte value; BeepConfigType(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepRepeat.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepRepeat.java index 42bb38abb0..3cf34bc247 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepRepeat.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepRepeat.java @@ -11,7 +11,7 @@ public enum BeepRepeat { EVERY_15_MINUTES_DELAYED((byte) 0x07), EVERY_5_MINUTES((byte) 0x08); - private byte value; + private final byte value; BeepRepeat(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepType.java index 606fe9af7d..17bbc855b2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/BeepType.java @@ -12,7 +12,7 @@ public enum BeepType { BIP_BIP_BIP_BIP_BIP_BIP((byte) 0x07), BEEEP_BEEEP((byte) 0x08); - private byte value; + private final byte value; BeepType(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryStatus.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryStatus.java index 800d4594cd..ad10439019 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryStatus.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryStatus.java @@ -8,7 +8,7 @@ public enum DeliveryStatus { BOLUS_IN_PROGRESS((byte) 0x05), BOLUS_AND_TEMP_BASAL((byte) 0x06); - private byte value; + private final byte value; DeliveryStatus(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryType.java index 110fa356fc..b0e80105f4 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/DeliveryType.java @@ -6,7 +6,7 @@ public enum DeliveryType { TEMP_BASAL((byte) 0x02), BOLUS((byte) 0x04); - private byte value; + private final byte value; DeliveryType(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/FaultEventCode.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/FaultEventCode.java index b916da88cf..a6fac508db 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/FaultEventCode.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/FaultEventCode.java @@ -122,7 +122,7 @@ public enum FaultEventCode { BAD_STATE_IN_MAYBE_INC_33_D((byte) 0x97), VALUES_DO_NOT_MATCH_OR_ARE_GREATER_THAN_0_X_97((byte) 0x98); - private byte value; + private final byte value; FaultEventCode(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/LogEventErrorCode.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/LogEventErrorCode.java index 9d4df96339..eb7223b4f0 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/LogEventErrorCode.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/LogEventErrorCode.java @@ -7,7 +7,7 @@ public enum LogEventErrorCode { INTERNAL_2_BIT_VARIABLE_SET_AND_MANIPULATED_IN_MAIN_LOOP_ROUTINES_3((byte) 0x03), INSULIN_STATE_TABLE_CORRUPTION((byte) 0x04); - private byte value; + private final byte value; LogEventErrorCode(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/MessageBlockType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/MessageBlockType.java index 06386fa57f..16002aa343 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/MessageBlockType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/MessageBlockType.java @@ -27,7 +27,7 @@ public enum MessageBlockType { BEEP_CONFIG(0x1e), CANCEL_DELIVERY(0x1f); - private byte value; + private final byte value; MessageBlockType(int value) { this.value = (byte) value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/OmnipodCrc.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/OmnipodCrc.java index c1ba0ca3a1..ebc461ee9a 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/OmnipodCrc.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/OmnipodCrc.java @@ -36,7 +36,7 @@ public class OmnipodCrc { 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 }; - public static final int[] crc8lookup = new int[]{ + private static final int[] crc8lookup = new int[]{ 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PacketType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PacketType.java index 59a18308be..cfc3bff947 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PacketType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PacketType.java @@ -7,7 +7,7 @@ public enum PacketType { CON((byte) 0b100), ACK((byte) 0b010); - private byte value; + private final byte value; PacketType(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PodProgressStatus.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PodProgressStatus.java index e0a547c260..9da2916997 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PodProgressStatus.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/PodProgressStatus.java @@ -18,7 +18,7 @@ public enum PodProgressStatus { ACTIVATION_TIME_EXCEEDED((byte) 0x0e), // Took > 2 hours from progress 2 to 3 or > 1 hour from 3 to 8 INACTIVE((byte) 0x0f); // Pod deactivated or a fatal packet state error - private byte value; + private final byte value; PodProgressStatus(byte value) { this.value = value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalDeliveryTable.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalDeliveryTable.java index 744b052451..df1c4161ec 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalDeliveryTable.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalDeliveryTable.java @@ -15,7 +15,7 @@ public class BasalDeliveryTable { private static final int NUM_SEGMENTS = 48; private static final int MAX_SEGMENTS_PER_ENTRY = 16; - private List entries = new ArrayList<>(); + private final List entries = new ArrayList<>(); public BasalDeliveryTable(BasalSchedule schedule) { TempSegment[] expandedSegments = new TempSegment[48]; @@ -97,14 +97,14 @@ public class BasalDeliveryTable { '}'; } - private class TempSegment { - private int pulses; + private static class TempSegment { + private final int pulses; - public TempSegment(int pulses) { + TempSegment(int pulses) { this.pulses = pulses; } - public int getPulses() { + int getPulses() { return pulses; } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalSchedule.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalSchedule.java index 0b22995205..24f2a72893 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalSchedule.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/BasalSchedule.java @@ -108,7 +108,7 @@ public class BasalSchedule { private final Duration duration; private final Duration startTime; - public BasalScheduleDurationEntry(double rate, Duration startTime, Duration duration) { + BasalScheduleDurationEntry(double rate, Duration startTime, Duration duration) { this.rate = rate; this.duration = duration; this.startTime = startTime; @@ -133,7 +133,7 @@ public class BasalSchedule { private final Duration startTime; private final Duration duration; - public BasalScheduleLookupResult(int index, BasalScheduleEntry basalScheduleEntry, Duration startTime, Duration duration) { + BasalScheduleLookupResult(int index, BasalScheduleEntry basalScheduleEntry, Duration startTime, Duration duration) { this.index = index; this.basalScheduleEntry = basalScheduleEntry; this.startTime = startTime; @@ -144,7 +144,7 @@ public class BasalSchedule { return index; } - public BasalScheduleEntry getBasalScheduleEntry() { + BasalScheduleEntry getBasalScheduleEntry() { return basalScheduleEntry; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/InsulinScheduleType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/InsulinScheduleType.java index ce4362d25c..76872a98e1 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/InsulinScheduleType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/InsulinScheduleType.java @@ -5,7 +5,7 @@ public enum InsulinScheduleType { TEMP_BASAL_SCHEDULE(1), BOLUS(2); - private byte value; + private final byte value; InsulinScheduleType(int value) { this.value = (byte) value; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/RateEntry.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/RateEntry.java index 3adb178707..e3d5d7cf28 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/RateEntry.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/definition/schedule/RateEntry.java @@ -15,7 +15,7 @@ public class RateEntry implements IRawRepresentable { // We use a double for the delay between pulses because the Joda time API lacks precision for our calculations private final double delayBetweenPulsesInSeconds; - public RateEntry(double totalPulses, double delayBetweenPulsesInSeconds) { + private RateEntry(double totalPulses, double delayBetweenPulsesInSeconds) { this.totalPulses = totalPulses; this.delayBetweenPulsesInSeconds = delayBetweenPulsesInSeconds; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/OmnipodException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/OmnipodException.java index 18c8425732..d4eb40ae94 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/OmnipodException.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/OmnipodException.java @@ -3,12 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; public abstract class OmnipodException extends RuntimeException { private boolean certainFailure; - public OmnipodException(String message, boolean certainFailure) { + OmnipodException(String message, boolean certainFailure) { super(message); this.certainFailure = certainFailure; } - public OmnipodException(String message, Throwable cause, boolean certainFailure) { + OmnipodException(String message, Throwable cause, boolean certainFailure) { super(message, cause); this.certainFailure = certainFailure; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java index dc80e5ab0c..72e647f250 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java @@ -208,6 +208,7 @@ public class OmnipodManager { return executeAndVerify(() -> communicationService.executeAction(new SetBasalScheduleAction(podStateManager, schedule, false, podStateManager.getScheduleOffset(), acknowledgementBeep))); } catch (OmnipodException ex) { + // TODO try to recover or at least verify whether or not the Pod is suspended // Treat all exceptions as uncertain failures, because all delivery has been suspended here. // Setting this to an uncertain failure will enable for the user to get an appropriate warning ex.setCertainFailure(false); @@ -233,8 +234,9 @@ public class OmnipodManager { acknowledgementBeep, completionBeep))); return statusResponse; } catch (OmnipodException ex) { - // Treat all exceptions as uncertain failures, because all delivery has been suspended here. + // Treat all exceptions as uncertain failures, because the old TBR has been cancelled here // Setting this to an uncertain failure will enable for the user to get an appropriate warning + // TODO try to recover ex.setCertainFailure(false); throw ex; } @@ -255,7 +257,7 @@ public class OmnipodManager { try { return executeAndVerify(() -> { StatusResponse statusResponse = communicationService.executeAction(new CancelDeliveryAction(podStateManager, deliveryTypes, acknowledgementBeep)); - aapsLogger.info(LTag.PUMPBTCOMM, "Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString()); + aapsLogger.info(LTag.PUMPCOMM, "Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString()); return statusResponse; }); } finally { @@ -285,7 +287,7 @@ public class OmnipodManager { } // Catch uncertain exceptions as we still want to report bolus progress indication - aapsLogger.error(LTag.PUMPBTCOMM, "Caught exception[certainFailure=false] in bolus", ex); + aapsLogger.error(LTag.PUMPCOMM, "Caught exception[certainFailure=false] in bolus", ex); commandDeliveryStatus = CommandDeliveryStatus.UNCERTAIN_FAILURE; } @@ -340,10 +342,10 @@ public class OmnipodManager { // Substract units not delivered in case of a Pod failure unitsNotDelivered = ex.getFaultEvent().getInsulinNotDelivered(); - aapsLogger.debug(LTag.PUMPBTCOMM, "Caught PodFaultException in bolus completion verification", ex); + aapsLogger.debug(LTag.PUMPCOMM, "Caught PodFaultException in bolus completion verification", ex); break; } catch (Exception ex) { - aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in bolus completion verification", ex); + aapsLogger.debug(LTag.PUMPCOMM, "Ignoring exception in bolus completion verification", ex); } } @@ -418,25 +420,23 @@ public class OmnipodManager { try { cancelDelivery(EnumSet.allOf(DeliveryType.class), acknowledgementBeeps); - } catch (Exception ex) { - logCommandExecutionFinished("setTime"); - throw ex; - } - DateTimeZone oldTimeZone = podStateManager.getTimeZone(); + DateTimeZone oldTimeZone = podStateManager.getTimeZone(); - try { - // Joda seems to cache the default time zone, so we use the JVM's - DateTimeZone.setDefault(DateTimeZone.forTimeZone(TimeZone.getDefault())); - podStateManager.setTimeZone(DateTimeZone.getDefault()); + try { + // Joda seems to cache the default time zone, so we use the JVM's + DateTimeZone.setDefault(DateTimeZone.forTimeZone(TimeZone.getDefault())); + podStateManager.setTimeZone(DateTimeZone.getDefault()); - setBasalSchedule(podStateManager.getBasalSchedule(), acknowledgementBeeps); - } catch (OmnipodException ex) { - // Treat all exceptions as uncertain failures, because all delivery has been suspended here. - // Setting this to an uncertain failure will enable for the user to get an appropriate warning - podStateManager.setTimeZone(oldTimeZone); - ex.setCertainFailure(false); - throw ex; + setBasalSchedule(podStateManager.getBasalSchedule(), acknowledgementBeeps); + } catch (OmnipodException ex) { + // Treat all exceptions as uncertain failures, because all delivery has been suspended here. + // Setting this to an uncertain failure will enable for the user to get an appropriate warning + // TODO try to recover or at least verify whether or not the Pod is suspended + podStateManager.setTimeZone(oldTimeZone); + ex.setCertainFailure(false); + throw ex; + } } finally { logCommandExecutionFinished("setTime"); } @@ -454,16 +454,16 @@ public class OmnipodManager { try { PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podStateManager, PodInfoType.RECENT_PULSE_LOG)); PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo(); - aapsLogger.info(LTag.PUMPBTCOMM, "Retrieved pulse log from the pod: {}", pulseLogInfo.toString()); + aapsLogger.info(LTag.PUMPCOMM, "Retrieved pulse log from the pod: {}", pulseLogInfo.toString()); } catch (Exception ex) { - aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to retrieve pulse log from the pod", ex); + aapsLogger.warn(LTag.PUMPCOMM, "Failed to retrieve pulse log from the pod", ex); } try { // Always send acknowledgement beeps here. Matches the PDM's behavior communicationService.executeAction(new DeactivatePodAction(podStateManager, true)); } catch (PodFaultException ex) { - aapsLogger.info(LTag.PUMPBTCOMM, "Ignoring PodFaultException in deactivatePod", ex); + aapsLogger.info(LTag.PUMPCOMM, "Ignoring PodFaultException in deactivatePod", ex); } finally { logCommandExecutionFinished("deactivatePod"); } @@ -501,17 +501,17 @@ public class OmnipodManager { if (isCertainFailure(originalException)) { throw originalException; } else { - aapsLogger.warn(LTag.PUMPBTCOMM, "Caught exception in executeAndVerify. Verifying command by using cancel none command to verify nonce", originalException); + aapsLogger.warn(LTag.PUMPCOMM, "Caught exception in executeAndVerify. Verifying command by using cancel none command to verify nonce", originalException); try { logStartingCommandExecution("verifyCommand"); StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podStateManager, new CancelDeliveryCommand(podStateManager.getCurrentNonce(), BeepType.NO_BEEP, DeliveryType.NONE), false); - aapsLogger.info(LTag.PUMPBTCOMM, "Command status resolved to SUCCESS. Status response after cancelDelivery[types=DeliveryType.NONE]: {}", statusResponse); + aapsLogger.info(LTag.PUMPCOMM, "Command status resolved to SUCCESS. Status response after cancelDelivery[types=DeliveryType.NONE]: {}", statusResponse); return statusResponse; } catch (NonceOutOfSyncException verificationException) { - aapsLogger.error(LTag.PUMPBTCOMM, "Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException); + aapsLogger.error(LTag.PUMPCOMM, "Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException); if (originalException instanceof OmnipodException) { ((OmnipodException) originalException).setCertainFailure(true); @@ -522,12 +522,12 @@ public class OmnipodManager { throw newException; } } catch (Exception verificationException) { - aapsLogger.error(LTag.PUMPBTCOMM, "Command unresolved (UNCERTAIN_FAILURE)", verificationException); + aapsLogger.error(LTag.PUMPCOMM, "Command unresolved (UNCERTAIN_FAILURE)", verificationException); throw originalException; - } finally { - logCommandExecutionFinished("verifyCommand"); } } + } finally { + logCommandExecutionFinished("verifyCommand"); } } @@ -560,11 +560,11 @@ public class OmnipodManager { } private void logStartingCommandExecution(String action) { - aapsLogger.debug(LTag.PUMPBTCOMM, "Starting command execution for action: " + action); + aapsLogger.debug(LTag.PUMPCOMM, "Starting command execution for action: " + action); } private void logCommandExecutionFinished(String action) { - aapsLogger.debug(LTag.PUMPBTCOMM, "Command execution finished for action: " + action); + aapsLogger.debug(LTag.PUMPCOMM, "Command execution finished for action: " + action); } private static Duration calculateBolusDuration(double units, double deliveryRate) { @@ -585,7 +585,7 @@ public class OmnipodManager { private final CommandDeliveryStatus commandDeliveryStatus; private final SingleSubject deliveryResultSubject; - public BolusCommandResult(CommandDeliveryStatus commandDeliveryStatus, SingleSubject deliveryResultSubject) { + BolusCommandResult(CommandDeliveryStatus commandDeliveryStatus, SingleSubject deliveryResultSubject) { this.commandDeliveryStatus = commandDeliveryStatus; this.deliveryResultSubject = deliveryResultSubject; } @@ -602,7 +602,7 @@ public class OmnipodManager { public static class BolusDeliveryResult { private final double unitsDelivered; - public BolusDeliveryResult(double unitsDelivered) { + BolusDeliveryResult(double unitsDelivered) { this.unitsDelivered = unitsDelivered; } @@ -619,9 +619,9 @@ public class OmnipodManager { private static class ActiveBolusData { private final double units; - private volatile DateTime startDate; - private volatile SingleSubject bolusCompletionSubject; - private volatile CompositeDisposable disposables; + private final DateTime startDate; + private final SingleSubject bolusCompletionSubject; + private final CompositeDisposable disposables; private ActiveBolusData(double units, DateTime startDate, SingleSubject bolusCompletionSubject, CompositeDisposable disposables) { this.units = units; @@ -630,23 +630,23 @@ public class OmnipodManager { this.disposables = disposables; } - public double getUnits() { + double getUnits() { return units; } - public DateTime getStartDate() { + DateTime getStartDate() { return startDate; } - public CompositeDisposable getDisposables() { + CompositeDisposable getDisposables() { return disposables; } - public SingleSubject getBolusCompletionSubject() { + SingleSubject getBolusCompletionSubject() { return bolusCompletionSubject; } - public double estimateUnitsDelivered() { + double estimateUnitsDelivered() { long elapsedMillis = new Duration(startDate, DateTime.now()).getMillis(); long totalDurationMillis = (long) (units / OmnipodConstants.POD_BOLUS_DELIVERY_RATE * 1000); double factor = (double) elapsedMillis / totalDurationMillis; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java index 7f3b819399..003f839b16 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java @@ -38,7 +38,7 @@ public abstract class PodStateManager { private final Gson gsonInstance; private PodState podState; - public PodStateManager(AAPSLogger aapsLogger) { + protected PodStateManager(AAPSLogger aapsLogger) { this.aapsLogger = aapsLogger; this.gsonInstance = createGson(); } @@ -619,7 +619,7 @@ public abstract class PodStateManager { return totalTicksDelivered; } - public Double getTotalInsulinDelivered() { + Double getTotalInsulinDelivered() { if (totalTicksDelivered != null) { return totalTicksDelivered * OmnipodConstants.POD_PULSE_SIZE; } else { @@ -631,7 +631,7 @@ public abstract class PodStateManager { this.totalTicksDelivered = totalTicksDelivered; } - public boolean isSuspended() { + boolean isSuspended() { return suspended; } @@ -647,7 +647,7 @@ public abstract class PodStateManager { this.nonceState = nonceState; } - public PodProgressStatus getPodProgressStatus() { + PodProgressStatus getPodProgressStatus() { return podProgressStatus; } @@ -679,7 +679,7 @@ public abstract class PodStateManager { this.basalSchedule = basalSchedule; } - public DateTime getLastBolusStartTime() { + DateTime getLastBolusStartTime() { return lastBolusStartTime; } @@ -787,7 +787,7 @@ public abstract class PodStateManager { return (int) ((table[1] + (table[0] << 16)) & 0xFFFFFFFFL); } - public int getCurrentNonce() { + int getCurrentNonce() { return (int) table[(2 + index)]; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/OmnipodRileyLinkCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/OmnipodRileyLinkCommunicationManager.java index c55505ac2d..6fc8d31152 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/OmnipodRileyLinkCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/OmnipodRileyLinkCommunicationManager.java @@ -105,7 +105,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication } public synchronized T exchangeMessages(Class responseClass, PodStateManager podStateManager, OmnipodMessage message, Integer addressOverride, Integer ackAddressOverride, boolean automaticallyResyncNonce) { - aapsLogger.debug(LTag.PUMPCOMM, "Exchanging OmnipodMessage: responseClass={}, podStateManager={}, message={}, addressOverride={}, ackAddressOverride={}, automaticallyResyncNonce={}", // + aapsLogger.debug(LTag.PUMPBTCOMM, "Exchanging OmnipodMessage: responseClass={}, podStateManager={}, message={}, addressOverride={}, ackAddressOverride={}, automaticallyResyncNonce={}", // responseClass.getSimpleName(), podStateManager, message, addressOverride, ackAddressOverride, automaticallyResyncNonce); try { @@ -123,7 +123,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication throw ex; } - aapsLogger.debug(LTag.PUMPCOMM, "Received response from the Pod [responseMessageBlock={}]", responseMessageBlock); + aapsLogger.debug(LTag.PUMPBTCOMM, "Received response from the Pod [responseMessageBlock={}]", responseMessageBlock); if (responseMessageBlock instanceof StatusResponse) { podStateManager.updateFromStatusResponse((StatusResponse) responseMessageBlock); @@ -138,10 +138,10 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication if (error.getErrorResponseCode() == ErrorResponse.ERROR_RESPONSE_CODE_BAD_NONCE) { podStateManager.resyncNonce(error.getNonceSearchKey(), message.getSentNonce(), message.getSequenceNumber()); if (automaticallyResyncNonce) { - aapsLogger.warn(LTag.PUMPCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Resyncing nonce and retrying to send message as automaticallyResyncNonce=true"); + aapsLogger.warn(LTag.PUMPBTCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Resyncing nonce and retrying to send message as automaticallyResyncNonce=true"); message.resyncNonce(podStateManager.getCurrentNonce()); } else { - aapsLogger.warn(LTag.PUMPCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Not resyncing nonce as automaticallyResyncNonce=true"); + aapsLogger.warn(LTag.PUMPBTCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Not resyncing nonce as automaticallyResyncNonce=true"); podStateManager.setLastFailedCommunication(DateTime.now()); throw new NonceOutOfSyncException(); } @@ -175,7 +175,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication } if (podStateManager.getMessageNumber() != message.getSequenceNumber()) { - aapsLogger.warn(LTag.PUMPCOMM, "Message number in Pod State [{}] does not match message sequence number [{}]. Setting message number in Pod State to {}", podStateManager.getMessageNumber(), message.getSequenceNumber(), message.getSequenceNumber()); + aapsLogger.warn(LTag.PUMPBTCOMM, "Message number in Pod State [{}] does not match message sequence number [{}]. Setting message number in Pod State to {}", podStateManager.getMessageNumber(), message.getSequenceNumber(), message.getSequenceNumber()); podStateManager.setMessageNumber(message.getSequenceNumber()); } @@ -226,7 +226,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication // so it's impossible for the pod to have received the message newException.setCertainFailure(!lastPacket); - aapsLogger.debug(LTag.PUMPCOMM, "Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length); + aapsLogger.debug(LTag.PUMPBTCOMM, "Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length); throw newException; } @@ -331,7 +331,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication podStateManager.increasePacketNumber(); while (System.currentTimeMillis() < timeoutTime) { - OmnipodPacket response = null; + OmnipodPacket response; try { response = (OmnipodPacket) sendAndListen(packet, responseTimeoutMilliseconds, repeatCount, 9, preambleExtensionMilliseconds); } catch (RileyLinkCommunicationException | OmnipodException ex) { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/RileyLinkOmnipodService.java index 201579f773..71ea915124 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/RileyLinkOmnipodService.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/RileyLinkOmnipodService.java @@ -40,7 +40,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { @Inject AapsOmnipodManager aapsOmnipodManager; @Inject OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager; - private IBinder mBinder = new LocalBinder(); + private final IBinder mBinder = new LocalBinder(); private boolean rileyLinkAddressChanged = false; private boolean inPreInit = true; private String rileyLinkAddress; @@ -52,7 +52,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { @Override public void onConfigurationChanged(Configuration newConfig) { - aapsLogger.warn(LTag.PUMPCOMM, "onConfigurationChanged"); + aapsLogger.warn(LTag.PUMPBTCOMM, "onConfigurationChanged"); super.onConfigurationChanged(newConfig); } @@ -75,7 +75,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { rfspy.startReader(); - aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkOmnipodService newly constructed"); + aapsLogger.debug(LTag.PUMPBTCOMM, "RileyLinkOmnipodService newly constructed"); } @Override @@ -115,13 +115,13 @@ public class RileyLinkOmnipodService extends RileyLinkService { String rileyLinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, ""); if (StringUtils.isEmpty(rileyLinkAddress)) { - aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: no address"); + aapsLogger.debug(LTag.PUMPBTCOMM, "RileyLink address invalid: no address"); errorDescription = resourceHelper.gs(R.string.omnipod_error_rileylink_address_invalid); return false; } else { if (!rileyLinkAddress.matches(REGEX_MAC)) { errorDescription = resourceHelper.gs(R.string.omnipod_error_rileylink_address_invalid); - aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: {}", rileyLinkAddress); + aapsLogger.debug(LTag.PUMPBTCOMM, "RileyLink address invalid: {}", rileyLinkAddress); } else { if (!rileyLinkAddress.equals(this.rileyLinkAddress)) { this.rileyLinkAddress = rileyLinkAddress; @@ -138,7 +138,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { } catch (Exception ex) { errorDescription = ex.getMessage(); - aapsLogger.error(LTag.PUMPCOMM, "Error on Verification: " + ex.getMessage(), ex); + aapsLogger.error(LTag.PUMPBTCOMM, "Error on Verification: " + ex.getMessage(), ex); return false; } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt index 9ac070adaa..093339b46c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt @@ -48,7 +48,7 @@ import org.joda.time.Duration import javax.inject.Inject class OmnipodFragment : DaggerFragment() { - val REFRESH_INTERVAL_MILLIS = 15 * 1000L; // 15 seconds + private val REFRESH_INTERVAL_MILLIS = 15 * 1000L; // 15 seconds @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var resourceHelper: ResourceHelper @@ -179,7 +179,7 @@ class OmnipodFragment : DaggerFragment() { loopHandler.removeCallbacks(refreshLoop) } - fun updateUi() { + private fun updateUi() { updateRileyLinkStatus() updateOmipodStatus() updatePodActionButtons() @@ -204,7 +204,7 @@ class OmnipodFragment : DaggerFragment() { omnipod_rl_status.setTextColor(if (rileyLinkServiceState.isError || rileyLinkError != null) Color.RED else Color.WHITE) } - fun updateOmipodStatus() { + private fun updateOmipodStatus() { updateLastConnection() updatePodStatus() diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java index 2549b5376e..3bfe876e84 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java @@ -50,15 +50,14 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { private RecyclerView recyclerView; private LinearLayoutManager linearLayoutManager; - static TypeList showingType = null; - static PumpHistoryEntryGroup selectedGroup = PumpHistoryEntryGroup.All; - List fullHistoryList = new ArrayList<>(); - List filteredHistoryList = new ArrayList<>(); + private static PumpHistoryEntryGroup selectedGroup = PumpHistoryEntryGroup.All; + private final List fullHistoryList = new ArrayList<>(); + private final List filteredHistoryList = new ArrayList<>(); - RecyclerViewAdapter recyclerViewAdapter; - boolean manualChange = false; + private RecyclerViewAdapter recyclerViewAdapter; + private boolean manualChange = false; - List typeListFull; + private List typeListFull; public PodHistoryActivity() { @@ -162,7 +161,6 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { if (manualChange) return; TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem(); - showingType = selected; selectedGroup = selected.entryGroup; filterHistory(selectedGroup); } @@ -190,10 +188,10 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { return typeList; } - public static class TypeList { + static class TypeList { - PumpHistoryEntryGroup entryGroup; - String name; + final PumpHistoryEntryGroup entryGroup; + final String name; TypeList(PumpHistoryEntryGroup entryGroup) { this.entryGroup = entryGroup; @@ -216,7 +214,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { } - public void setHistoryList(List historyList) { + void setHistoryList(List historyList) { this.historyList = historyList; Collections.sort(this.historyList); } @@ -326,9 +324,9 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { class HistoryViewHolder extends RecyclerView.ViewHolder { - TextView timeView; - TextView typeView; - TextView valueView; + final TextView timeView; + final TextView typeView; + final TextView valueView; HistoryViewHolder(View itemView) { super(itemView); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt index fc8c9d245f..c9fe267414 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt @@ -90,7 +90,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { disposables.clear() } - fun initPodAction() { + private fun initPodAction() { val pagerSettings = WizardPagerSettings() var refreshAction = InitPodRefreshAction(injector, PodActionType.InitPod) @@ -119,7 +119,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { this@PodManagementActivity.startActivity(myIntent) } - fun removePodAction() { + private fun removePodAction() { val pagerSettings = WizardPagerSettings() var refreshAction = InitPodRefreshAction(injector, PodActionType.RemovePod) @@ -143,7 +143,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { } - fun resetPodAction() { + private fun resetPodAction() { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread { aapsOmnipodManager.resetPodStatus() @@ -151,11 +151,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() { }) } - fun showPodHistory() { + private fun showPodHistory() { startActivity(Intent(applicationContext, PodHistoryActivity::class.java)) } - fun refreshButtons() { + private fun refreshButtons() { initpod_init_pod.isEnabled = !podStateManager.isPodActivationCompleted initpod_remove_pod.isEnabled = podStateManager.isPodInitialized initpod_reset_pod.isEnabled = podStateManager.hasPodState() diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionFragment.java index 89d3bdd20c..97dd6c2573 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionFragment.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionFragment.java @@ -44,16 +44,16 @@ public class InitActionFragment extends DaggerFragment implements PodInitReceive private static boolean isFirstView; - protected PageFragmentCallbacks mCallbacks; - protected String mKey; + private PageFragmentCallbacks mCallbacks; + private String mKey; protected InitActionPage mPage; protected ProgressBar progressBar; protected TextView errorView; protected Button retryButton; - protected PodInitActionType podInitActionType; - protected List children; + PodInitActionType podInitActionType; + private List children; protected Map mapCheckBoxes; protected PumpEnactResult callResult; @@ -209,7 +209,7 @@ public class InitActionFragment extends DaggerFragment implements PodInitReceive } } - public void setCheckBox(PodInitActionType podInitActionType, boolean isSuccess) { + protected void setCheckBox(PodInitActionType podInitActionType, boolean isSuccess) { FragmentActivity activity = getActivity(); if (activity != null) { activity.runOnUiThread(() -> { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionPage.java index f1b4cb23a0..8c086ffe6e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionPage.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitActionPage.java @@ -21,10 +21,10 @@ public class InitActionPage extends Page { protected PodInitActionType podInitActionType; - protected boolean actionCompleted = false; - protected boolean actionSuccess = false; + private boolean actionCompleted = false; + private boolean actionSuccess = false; - public InitActionPage(ModelCallbacks callbacks, String title) { + protected InitActionPage(ModelCallbacks callbacks, String title) { super(callbacks, title); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitPodTask.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitPodTask.java index 45da4bbae1..6864c696a1 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitPodTask.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/initpod/InitPodTask.java @@ -20,7 +20,7 @@ public class InitPodTask extends AsyncTask { @Inject ProfileFunction profileFunction; @Inject AapsOmnipodManager aapsOmnipodManager; @Inject RxBusWrapper rxBus; - private InitActionFragment initActionFragment; + private final InitActionFragment initActionFragment; public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) { injector.androidInjector().inject(this); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/InitPodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/InitPodWizardModel.java index 34fa7eaadd..e3c4e9c1fe 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/InitPodWizardModel.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/InitPodWizardModel.java @@ -8,13 +8,13 @@ import com.tech.freak.wizardpager.model.AbstractWizardModel; import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.pages.PodInfoFragment; -public abstract class InitPodWizardModel extends AbstractWizardModel { - public InitPodWizardModel(Context context) { +abstract class InitPodWizardModel extends AbstractWizardModel { + InitPodWizardModel(Context context) { super(context); } @Override public Fragment getReviewFragment() { - return PodInfoFragment.create("initPodInfoFragment", true); + return PodInfoFragment.create(true); } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/RemovePodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/RemovePodWizardModel.java index 9f84660db1..51ebe065aa 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/RemovePodWizardModel.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/model/RemovePodWizardModel.java @@ -55,7 +55,7 @@ public class RemovePodWizardModel extends AbstractWizardModel { } @Override public Fragment getReviewFragment() { - return PodInfoFragment.create("removePodInfoFragment", false); + return PodInfoFragment.create(false); } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/InitPodRefreshAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/InitPodRefreshAction.java index 8477aa5afb..b78ebaae3e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/InitPodRefreshAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/InitPodRefreshAction.java @@ -26,7 +26,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; */ public class InitPodRefreshAction extends AbstractCancelAction implements FinishActionInterface { - private PodActionType actionType; + private final PodActionType actionType; @Inject PodStateManager podStateManager; @Inject AAPSLogger aapsLogger; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoFragment.java index 8933f9cc12..83dbeb0125 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoFragment.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoFragment.java @@ -30,20 +30,16 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil; * Created by andy on 12/11/2019 */ public class PodInfoFragment extends DaggerFragment { - private static final String ARG_KEY = "key"; private static final String ARG_INIT_POD = "initPod"; @Inject AapsOmnipodUtil aapsOmnipodUtil; @Inject PodStateManager podStateManager; - private PageFragmentCallbacks mCallbacks; - private String mKey; - public boolean isInitPod; + private boolean isInitPod; private ArrayList mCurrentReviewItems; - public static PodInfoFragment create(String key, boolean initPod) { + public static PodInfoFragment create(boolean initPod) { Bundle args = new Bundle(); - args.putString(ARG_KEY, key); args.putBoolean(ARG_INIT_POD, initPod); PodInfoFragment fragment = new PodInfoFragment(); @@ -58,7 +54,6 @@ public class PodInfoFragment extends DaggerFragment { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Bundle args = getArguments(); - mKey = args.getString(ARG_KEY); isInitPod = args.getBoolean(ARG_INIT_POD); } @@ -120,28 +115,16 @@ public class PodInfoFragment extends DaggerFragment { if (!(activity instanceof PageFragmentCallbacks)) { throw new ClassCastException("Activity must implement PageFragmentCallbacks"); } - - mCallbacks = (PageFragmentCallbacks) activity; } @Override public void onDetach() { super.onDetach(); - mCallbacks = null; } - private class PodInfoAdapter extends ArrayAdapter { - - private ArrayList dataSet; - Context mContext; - private int lastPosition = -1; - - // View lookup cache - - public PodInfoAdapter(ArrayList data, Context context) { + private static class PodInfoAdapter extends ArrayAdapter { + PodInfoAdapter(ArrayList data, Context context) { super(context, com.tech.freak.wizardpager.R.layout.list_item_review, data); - this.dataSet = data; - this.mContext = context; } @@ -152,8 +135,6 @@ public class PodInfoFragment extends DaggerFragment { // Check if an existing view is being reused, otherwise inflate the view ViewHolder viewHolder; // view lookup cache stored in tag - final View result; - if (convertView == null) { viewHolder = new ViewHolder(); @@ -162,12 +143,9 @@ public class PodInfoFragment extends DaggerFragment { viewHolder.txtName = (TextView) convertView.findViewById(android.R.id.text1); viewHolder.txtType = (TextView) convertView.findViewById(android.R.id.text2); - result = convertView; - convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); - result = convertView; } viewHolder.txtName.setText(dataModel.getTitle()); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoPage.java deleted file mode 100644 index f292597573..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/pages/PodInfoPage.java +++ /dev/null @@ -1,34 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.pages; - -import androidx.fragment.app.Fragment; - -import com.tech.freak.wizardpager.model.ModelCallbacks; -import com.tech.freak.wizardpager.model.Page; -import com.tech.freak.wizardpager.model.ReviewItem; - -import java.util.ArrayList; - - -/** - * Created by andy on 12/11/2019 - */ -public class PodInfoPage extends Page { - - public PodInfoPage(ModelCallbacks callbacks, String title) { - super(callbacks, title); - } - - @Override - public Fragment createFragment() { - return PodInfoFragment.create(getKey(), true); - } - - @Override - public void getReviewItems(ArrayList dest) { - } - - @Override - public boolean isCompleted() { - return true; - } -} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/AapsOmnipodUtil.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/AapsOmnipodUtil.java index fd92e4c9f9..97c938825a 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/AapsOmnipodUtil.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/AapsOmnipodUtil.java @@ -31,7 +31,7 @@ public class AapsOmnipodUtil { private final ResourceHelper resourceHelper; - private Gson gsonInstance = createGson(); + private final Gson gsonInstance = createGson(); @Inject public AapsOmnipodUtil(ResourceHelper resourceHelper) { diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 750c85d0a5..a143614b1a 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -15,35 +15,35 @@ pref_omnipod_beep_tbr_enabled pref_omnipod_pod_debugging_options_enabled pref_omnipod_timechange_enabled - Bolus Beep Enabled - Basal Beep Enabled - SMB Beep Enabled - TBR Beep Enabled - Pod Debugging Options Enabled - DST/Timezone Detection Enabled + Bolus beep enabled + Basal beep enabled + SMB beep enabled + TBR beep enabled + Pod debugging options enabled + DST/Time zone detection enabled Moments ago - Pod Mgmt - Pod Status - Total Delivered + Pod mgmt + Pod status + Total delivered %1$.2f U %1$.2f U left Over 50 U - Pod Address - Pod Expires + Pod address + Pod expires Warning No active Pod Setup in progress (waiting for pair and prime) Setup in progress (waiting for cannula insertion) Running Suspended - Pod Fault + Pod fault Activation time exceeded Inactive - Pod Fault: %1$s %2$s - Active Pod Alerts - Ack Alerts + Pod fault: %1$s %2$s + Active Pod alerts + Ack alerts %1$.2f %2$s (%3$s) Initializing @@ -53,52 +53,52 @@ - RileyLink Address invalid. + RileyLink address invalid. Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation. - Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time. + Operation is not possible.\n\n You need to wait a few minutes, until AAPS tries to set basal profile for first time. Illegal PodInitActionType: %1$s - No active pod. - Command verification failed. + No active Pod + Command verification failed An unexpected error occurred. Please report! (type: %1$s). - Communication failed: received invalid input parameters. - Communication failed: timeout. + Communication failed: received invalid input parameters + Communication failed: timeout Communication failed: an unexpected error occurred. Please report! - Communication failed: message integrity verification failed. - Communication failed: received an invalid packet from the Pod. - Communication failed: the Pod is in a wrong state. - Communication failed: received an invalid response from the Pod. - Communication failed: received a message with an invalid sequence number from the Pod. - Communication failed: received a message with an invalid address from the Pod. - Communication failed: failed to decode message from the Pod. - Communication failed: nonce resync failed. - Communication failed: nonce out of sync. - Communication failed: not enough data received from the Pod. - A Pod fault (%1$03d %2$s) has been detected. Please deactivate your Pod and start a new one. - Communication failed: the Pod returned an error response. + Communication failed: message integrity verification failed + Communication failed: received an invalid packet from the Pod + Communication failed: the Pod is in a wrong state + Communication failed: received an invalid response from the Pod + Communication failed: received a message with an invalid sequence number from the Pod + Communication failed: received a message with an invalid address from the Pod + Communication failed: failed to decode message from the Pod + Communication failed: nonce resync failed + Communication failed: nonce out of sync + Communication failed: not enough data received from the Pod + A Pod fault (%1$03d %2$s) has been detected. Please deactivate your Pod and start a new one + Communication failed: the Pod returned an error response - Pod Management + Pod management Init Pod Deactivate Pod Reset Pod - Pod History - Set Bolus - Cancel Bolus - Set Temporary Basal - Cancel Temporary Basal (Internally by driver) - Cancel Temporary Basal (Forced by user) - Set Basal Schedule - Get Pod Status - Get Pod Info - Set Time - Configure Alerts - Acknowledge Alerts - Suspend Delivery - Resume Delivery - Unknown Entry + Pod history + Set bolus + Cancel bolus + Set temporary basal + Cancel temporary basal (internally by driver) + Cancel temporary casal (forced by user) + Set basal schedule + Get Pod status + Get Pod info + Set time + Configure alerts + Acknowledge alerts + Suspend delivery + Resume delivery + Unknown entry %1$.2f U %1$.2f U, CH=%2$.1f g - Rate: %1$.2f U, Duration: %2$d min + Rate: %1$.2f U, duration: %2$d min If you press OK, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the Deactivate Pod option. Pod History not available at the moment. Fill the Pod @@ -109,7 +109,7 @@ \nPrepare the infusion site. Remove the Pod\'s needle cap and adhesive backing and attach the Pod to the infusion site.\n\nIf the cannula sticks out, please press Cancel and discard your Pod.\n\nPress Next to insert the cannula and begin basal delivery. Inserting cannula Trying to set initial basal schedule and insert the cannula.\n\nWhen all items are checked, you can press Next. - Pod Info + Pod info \nThe Pod is now active.\n\nYour basal schedule has been programmed and the cannula has been inserted.\n\nPlease verify that the cannula has been inserted correctly and replace your Pod if you feel hasn\'t. Deactivate Pod \nPress Next to deactivate the Pod.\n\nNote: This will suspend all insulin delivery and deactivate the Pod. @@ -118,15 +118,12 @@ Pod deactivated.\n\nPlease remove the Pod from your body and discard it. Pair Pod Prime Pod - Fill Cannula - Set Basal Profile - Cancel Delivery + Fill cannula + Set basal profile + Cancel delivery Deactivate Pod - Omnipod Dash - DASH - Pump integration for Omnipod Dash. Finish pairing reminder Finish setup reminder Pod will expire soon @@ -135,19 +132,19 @@ Low reservoir Unknown alert Setting basal profile might have failed. Delivery might be suspended! Please refresh Pod status. - Setting temp basal might have failed. If there was a temp basal already running, that may have been cancelled! Please refresh pod status. + Setting temp basal might have failed. If there was a temp basal already running, that may have been cancelled! Please refresh Pod status. Setting time might have failed. Delivery might be suspended! Please refresh Pod status. Unable to verify whether the bolus succeeded. Please verify that your Pod is bolusing or cancel the bolus. - RL Stats - Pulse Log + RL stats + Pulse log LOT TID Firmware version PM %1$s / PI %2$s Errors Basal profile is the same, so it will not be set again. - Reset RileyLink Config - Time and/or Timezone change on pump + Reset RileyLink config + Time and/or time zone changed on the Pod %1$s and %2$s %1$s ago Waiting for RileyLink connection... diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java index 3d7acfc167..fc6a146d29 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java @@ -73,7 +73,7 @@ public abstract class RileyLinkCommunicationManager { // internal flag boolean showPumpMessages = true; if (showPumpMessages) { - aapsLogger.info(LTag.PUMPCOMM, "Sent:" + ByteUtil.shortHexString(msg.getTxData())); + aapsLogger.info(LTag.PUMPBTCOMM, "Sent:" + ByteUtil.shortHexString(msg.getTxData())); } RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(injector, msg.getTxData()), @@ -86,7 +86,7 @@ public abstract class RileyLinkCommunicationManager { // Mark this as the last time we heard from the pump. rememberLastGoodDeviceCommunicationTime(); } else { - aapsLogger.warn(LTag.PUMPCOMM, "isDeviceReachable. Response is invalid ! [interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", rfSpyResponse.wasInterrupted(), + aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Response is invalid ! [interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", rfSpyResponse.wasInterrupted(), rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam()); if (rfSpyResponse.wasTimeout()) { @@ -96,7 +96,7 @@ public abstract class RileyLinkCommunicationManager { long diff = System.currentTimeMillis() - getPumpDevice().getLastConnectionTimeMillis(); if (diff > ALLOWED_PUMP_UNREACHABLE) { - aapsLogger.warn(LTag.PUMPCOMM, "We reached max time that Pump can be unreachable. Starting Tuning."); + aapsLogger.warn(LTag.PUMPBTCOMM, "We reached max time that Pump can be unreachable. Starting Tuning."); serviceTaskExecutor.startTask(new WakeAndTuneTask(injector)); timeoutCount = 0; } @@ -109,7 +109,7 @@ public abstract class RileyLinkCommunicationManager { } if (showPumpMessages) { - aapsLogger.info(LTag.PUMPCOMM, "Received:" + ByteUtil.shortHexString(rfSpyResponse.getRadioResponse(injector).getPayload())); + aapsLogger.info(LTag.PUMPBTCOMM, "Received:" + ByteUtil.shortHexString(rfSpyResponse.getRadioResponse(injector).getPayload())); } return response; @@ -145,18 +145,18 @@ public abstract class RileyLinkCommunicationManager { nextWakeUpRequired = 0L; if (System.currentTimeMillis() > nextWakeUpRequired) { - aapsLogger.info(LTag.PUMPCOMM, "Waking pump..."); + aapsLogger.info(LTag.PUMPBTCOMM, "Waking pump..."); byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 200, (byte) 0, (byte) 0, 25000, (byte) 0); - aapsLogger.info(LTag.PUMPCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw())); + aapsLogger.info(LTag.PUMPBTCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw())); // FIXME wakeUp successful !!!!!!!!!!!!!!!!!! nextWakeUpRequired = System.currentTimeMillis() + (receiverDeviceAwakeForMinutes * 60 * 1000); } else { - aapsLogger.debug(LTag.PUMPCOMM, "Last pump communication was recent, not waking pump."); + aapsLogger.debug(LTag.PUMPBTCOMM, "Last pump communication was recent, not waking pump."); } // long lastGoodPlus = getLastGoodReceiverCommunicationTime() + (receiverDeviceAwakeForMinutes * 60 * 1000); @@ -213,7 +213,7 @@ public abstract class RileyLinkCommunicationManager { private double scanForDevice(double[] frequencies) { - aapsLogger.info(LTag.PUMPCOMM, "Scanning for receiver ({})", receiverDeviceID); + aapsLogger.info(LTag.PUMPBTCOMM, "Scanning for receiver ({})", receiverDeviceID); wakeUp(receiverDeviceAwakeForMinutes, false); FrequencyScanResults results = new FrequencyScanResults(); @@ -230,7 +230,7 @@ public abstract class RileyLinkCommunicationManager { RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 0, (byte) 0, (byte) 0, 1250, (byte) 0); if (resp.wasTimeout()) { - aapsLogger.error(LTag.PUMPCOMM, "scanForPump: Failed to find pump at frequency {}", frequencies[i]); + aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: Failed to find pump at frequency {}", frequencies[i]); } else if (resp.looksLikeRadioPacket()) { RadioResponse radioResponse = new RadioResponse(injector); @@ -244,17 +244,17 @@ public abstract class RileyLinkCommunicationManager { trial.rssiList.add(rssi); trial.successes++; } else { - aapsLogger.warn(LTag.PUMPCOMM, "Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw())); + aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw())); trial.rssiList.add(-99); } } catch (RileyLinkCommunicationException rle) { - aapsLogger.warn(LTag.PUMPCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw())); + aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw())); trial.rssiList.add(-99); } } else { - aapsLogger.error(LTag.PUMPCOMM, "scanForPump: raw response is " + ByteUtil.shortHexString(resp.getRaw())); + aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: raw response is " + ByteUtil.shortHexString(resp.getRaw())); trial.rssiList.add(-99); } trial.tries++; @@ -278,7 +278,7 @@ public abstract class RileyLinkCommunicationManager { + one.frequencyMHz, "" + one.averageRSSI + ", RSSIs =" + one.rssiList)); } - aapsLogger.info(LTag.PUMPCOMM, stringBuilder.toString()); + aapsLogger.info(LTag.PUMPBTCOMM, stringBuilder.toString()); results.sort(); // sorts in ascending order @@ -286,10 +286,10 @@ public abstract class RileyLinkCommunicationManager { results.bestFrequencyMHz = bestTrial.frequencyMHz; if (bestTrial.successes > 0) { rfspy.setBaseFrequency(results.bestFrequencyMHz); - aapsLogger.debug(LTag.PUMPCOMM, "Best frequency found: " + results.bestFrequencyMHz); + aapsLogger.debug(LTag.PUMPBTCOMM, "Best frequency found: " + results.bestFrequencyMHz); return results.bestFrequencyMHz; } else { - aapsLogger.error(LTag.PUMPCOMM, "No pump response during scan."); + aapsLogger.error(LTag.PUMPBTCOMM, "No pump response during scan."); return 0.0; } } @@ -318,22 +318,22 @@ public abstract class RileyLinkCommunicationManager { RadioPacket pkt = new RadioPacket(injector, pumpMsgContent); RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0); if (resp.wasTimeout()) { - aapsLogger.warn(LTag.PUMPCOMM, "tune_tryFrequency: no pump response at frequency {}", freqMHz); + aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: no pump response at frequency {}", freqMHz); } else if (resp.looksLikeRadioPacket()) { RadioResponse radioResponse = new RadioResponse(injector); try { radioResponse.init(resp.getRaw()); if (radioResponse.isValid()) { - aapsLogger.warn(LTag.PUMPCOMM, "tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz); + aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz); return calculateRssi(radioResponse.rssi); } else { - aapsLogger.warn(LTag.PUMPCOMM, "tune_tryFrequency: invalid radio response:" + aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: invalid radio response:" + ByteUtil.shortHexString(radioResponse.getPayload())); } } catch (RileyLinkCommunicationException e) { - aapsLogger.warn(LTag.PUMPCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw())); + aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw())); } } @@ -360,13 +360,13 @@ public abstract class RileyLinkCommunicationManager { } if (betterFrequency == 0.0) { // we've failed... caller should try a full scan for pump - aapsLogger.error(LTag.PUMPCOMM, "quickTuneForPump: failed to find pump"); + aapsLogger.error(LTag.PUMPBTCOMM, "quickTuneForPump: failed to find pump"); } else { rfspy.setBaseFrequency(betterFrequency); if (betterFrequency != startFrequencyMHz) { - aapsLogger.info(LTag.PUMPCOMM, "quickTuneForPump: new frequency is {}MHz", betterFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: new frequency is {}MHz", betterFrequency); } else { - aapsLogger.info(LTag.PUMPCOMM, "quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz); + aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz); } } return betterFrequency; @@ -374,7 +374,7 @@ public abstract class RileyLinkCommunicationManager { private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) { - aapsLogger.info(LTag.PUMPCOMM, "Doing quick radio tune for receiver ({})", receiverDeviceID); + aapsLogger.info(LTag.PUMPBTCOMM, "Doing quick radio tune for receiver ({})", receiverDeviceID); wakeUp(false); int startRssi = tune_tryFrequency(startFrequencyMHz); double lowerFrequency = startFrequencyMHz - stepSizeMHz; @@ -413,7 +413,7 @@ public abstract class RileyLinkCommunicationManager { // Might still be zero, but that's fine. } double minutesAgo = (System.currentTimeMillis() - lastGoodReceiverCommunicationTime) / (1000.0 * 60.0); - aapsLogger.debug(LTag.PUMPCOMM, "Last good pump communication was " + minutesAgo + " minutes ago."); + aapsLogger.debug(LTag.PUMPBTCOMM, "Last good pump communication was " + minutesAgo + " minutes ago."); return lastGoodReceiverCommunicationTime; } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java index 66a3a446cb..32560664d0 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java @@ -118,7 +118,7 @@ public class RadioResponse { receivedCRC = decodeThis[decodeThis.length - 1]; byte calculatedCRC = CRC.crc8(decodedPayload); if (receivedCRC != calculatedCRC) { - aapsLogger.error(LTag.PUMPCOMM, String.format("RadioResponse: CRC mismatch, calculated 0x%02x, received 0x%02x", + aapsLogger.error(LTag.PUMPBTCOMM, String.format("RadioResponse: CRC mismatch, calculated 0x%02x, received 0x%02x", calculatedCRC, receivedCRC)); } } else { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicReadOperation.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicReadOperation.java index 09a3c58469..ea38e06069 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicReadOperation.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicReadOperation.java @@ -55,7 +55,7 @@ public class CharacteristicReadOperation extends BLECommOperation { public void gattOperationCompletionCallback(UUID uuid, byte[] value) { super.gattOperationCompletionCallback(uuid, value); if (!characteristic.getUuid().equals(uuid)) { - aapsLogger.error(LTag.PUMPCOMM, String.format( + aapsLogger.error(LTag.PUMPBTCOMM, String.format( "Completion callback: UUID does not match! out of sequence? Found: %s, should be %s", GattAttributes.lookup(characteristic.getUuid()), GattAttributes.lookup(uuid))); } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicWriteOperation.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicWriteOperation.java index 011135e7ac..772b1c1b21 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicWriteOperation.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/operations/CharacteristicWriteOperation.java @@ -58,7 +58,7 @@ public class CharacteristicWriteOperation extends BLECommOperation { @Override public void gattOperationCompletionCallback(UUID uuid, byte[] value) { if (!characteristic.getUuid().equals(uuid)) { - aapsLogger.error(LTag.PUMPCOMM, String.format( + aapsLogger.error(LTag.PUMPBTCOMM, String.format( "Completion callback: UUID does not match! out of sequence? Found: %s, should be %s", GattAttributes.lookup(characteristic.getUuid()), GattAttributes.lookup(uuid))); } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java index e8e0139524..337f8b5527 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java @@ -94,20 +94,20 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver { super.onReceive(context, intent); if (intent == null) { - aapsLogger.error(LTag.PUMPCOMM, "onReceive: received null intent"); + aapsLogger.error(LTag.PUMPBTCOMM, "onReceive: received null intent"); } else { String action = intent.getAction(); if (action == null) { aapsLogger.error("onReceive: null action"); } else { - aapsLogger.debug(LTag.PUMPCOMM, "Received Broadcast: " + action); + aapsLogger.debug(LTag.PUMPBTCOMM, "Received Broadcast: " + action); if (!processBluetoothBroadcasts(action) && // !processRileyLinkBroadcasts(action, context) && // !processTuneUpBroadcasts(action) && // !processApplicationSpecificBroadcasts(action, intent) // ) { - aapsLogger.error(LTag.PUMPCOMM, "Unhandled broadcast: action=" + action); + aapsLogger.error(LTag.PUMPBTCOMM, "Unhandled broadcast: action=" + action); } } } @@ -143,7 +143,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver { return true; } else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) { - aapsLogger.warn(LTag.PUMPCOMM, "RileyLinkConst.Intents.RileyLinkReady"); + aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady"); // sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump); rileyLinkService.rileyLinkBLE.enableNotifications(); @@ -154,16 +154,16 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver { RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion; // if (isLoggingEnabled()) - aapsLogger.debug(LTag.PUMPCOMM, "RfSpy version (BLE113): " + bleVersion); + aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): " + bleVersion); rileyLinkService.rileyLinkServiceData.versionBLE113 = bleVersion; // if (isLoggingEnabled()) - aapsLogger.debug(LTag.PUMPCOMM, "RfSpy Radio version (CC110): " + rlVersion.name()); + aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name()); this.rileyLinkServiceData.versionCC110 = rlVersion; ServiceTask task = new InitializePumpManagerTask(injector, context); serviceTaskExecutor.startTask(task); - aapsLogger.info(LTag.PUMPCOMM, "Announcing RileyLink open For business"); + aapsLogger.info(LTag.PUMPBTCOMM, "Announcing RileyLink open For business"); return true; } else if (action.equals(RileyLinkConst.Intents.RileyLinkNewAddressSet)) { @@ -192,13 +192,13 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver { public boolean processBluetoothBroadcasts(String action) { if (action.equals(RileyLinkConst.Intents.BluetoothConnected)) { - aapsLogger.debug(LTag.PUMPCOMM, "Bluetooth - Connected"); + aapsLogger.debug(LTag.PUMPBTCOMM, "Bluetooth - Connected"); serviceTaskExecutor.startTask(new DiscoverGattServicesTask(injector)); return true; } else if (action.equals(RileyLinkConst.Intents.BluetoothReconnected)) { - aapsLogger.debug(LTag.PUMPCOMM, "Bluetooth - Reconnecting"); + aapsLogger.debug(LTag.PUMPBTCOMM, "Bluetooth - Reconnecting"); getServiceInstance().bluetoothInit(); serviceTaskExecutor.startTask(new DiscoverGattServicesTask(injector, true)); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java index 0e340918c8..b4fb23d65f 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java @@ -81,14 +81,14 @@ public abstract class RileyLinkService extends DaggerService { @Override public boolean onUnbind(Intent intent) { - //aapsLogger.warn(LTag.PUMPCOMM, "onUnbind"); + //aapsLogger.warn(LTag.PUMPBTCOMM, "onUnbind"); return super.onUnbind(intent); } @Override public void onRebind(Intent intent) { - //aapsLogger.warn(LTag.PUMPCOMM, "onRebind"); + //aapsLogger.warn(LTag.PUMPBTCOMM, "onRebind"); super.onRebind(intent); } @@ -123,7 +123,7 @@ public abstract class RileyLinkService extends DaggerService { public boolean bluetoothInit() { - aapsLogger.debug(LTag.PUMPCOMM, "bluetoothInit: attempting to get an adapter"); + aapsLogger.debug(LTag.PUMPBTCOMM, "bluetoothInit: attempting to get an adapter"); rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.BluetoothInitializing); bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); @@ -153,10 +153,10 @@ public abstract class RileyLinkService extends DaggerService { if (rileyLinkBLE.isConnected()) { if (deviceAddress.equals(rileyLinkServiceData.rileylinkAddress)) { - aapsLogger.info(LTag.PUMPCOMM, "No change to RL address. Not reconnecting."); + aapsLogger.info(LTag.PUMPBTCOMM, "No change to RL address. Not reconnecting."); return false; } else { - aapsLogger.warn(LTag.PUMPCOMM, "Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress + aapsLogger.warn(LTag.PUMPBTCOMM, "Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress + "), reconnecting to new: " + deviceAddress); rileyLinkBLE.disconnect(); @@ -168,7 +168,7 @@ public abstract class RileyLinkService extends DaggerService { return true; } } else { - aapsLogger.debug(LTag.PUMPCOMM, "Using RL " + deviceAddress); + aapsLogger.debug(LTag.PUMPBTCOMM, "Using RL " + deviceAddress); if (rileyLinkServiceData.getRileyLinkServiceState() == RileyLinkServiceState.NotStarted) { if (!bluetoothInit()) { @@ -203,7 +203,7 @@ public abstract class RileyLinkService extends DaggerService { newFrequency = getDeviceCommunicationManager().tuneForDevice(); if ((newFrequency != 0.0) && (newFrequency != lastGoodFrequency)) { - aapsLogger.info(LTag.PUMPCOMM, "Saving new pump frequency of {} MHz", newFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, "Saving new pump frequency of {} MHz", newFrequency); sp.putDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, newFrequency); rileyLinkServiceData.lastGoodFrequency = newFrequency; rileyLinkServiceData.tuneUpDone = true; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java index 70e6440f0f..c7e49f6cd8 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java @@ -74,7 +74,7 @@ public class InitializePumpManagerTask extends ServiceTask { rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady); - aapsLogger.info(LTag.PUMPCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency); rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency); @@ -103,7 +103,7 @@ public class InitializePumpManagerTask extends ServiceTask { rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady); rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod; // TODO shouldn't be needed - aapsLogger.info(LTag.PUMPCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency); rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);