@@ -35,20 +34,23 @@ public abstract class RileyLinkCommunicationManager {
protected final RFSpy rfspy;
protected final Context context;
-
- private double[] scanFrequencies;
-
protected int receiverDeviceAwakeForMinutes = 1; // override this in constructor of specific implementation
protected String receiverDeviceID; // String representation of receiver device (ex. Pump (xxxxxx) or Pod (yyyyyy))
protected long lastGoodReceiverCommunicationTime = 0;
protected PumpStatus pumpStatus;
protected RileyLinkServiceData rileyLinkServiceData;
-
+ protected RileyLinkTargetFrequency targetFrequency;
+ private double[] scanFrequencies;
// internal flag
private boolean showPumpMessages = true;
- protected RileyLinkTargetFrequency targetFrequency;
+ private int timeoutCount = 0;
+ private long nextWakeUpRequired = 0L;
+ // protected PumpMessage sendAndListen(RLMessage msg) {
+ // return sendAndListen(msg, 4000); // 2000
+ // }
+
public RileyLinkCommunicationManager(Context context, RFSpy rfspy, RileyLinkTargetFrequency targetFrequency) {
this.context = context;
this.rfspy = rfspy;
@@ -64,14 +66,6 @@ public abstract class RileyLinkCommunicationManager {
protected abstract void configurePumpSpecificSettings();
- // protected PumpMessage sendAndListen(RLMessage msg) {
- // return sendAndListen(msg, 4000); // 2000
- // }
-
-
- private int timeoutCount = 0;
-
-
// All pump communications go through this function.
protected E sendAndListen(RLMessage msg, int timeout_ms, Class clazz) {
@@ -83,7 +77,7 @@ public abstract class RileyLinkCommunicationManager {
E response = createResponseMessage(rfSpyResponse.getRadioResponse().getPayload(), clazz);
- //PumpMessage rval = new PumpMessage(resp.getRadioResponse().getPayload());
+ // PumpMessage rval = new PumpMessage(resp.getRadioResponse().getPayload());
if (response.isValid()) {
// Mark this as the last time we heard from the pump.
rememberLastGoodDeviceCommunicationTime();
@@ -94,10 +88,11 @@ public abstract class RileyLinkCommunicationManager {
timeoutCount++;
if (timeoutCount >= 5) {
- RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.NoContactWithDevice);
+ RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorError,
+ RileyLinkError.NoContactWithDevice);
timeoutCount = 0;
tuneForDevice();
- //RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_quickTune);
+ // RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_quickTune);
}
}
@@ -118,9 +113,6 @@ public abstract class RileyLinkCommunicationManager {
}
- private long nextWakeUpRequired = 0L;
-
-
public int getNotConnectedCount() {
return rfspy != null ? rfspy.notConnectedCount : 0;
}
@@ -129,9 +121,9 @@ public abstract class RileyLinkCommunicationManager {
// FIXME change wakeup
// TODO we might need to fix this. Maybe make pump awake for shorter time (battery factor for pump) - Andy
public void wakeUp(int duration_minutes, boolean force) {
- // If it has been longer than n minutes, do wakeup. Otherwise assume pump is still awake.
+ // If it has been longer than n minutes, do wakeup. Otherwise assume pump is still awake.
// **** FIXME: this wakeup doesn't seem to work well... must revisit
- //receiverDeviceAwakeForMinutes = duration_minutes;
+ // receiverDeviceAwakeForMinutes = duration_minutes;
MedtronicUtil.setPumpDeviceState(PumpDeviceState.WakingUp);
@@ -142,7 +134,8 @@ public abstract class RileyLinkCommunicationManager {
LOG.info("Waking pump...");
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
- RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 200, (byte) 0, (byte) 0, 25000, (byte) 0);
+ RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte)0, (byte)200,
+ (byte)0, (byte)0, 25000, (byte)0);
LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
// FIXME wakeUp successful !!!!!!!!!!!!!!!!!!
@@ -152,18 +145,18 @@ public abstract class RileyLinkCommunicationManager {
LOG.trace("Last pump communication was recent, not waking pump.");
}
-
- // long lastGoodPlus = getLastGoodReceiverCommunicationTime() + (receiverDeviceAwakeForMinutes * 60 * 1000);
+ // long lastGoodPlus = getLastGoodReceiverCommunicationTime() + (receiverDeviceAwakeForMinutes * 60 * 1000);
//
- // if (System.currentTimeMillis() > lastGoodPlus || force) {
- // LOG.info("Waking pump...");
+ // if (System.currentTimeMillis() > lastGoodPlus || force) {
+ // LOG.info("Waking pump...");
//
- // byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.PowerOn);
- // RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 200, (byte) 0, (byte) 0, 15000, (byte) 0);
- // LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
- // } else {
- // LOG.trace("Last pump communication was recent, not waking pump.");
- // }
+ // byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.PowerOn);
+ // RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 200, (byte)
+ // 0, (byte) 0, 15000, (byte) 0);
+ // LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
+ // } else {
+ // LOG.trace("Last pump communication was recent, not waking pump.");
+ // }
}
@@ -178,7 +171,8 @@ public abstract class RileyLinkCommunicationManager {
/**
- * If user changes pump and one pump is running in US freq, and other in WW, then previously set frequency would be invalid,
+ * If user changes pump and one pump is running in US freq, and other in WW, then previously set frequency would be
+ * invalid,
* so we would need to retune. This checks that saved frequency is correct range.
*
* @param frequency
@@ -217,7 +211,8 @@ public abstract class RileyLinkCommunicationManager {
for (int j = 0; j < tries; j++) {
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData);
- RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 0, (byte) 0, (byte) 0, 1500, (byte) 0);
+ RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte)0, (byte)0,
+ (byte)0, (byte)0, 1500, (byte)0);
if (resp.wasTimeout()) {
LOG.error("scanForPump: Failed to find pump at frequency {}", frequencies[i]);
} else if (resp.looksLikeRadioPacket()) {
@@ -234,17 +229,17 @@ public abstract class RileyLinkCommunicationManager {
trial.tries++;
}
sumRSSI += -99.0 * (trial.tries - trial.successes);
- trial.averageRSSI = (double) (sumRSSI) / (double) (trial.tries);
+ trial.averageRSSI = (double)(sumRSSI) / (double)(trial.tries);
results.trials.add(trial);
}
-
StringBuilder stringBuilder = new StringBuilder("Scan results:\n");
for (int k = 0; k < results.trials.size(); k++) {
FrequencyTrial one = results.trials.get(k);
- stringBuilder.append(String.format("Scan Result[%s]: Freq=%s, avg RSSI = %s\n", "" + k, "" + one.frequencyMHz, "" + one.averageRSSI));
+ stringBuilder.append(String.format("Scan Result[%s]: Freq=%s, avg RSSI = %s\n", "" + k, ""
+ + one.frequencyMHz, "" + one.averageRSSI));
}
LOG.debug(stringBuilder.toString());
@@ -268,10 +263,10 @@ public abstract class RileyLinkCommunicationManager {
private int tune_tryFrequency(double freqMHz) {
rfspy.setBaseFrequency(freqMHz);
- //RLMessage msg = makeRLMessage(RLMessageType.ReadSimpleData);
+ // RLMessage msg = makeRLMessage(RLMessageType.ReadSimpleData);
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData);
RadioPacket pkt = new RadioPacket(pumpMsgContent);
- RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, rfspy.EXPECTED_MAX_BLUETOOTH_LATENCY_MS, (byte) 0);
+ RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte)0, (byte)0, (byte)0, (byte)0, 1500, (byte)0);
if (resp.wasTimeout()) {
LOG.warn("tune_tryFrequency: no pump response at frequency {}", freqMHz);
} else if (resp.looksLikeRadioPacket()) {
@@ -280,7 +275,8 @@ public abstract class RileyLinkCommunicationManager {
LOG.warn("tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz);
return radioResponse.rssi;
} else {
- LOG.warn("tune_tryFrequency: invalid radio response:" + ByteUtil.shortHexString(radioResponse.getPayload()));
+ LOG.warn("tune_tryFrequency: invalid radio response:"
+ + ByteUtil.shortHexString(radioResponse.getPayload()));
}
}
return 0;
@@ -297,7 +293,7 @@ public abstract class RileyLinkCommunicationManager {
// Try again at larger step size
stepsize += 0.05;
} else {
- if ((int) (evenBetterFrequency * 100) == (int) (betterFrequency * 100)) {
+ if ((int)(evenBetterFrequency * 100) == (int)(betterFrequency * 100)) {
// value did not change, so we're done.
break;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkConst.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkConst.java
index 4066e5aaa2..b29567d79b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkConst.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkConst.java
@@ -12,7 +12,7 @@ public class RileyLinkConst {
public static final String RileyLinkReady = Prefix + "RileyLink_Ready";
public static final String RileyLinkGattFailed = Prefix + "RileyLink_Gatt_Failed";
- //public static final String RileyLinkError = Prefix + "RileyLink_Ready";
+ // public static final String RileyLinkError = Prefix + "RileyLink_Ready";
public static final String BluetoothConnected = Prefix + "Bluetooth_Connected";
public static final String BluetoothReconnected = Prefix + "Bluetooth_Reconnected";
@@ -35,6 +35,7 @@ public class RileyLinkConst {
}
public class IPC {
+
// needs to br renamed (and maybe removed)
public static final String MSG_PUMP_quickTune = Prefix + "MSG_PUMP_quickTune";
public static final String MSG_PUMP_tunePump = Prefix + "MSG_PUMP_tunePump";
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkUtil.java
index 00d012ca36..af4b5dd621 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkUtil.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/RileyLinkUtil.java
@@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink;
-import android.content.Context;
-import android.content.Intent;
-import android.support.v4.content.LocalBroadcastManager;
+import java.util.ArrayList;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
+import android.content.Context;
+import android.content.Intent;
+import android.support.v4.content.LocalBroadcastManager;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkBLE;
@@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.Riley
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkServiceState;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.RileyLinkService;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.RileyLinkServiceData;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.data.ServiceNotification;
@@ -25,7 +26,6 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.PumpMedtronic.events.EventMedtronicDeviceStatusChange;
-
/**
* Created by andy on 17/05/2018.
*/
@@ -33,22 +33,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.events.EventMedtronicDev
public class RileyLinkUtil {
private static final Logger LOG = LoggerFactory.getLogger(RileyLinkUtil.class);
-
+ protected static List historyRileyLink = new ArrayList<>();
+ protected static RileyLinkCommunicationManager rileyLinkCommunicationManager;
+ static ServiceTask currentTask;
private static Context context;
private static RileyLinkBLE rileyLinkBLE;
private static RileyLinkServiceData rileyLinkServiceData;
- private static List historyRileyLink = new ArrayList<>();
- //private static PumpType pumpType;
- //private static MedtronicPumpStatus medtronicPumpStatus;
+ // private static PumpType pumpType;
+ // private static MedtronicPumpStatus medtronicPumpStatus;
private static RileyLinkService rileyLinkService;
- protected static RileyLinkCommunicationManager rileyLinkCommunicationManager;
- //private static RileyLinkIPCConnection rileyLinkIPCConnection;
+ // private static RileyLinkIPCConnection rileyLinkIPCConnection;
private static MedtronicDeviceType medtronicPumpModel;
- private static RileyLinkTargetFrequency rileyLinkTargetFrequency;
- //private static MedtronicPumpStatus pumpStatus;
+ // private static MedtronicPumpStatus pumpStatus;
// BAD dependencies in Classes: RileyLinkService
+ private static RileyLinkTargetFrequency rileyLinkTargetFrequency;
// Broadcasts: RileyLinkBLE, RileyLinkService,
+ private static RileyLinkTargetDevice targetDevice;
public static void setContext(Context contextIn) {
@@ -62,13 +63,13 @@ public class RileyLinkUtil {
}
- public static void setServiceState(RileyLinkServiceState newState) {
- setServiceState(newState, null);
+ public static RileyLinkServiceState getServiceState() {
+ return RileyLinkUtil.rileyLinkServiceData.serviceState;
}
- public static RileyLinkServiceState getServiceState() {
- return RileyLinkUtil.rileyLinkServiceData.serviceState;
+ public static void setServiceState(RileyLinkServiceState newState) {
+ setServiceState(newState, null);
}
@@ -81,23 +82,25 @@ public class RileyLinkUtil {
RileyLinkUtil.rileyLinkServiceData.serviceState = newState;
RileyLinkUtil.rileyLinkServiceData.errorCode = errorCode;
- LOG.warn("RileyLink State Changed: {} {}", newState, errorCode == null ? "" : " - Error State: " + errorCode.name());
+ LOG.warn("RileyLink State Changed: {} {}", newState,
+ errorCode == null ? "" : " - Error State: " + errorCode.name());
- RileyLinkUtil.historyRileyLink.add(new RLHistoryItem(RileyLinkUtil.rileyLinkServiceData.serviceState, RileyLinkUtil.rileyLinkServiceData.errorCode));
+ RileyLinkUtil.historyRileyLink.add(new RLHistoryItem(RileyLinkUtil.rileyLinkServiceData.serviceState,
+ RileyLinkUtil.rileyLinkServiceData.errorCode, targetDevice));
MainApp.bus().post(new EventMedtronicDeviceStatusChange(newState, errorCode));
}
- public static void setRileyLinkBLE(RileyLinkBLE rileyLinkBLEIn) {
- RileyLinkUtil.rileyLinkBLE = rileyLinkBLEIn;
- }
-
-
public static RileyLinkBLE getRileyLinkBLE() {
return RileyLinkUtil.rileyLinkBLE;
}
+ public static void setRileyLinkBLE(RileyLinkBLE rileyLinkBLEIn) {
+ RileyLinkUtil.rileyLinkBLE = rileyLinkBLEIn;
+ }
+
+
public static RileyLinkServiceData getRileyLinkServiceData() {
return RileyLinkUtil.rileyLinkServiceData;
}
@@ -113,18 +116,13 @@ public class RileyLinkUtil {
}
- public static void setRileyLinkService(RileyLinkService rileyLinkService) {
- RileyLinkUtil.rileyLinkService = rileyLinkService;
- }
-
-
public static RileyLinkService getRileyLinkService() {
return RileyLinkUtil.rileyLinkService;
}
- public static void setRileyLinkCommunicationManager(RileyLinkCommunicationManager rileyLinkCommunicationManager) {
- RileyLinkUtil.rileyLinkCommunicationManager = rileyLinkCommunicationManager;
+ public static void setRileyLinkService(RileyLinkService rileyLinkService) {
+ RileyLinkUtil.rileyLinkService = rileyLinkService;
}
@@ -133,13 +131,16 @@ public class RileyLinkUtil {
}
+ public static void setRileyLinkCommunicationManager(RileyLinkCommunicationManager rileyLinkCommunicationManager) {
+ RileyLinkUtil.rileyLinkCommunicationManager = rileyLinkCommunicationManager;
+ }
+
+
public static boolean sendNotification(ServiceNotification notification, Integer clientHashcode) {
return RileyLinkUtil.rileyLinkService.sendNotification(notification, clientHashcode);
}
- static ServiceTask currentTask;
-
// FIXME remove ?
public static void setCurrentTask(ServiceTask task) {
if (currentTask == null) {
@@ -170,14 +171,18 @@ public class RileyLinkUtil {
// make a new bundle to send as the message data
transport.setServiceResult(serviceResult);
// FIXME
- //transport.setTransportType(RT2Const.IPC.MSG_ServiceResult);
- //rileyLinkIPCConnection.sendTransport(transport, clientHashcode);
+ // transport.setTransportType(RT2Const.IPC.MSG_ServiceResult);
+ // rileyLinkIPCConnection.sendTransport(transport, clientHashcode);
}
-// public static void setRileyLinkIPCConnection(RileyLinkIPCConnection rileyLinkIPCConnection) {
-// RileyLinkUtil.rileyLinkIPCConnection = rileyLinkIPCConnection;
-// }
+ // public static void setRileyLinkIPCConnection(RileyLinkIPCConnection rileyLinkIPCConnection) {
+ // RileyLinkUtil.rileyLinkIPCConnection = rileyLinkIPCConnection;
+ // }
+
+ public static RileyLinkTargetFrequency getRileyLinkTargetFrequency() {
+ return RileyLinkUtil.rileyLinkTargetFrequency;
+ }
public static void setRileyLinkTargetFrequency(RileyLinkTargetFrequency rileyLinkTargetFrequency) {
@@ -185,15 +190,25 @@ public class RileyLinkUtil {
}
- public static RileyLinkTargetFrequency getRileyLinkTargetFrequency() {
- return RileyLinkUtil.rileyLinkTargetFrequency;
- }
-
-
public static boolean isSame(Double d1, Double d2) {
double diff = d1 - d2;
return (Math.abs(diff) <= 0.000001);
}
+
+ public static List getRileyLinkHistory() {
+ return historyRileyLink;
+ }
+
+
+ public static RileyLinkTargetDevice getTargetDevice() {
+ return targetDevice;
+ }
+
+
+ public static void setTargetDevice(RileyLinkTargetDevice targetDevice) {
+ RileyLinkUtil.targetDevice = targetDevice;
+ }
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpy.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpy.java
index 5077f93e3d..88d82f83b1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpy.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpy.java
@@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble;
-import android.os.SystemClock;
+import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.UUID;
+import android.os.SystemClock;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
@@ -26,18 +26,13 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.ThreadUtil;
*/
public class RFSpy {
- private static final Logger LOG = LoggerFactory.getLogger(RFSpy.class);
-
-
public static final long RILEYLINK_FREQ_XTAL = 24000000;
-
-
public static final int EXPECTED_MAX_BLUETOOTH_LATENCY_MS = 7500; // 1500
-
+ private static final Logger LOG = LoggerFactory.getLogger(RFSpy.class);
+ public int notConnectedCount = 0;
private RileyLinkBLE rileyLinkBle;
private RFSpyReader reader;
private RileyLinkTargetFrequency selectedTargetFrequency;
-
private UUID radioServiceUUID = UUID.fromString(GattAttributes.SERVICE_RADIO);
private UUID radioDataUUID = UUID.fromString(GattAttributes.CHARA_RADIO_DATA);
private UUID radioVersionUUID = UUID.fromString(GattAttributes.CHARA_RADIO_VERSION);
@@ -54,6 +49,7 @@ public class RFSpy {
// Starts an async task to read when data is available
public void startReader() {
rileyLinkBle.registerRadioResponseCountNotification(new Runnable() {
+
@Override
public void run() {
newDataIsAvailable();
@@ -70,8 +66,6 @@ public class RFSpy {
}
- public int notConnectedCount = 0;
-
// This gets the version from the BLE113, not from the CC1110.
// I.e., this gets the version from the BLE interface, not from the radio.
public String getVersion() {
@@ -84,6 +78,7 @@ public class RFSpy {
}
}
+
public String getRadioVersion() {
RFSpyResponse resp = writeToData(RFSpyCommand.GetVersion, null, EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
if (resp == null) {
@@ -105,19 +100,21 @@ public class RFSpy {
byte[] junkInBuffer = reader.poll(0);
while (junkInBuffer != null) {
- LOG.warn(ThreadUtil.sig() + "writeToData: draining read queue, found this: " + ByteUtil.shortHexString(junkInBuffer));
+ LOG.warn(ThreadUtil.sig() + "writeToData: draining read queue, found this: "
+ + ByteUtil.shortHexString(junkInBuffer));
junkInBuffer = reader.poll(0);
}
// prepend length, and send it.
- byte[] prepended = ByteUtil.concat(new byte[]{(byte) (bytes.length)}, bytes);
- BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID, prepended);
+ byte[] prepended = ByteUtil.concat(new byte[] { (byte)(bytes.length) }, bytes);
+ BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID,
+ prepended);
if (writeCheck.resultCode != BLECommOperationResult.RESULT_SUCCESS) {
LOG.error("BLE Write operation failed, code=" + writeCheck.resultCode);
return new RFSpyResponse(); // will be a null (invalid) response
}
SystemClock.sleep(100);
- //Log.i(TAG,ThreadUtil.sig()+String.format(" writeToData:(timeout %d) %s",(responseTimeout_ms),ByteUtil.shortHexString(prepended)));
+ // Log.i(TAG,ThreadUtil.sig()+String.format(" writeToData:(timeout %d) %s",(responseTimeout_ms),ByteUtil.shortHexString(prepended)));
byte[] rawResponse = reader.poll(responseTimeout_ms);
RFSpyResponse resp = new RFSpyResponse(command, rawResponse);
if (rawResponse == null) {
@@ -139,16 +136,18 @@ public class RFSpy {
LOG.info("writeToData: decoded radio response is " + ByteUtil.shortHexString(responsePayload));
resetNotConnectedCount();
}
- //Log.i(TAG, "writeToData: raw response is " + ByteUtil.shortHexString(rawResponse));
+ // Log.i(TAG, "writeToData: raw response is " + ByteUtil.shortHexString(rawResponse));
}
}
return resp;
}
+
private void resetNotConnectedCount() {
this.notConnectedCount = 0;
}
+
private byte[] getByteArray(byte... input) {
return input;
}
@@ -173,52 +172,60 @@ public class RFSpy {
public RFSpyResponse transmit(RadioPacket radioPacket) {
- return transmit(radioPacket, (byte) 0, (byte) 0, (byte) 0xFF);
+ return transmit(radioPacket, (byte)0, (byte)0, (byte)0xFF);
}
public RFSpyResponse transmit(RadioPacket radioPacket, byte sendChannel, byte repeatCount, byte delay_ms) {
// append checksum, encode data, send it.
byte[] fullPacket = ByteUtil.concat(getByteArray(sendChannel, repeatCount, delay_ms), radioPacket.getEncoded());
- RFSpyResponse response = writeToData(RFSpyCommand.Send, fullPacket, delay_ms + EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
+ RFSpyResponse response = writeToData(RFSpyCommand.Send, fullPacket, delay_ms
+ + EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
return response;
}
public RFSpyResponse receive(byte listenChannel, int timeout_ms, byte retryCount) {
int receiveDelay = timeout_ms * (retryCount + 1);
- byte[] listen = getByteArray(listenChannel, (byte) ((timeout_ms >> 24) & 0x0FF), (byte) ((timeout_ms >> 16) & 0x0FF), (byte) ((timeout_ms >> 8) & 0x0FF), (byte) (timeout_ms & 0x0FF), retryCount);
+ byte[] listen = getByteArray(listenChannel, (byte)((timeout_ms >> 24) & 0x0FF),
+ (byte)((timeout_ms >> 16) & 0x0FF), (byte)((timeout_ms >> 8) & 0x0FF), (byte)(timeout_ms & 0x0FF),
+ retryCount);
return writeToData(RFSpyCommand.GetPacket, listen, receiveDelay);
}
public RFSpyResponse transmitThenReceive(RadioPacket pkt, int timeout_ms) {
- return transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, timeout_ms, (byte) 0);
+ return transmitThenReceive(pkt, (byte)0, (byte)0, (byte)0, (byte)0, timeout_ms, (byte)0);
}
- public RFSpyResponse transmitThenReceive(RadioPacket pkt, byte sendChannel, byte repeatCount, byte delay_ms, byte listenChannel, int timeout_ms, byte retryCount) {
+ public RFSpyResponse transmitThenReceive(RadioPacket pkt, byte sendChannel, byte repeatCount, byte delay_ms,
+ byte listenChannel, int timeout_ms, byte retryCount) {
int sendDelay = repeatCount * delay_ms;
int receiveDelay = timeout_ms * (retryCount + 1);
- byte[] sendAndListen = getByteArray(sendChannel, repeatCount, delay_ms, listenChannel, (byte) ((timeout_ms >> 24) & 0x0FF), (byte) ((timeout_ms >> 16) & 0x0FF), (byte) ((timeout_ms >> 8) & 0x0FF), (byte) (timeout_ms & 0x0FF), (byte) retryCount);
+ byte[] sendAndListen = getByteArray(sendChannel, repeatCount, delay_ms, listenChannel,
+ (byte)((timeout_ms >> 24) & 0x0FF), (byte)((timeout_ms >> 16) & 0x0FF), (byte)((timeout_ms >> 8) & 0x0FF),
+ (byte)(timeout_ms & 0x0FF), (byte)retryCount);
byte[] fullPacket = ByteUtil.concat(sendAndListen, pkt.getEncoded());
- return writeToData(RFSpyCommand.SendAndListen, fullPacket, sendDelay + receiveDelay + EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
+ return writeToData(RFSpyCommand.SendAndListen, fullPacket, sendDelay + receiveDelay
+ + EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
}
public RFSpyResponse updateRegister(CC111XRegister reg, int val) {
- byte[] updateRegisterPkt = getByteArray(reg.value, (byte) val);
- RFSpyResponse resp = writeToData(RFSpyCommand.UpdateRegister, updateRegisterPkt, EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
+ byte[] updateRegisterPkt = getByteArray(reg.value, (byte)val);
+ RFSpyResponse resp = writeToData(RFSpyCommand.UpdateRegister, updateRegisterPkt,
+ EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
return resp;
}
public void setBaseFrequency(double freqMHz) {
- int value = (int) (freqMHz * 1000000 / ((double) (RILEYLINK_FREQ_XTAL) / Math.pow(2.0, 16.0)));
- updateRegister(CC111XRegister.freq0, (byte) (value & 0xff));
- updateRegister(CC111XRegister.freq1, (byte) ((value >> 8) & 0xff));
- updateRegister(CC111XRegister.freq2, (byte) ((value >> 16) & 0xff));
+ int value = (int)(freqMHz * 1000000 / ((double)(RILEYLINK_FREQ_XTAL) / Math.pow(2.0, 16.0)));
+ updateRegister(CC111XRegister.freq0, (byte)(value & 0xff));
+ updateRegister(CC111XRegister.freq1, (byte)((value >> 8) & 0xff));
+ updateRegister(CC111XRegister.freq2, (byte)((value >> 16) & 0xff));
LOG.warn("Set frequency to {}", freqMHz);
configureRadioForRegion(RileyLinkUtil.getRileyLinkTargetFrequency());
@@ -234,24 +241,24 @@ public class RFSpy {
switch (frequency) {
case Medtronic_WorldWide: {
setRXFilterMode(RXFilterMode.Wide);
- //updateRegister(CC111X_MDMCFG3, (byte) 0x66);
- //updateRegister(CC111X_MDMCFG2, (byte) 0x33);
+ // updateRegister(CC111X_MDMCFG3, (byte) 0x66);
+ // updateRegister(CC111X_MDMCFG2, (byte) 0x33);
updateRegister(CC111XRegister.mdmcfg1, 0x62);
updateRegister(CC111XRegister.mdmcfg0, 0x1A);
updateRegister(CC111XRegister.deviatn, 0x13);
}
- break;
+ break;
case Medtronic_US: {
setRXFilterMode(RXFilterMode.Narrow);
- //updateRegister(CC111X_MDMCFG3, (byte) 0x66);
- //updateRegister(CC111X_MDMCFG2, (byte) 0x33);
+ // updateRegister(CC111X_MDMCFG3, (byte) 0x66);
+ // updateRegister(CC111X_MDMCFG2, (byte) 0x33);
updateRegister(CC111XRegister.mdmcfg1, 0x61);
updateRegister(CC111XRegister.mdmcfg0, 0x7E);
updateRegister(CC111XRegister.deviatn, 0x15);
}
- break;
+ break;
case Omnipod: {
LOG.debug("No region configuration for RfSpy and {}", frequency.name());
@@ -269,11 +276,10 @@ public class RFSpy {
private void setRXFilterMode(RXFilterMode mode) {
- byte drate_e = (byte) 0x9; // exponent of symbol rate (16kbps)
+ byte drate_e = (byte)0x9; // exponent of symbol rate (16kbps)
byte chanbw = mode.value;
- updateRegister(CC111XRegister.mdmcfg4, (byte) (chanbw | drate_e));
+ updateRegister(CC111XRegister.mdmcfg4, (byte)(chanbw | drate_e));
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpyReader.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpyReader.java
index 9d8cfff559..97b04c8f55 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpyReader.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFSpyReader.java
@@ -1,16 +1,16 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble;
-import android.os.AsyncTask;
-import android.os.SystemClock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.UUID;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import android.os.AsyncTask;
+import android.os.SystemClock;
+
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.operations.BLECommOperationResult;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
@@ -22,24 +22,23 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.ThreadUtil;
public class RFSpyReader {
private static final Logger LOG = LoggerFactory.getLogger(RFSpyReader.class);
-
- //private Context context;
+ AsyncTask readerTask;
+ // private Context context;
private RileyLinkBLE rileyLinkBle;
private Semaphore waitForRadioData = new Semaphore(0, true);
- AsyncTask readerTask;
private LinkedBlockingQueue mDataQueue = new LinkedBlockingQueue<>();
private int acquireCount = 0;
private int releaseCount = 0;
- public RFSpyReader(/*Context context,*/ RileyLinkBLE rileyLinkBle) {
- //this.context = context;
+ public RFSpyReader(/* Context context, */RileyLinkBLE rileyLinkBle) {
+ // this.context = context;
this.rileyLinkBle = rileyLinkBle;
}
- public void init(/*Context context,*/ RileyLinkBLE rileyLinkBLE) {
- //this.context = context;
+ public void init(/* Context context, */RileyLinkBLE rileyLinkBLE) {
+ // this.context = context;
this.rileyLinkBle = rileyLinkBLE;
}
@@ -54,14 +53,16 @@ public class RFSpyReader {
// This timeout must be coordinated with the length of the RFSpy radio operation or Bad Things Happen.
public byte[] poll(int timeout_ms) {
- LOG.trace(ThreadUtil.sig() + "Entering poll at t==" + SystemClock.uptimeMillis() + ", timeout is " + timeout_ms + " mDataQueue size is " + mDataQueue.size());
+ LOG.trace(ThreadUtil.sig() + "Entering poll at t==" + SystemClock.uptimeMillis() + ", timeout is " + timeout_ms
+ + " mDataQueue size is " + mDataQueue.size());
if (mDataQueue.isEmpty())
try {
// block until timeout or data available.
// returns null if timeout.
byte[] dataFromQueue = mDataQueue.poll(timeout_ms, TimeUnit.MILLISECONDS);
if (dataFromQueue != null) {
- LOG.debug("Got data [" + ByteUtil.shortHexString(dataFromQueue) + "] at t==" + SystemClock.uptimeMillis());
+ LOG.debug("Got data [" + ByteUtil.shortHexString(dataFromQueue) + "] at t=="
+ + SystemClock.uptimeMillis());
} else {
LOG.debug("Got data [null] at t==" + SystemClock.uptimeMillis());
}
@@ -77,13 +78,15 @@ public class RFSpyReader {
public void newDataIsAvailable() {
releaseCount++;
- LOG.trace(ThreadUtil.sig() + "waitForRadioData released(count=" + releaseCount + ") at t=" + SystemClock.uptimeMillis());
+ LOG.trace(ThreadUtil.sig() + "waitForRadioData released(count=" + releaseCount + ") at t="
+ + SystemClock.uptimeMillis());
waitForRadioData.release();
}
public void start() {
readerTask = new AsyncTask() {
+
@Override
protected Void doInBackground(Void... voids) {
UUID serviceUUID = UUID.fromString(GattAttributes.SERVICE_RADIO);
@@ -93,7 +96,8 @@ public class RFSpyReader {
try {
acquireCount++;
waitForRadioData.acquire();
- LOG.trace(ThreadUtil.sig() + "waitForRadioData acquired (count=" + acquireCount + ") at t=" + SystemClock.uptimeMillis());
+ LOG.trace(ThreadUtil.sig() + "waitForRadioData acquired (count=" + acquireCount + ") at t="
+ + SystemClock.uptimeMillis());
SystemClock.sleep(100);
SystemClock.sleep(1);
result = rileyLinkBle.readCharacteristic_blocking(serviceUUID, radioDataUUID);
@@ -101,7 +105,7 @@ public class RFSpyReader {
if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) {
// only data up to the first null is valid
- for(int i = 0; i < result.value.length; i++) {
+ for (int i = 0; i < result.value.length; i++) {
if (result.value[i] == 0) {
result.value = ByteUtil.substring(result.value, 0, i);
break;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFTools.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFTools.java
index 45d401f3c0..eac1215a9b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFTools.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RFTools.java
@@ -1,10 +1,10 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble;
+import java.util.ArrayList;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.CRC;
@@ -13,17 +13,18 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.CRC;
*/
public class RFTools {
+ public static final byte[] codes = new byte[] { 21, 49, 50, 35, 52, 37, 38, 22, 26, 25, 42, 11, 44, 13, 14, 28 };
private static final Logger LOG = LoggerFactory.getLogger(RFTools.class);
-
-
+ private final static char[] HEX_DIGITS = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/*
- CodeSymbols is an ordered list of translations
- 6bits -> 4 bits, in order from 0x0 to 0xF
- The 6 bit codes are what is used on the RF side of the RileyLink
- to communicate with a Medtronic pump.
-
+ * CodeSymbols is an ordered list of translations
+ * 6bits -> 4 bits, in order from 0x0 to 0xF
+ * The 6 bit codes are what is used on the RF side of the RileyLink
+ * to communicate with a Medtronic pump.
*/
- public static byte[] CodeSymbols = {0x15, 0x31, 0x32, 0x23, 0x34, 0x25, 0x26, 0x16, 0x1a, 0x19, 0x2a, 0x0b, 0x2c, 0x0d, 0x0e, 0x1c};
+ public static byte[] CodeSymbols = {
+ 0x15, 0x31, 0x32, 0x23, 0x34, 0x25, 0x26, 0x16, 0x1a, 0x19, 0x2a, 0x0b, 0x2c, 0x0d, 0x0e, 0x1c };
public static byte[] appendChecksum(final byte[] input) {
@@ -36,15 +37,51 @@ public class RFTools {
byte[] rval = new byte[input.length + 1];
System.arraycopy(input, 0, rval, 0, input.length);
byte mycrc = CRC.crc8(input);
- LOG.debug(String.format("Adding checksum 0x%02X to %d byte array from 0x%02X to 0x%02X", mycrc, input.length, input[0], input[input.length - 1]));
+ LOG.debug(String.format("Adding checksum 0x%02X to %d byte array from 0x%02X to 0x%02X", mycrc, input.length,
+ input[0], input[input.length - 1]));
rval[input.length] = mycrc;
return rval;
}
+ /*
+ * + (NSData*)encode4b6b:(NSData*)data {
+ * NSMutableData *outData = [NSMutableData data];
+ * NSMutableData *dataPlusCrc = [data mutableCopy];
+ * unsigned char crc = [MinimedPacket crcForData:data];
+ * [dataPlusCrc appendBytes:&crc length:1];
+ * char codes[16] = {21,49,50,35,52,37,38,22,26,25,42,11,44,13,14,28};
+ * const unsigned char *inBytes = [dataPlusCrc bytes];
+ * unsigned int acc = 0x0;
+ * int bitcount = 0;
+ * for (int i=0; i < dataPlusCrc.length; i++) {
+ * acc <<= 6;
+ * acc |= codes[inBytes[i] >> 4];
+ * bitcount += 6;
+ *
+ * acc <<= 6;
+ * acc |= codes[inBytes[i] & 0x0f];
+ * bitcount += 6;
+ *
+ * while (bitcount >= 8) {
+ * unsigned char outByte = acc >> (bitcount-8) & 0xff;
+ * [outData appendBytes:&outByte length:1];
+ * bitcount -= 8;
+ * acc &= (0xffff >> (16-bitcount));
+ * }
+ * }
+ * if (bitcount > 0) {
+ * acc <<= (8-bitcount);
+ * unsigned char outByte = acc & 0xff;
+ * [outData appendBytes:&outByte length:1];
+ * }
+ * return outData;
+ * }
+ */
+
public static ArrayList fromBytes(byte[] data) {
ArrayList rval = new ArrayList<>();
- for(int i = 0; i < data.length; i++) {
+ for (int i = 0; i < data.length; i++) {
rval.add(data[i]);
}
return rval;
@@ -53,53 +90,16 @@ public class RFTools {
public static byte[] toBytes(ArrayList data) {
byte[] rval = new byte[data.size()];
- for(int i = 0; i < data.size(); i++) {
+ for (int i = 0; i < data.size(); i++) {
rval[i] = data.get(i);
}
return rval;
}
-/*
- + (NSData*)encode4b6b:(NSData*)data {
- NSMutableData *outData = [NSMutableData data];
- NSMutableData *dataPlusCrc = [data mutableCopy];
- unsigned char crc = [MinimedPacket crcForData:data];
- [dataPlusCrc appendBytes:&crc length:1];
- char codes[16] = {21,49,50,35,52,37,38,22,26,25,42,11,44,13,14,28};
- const unsigned char *inBytes = [dataPlusCrc bytes];
- unsigned int acc = 0x0;
- int bitcount = 0;
- for (int i=0; i < dataPlusCrc.length; i++) {
- acc <<= 6;
- acc |= codes[inBytes[i] >> 4];
- bitcount += 6;
- acc <<= 6;
- acc |= codes[inBytes[i] & 0x0f];
- bitcount += 6;
-
- while (bitcount >= 8) {
- unsigned char outByte = acc >> (bitcount-8) & 0xff;
- [outData appendBytes:&outByte length:1];
- bitcount -= 8;
- acc &= (0xffff >> (16-bitcount));
- }
- }
- if (bitcount > 0) {
- acc <<= (8-bitcount);
- unsigned char outByte = acc & 0xff;
- [outData appendBytes:&outByte length:1];
- }
- return outData;
- }
-*/
-
- public static final byte[] codes = new byte[]{21, 49, 50, 35, 52, 37, 38, 22, 26, 25, 42, 11, 44, 13, 14, 28};
-
-
- /* O(n) lookup. Run on an O(n) translation of a byte-stream, gives O(n**2) performance. Sigh. */
+ /* O(n) lookup. Run on an O(n) translation of a byte-stream, gives O(n**2) performance. Sigh. */
public static int codeIndex(byte b) {
- for(int i = 0; i < codes.length; i++) {
+ for (int i = 0; i < codes.length; i++) {
if (b == codes[i]) {
return i;
}
@@ -119,7 +119,7 @@ public class RFTools {
int acc = 0;
int bitcount = 0;
int i;
- for(i = 0; i < inData.size(); i++) {
+ for (i = 0; i < inData.size(); i++) {
acc <<= 6;
acc |= codes[(inData.get(i) >> 4) & 0x0f];
bitcount += 6;
@@ -129,7 +129,7 @@ public class RFTools {
bitcount += 6;
while (bitcount >= 8) {
- byte outByte = (byte) (acc >> (bitcount - 8) & 0xff);
+ byte outByte = (byte)(acc >> (bitcount - 8) & 0xff);
outData.add(outByte);
bitcount -= 8;
acc &= (0xffff >> (16 - bitcount));
@@ -140,18 +140,17 @@ public class RFTools {
acc |= 0x14; // marks uneven packet boundary.
bitcount += 6;
if (bitcount >= 8) {
- byte outByte = (byte) ((acc >> (bitcount - 8)) & 0xff);
+ byte outByte = (byte)((acc >> (bitcount - 8)) & 0xff);
outData.add(outByte);
bitcount -= 8;
// acc &= (0xffff >> (16 - bitcount));
}
while (bitcount >= 8) {
- outData.add((byte) 0);
+ outData.add((byte)0);
bitcount -= 8;
}
}
-
// convert back to byte[]
byte[] rval = toBytes(outData);
@@ -162,14 +161,14 @@ public class RFTools {
public static void test() {
/*
- {0xa7} -> {0xa9, 0x60}
- {0xa7, 0x12} -> {0xa9, 0x6c, 0x72}
- {0xa7, 0x12, 0xa7} -> {0xa9, 0x6c, 0x72, 0xa9, 0x60}
- */
+ * {0xa7} -> {0xa9, 0x60}
+ * {0xa7, 0x12} -> {0xa9, 0x6c, 0x72}
+ * {0xa7, 0x12, 0xa7} -> {0xa9, 0x6c, 0x72, 0xa9, 0x60}
+ */
/* test compare */
- byte[] s1 = {0, 1, 2};
- byte[] s2 = {2, 1, 0, 3};
- byte[] s3 = {0, 1, 2, 3};
+ byte[] s1 = { 0, 1, 2 };
+ byte[] s2 = { 2, 1, 0, 3 };
+ byte[] s3 = { 0, 1, 2, 3 };
if (ByteUtil.compare(s1, s1) != 0) {
LOG.error("test: compare failed.");
}
@@ -182,21 +181,24 @@ public class RFTools {
if (ByteUtil.compare(s1, s3) >= 0) {
LOG.error("test: compare failed.");
}
- //testCompose(new byte[] {(byte)0xa7, (byte)0xa7});
- byte[] bs = encode4b6b(new byte[]{(byte) 0xa7});
- byte[] out = new byte[]{(byte) (0xa9), 0x65};
+ // testCompose(new byte[] {(byte)0xa7, (byte)0xa7});
+ byte[] bs = encode4b6b(new byte[] { (byte)0xa7 });
+ byte[] out = new byte[] { (byte)(0xa9), 0x65 };
if (ByteUtil.compare(bs, out) != 0) {
- LOG.error("encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " + ByteUtil.shortHexString(bs));
+ LOG.error("encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ + ByteUtil.shortHexString(bs));
}
- bs = encode4b6b(new byte[]{(byte) 0xa7, 0x12});
- out = new byte[]{(byte) (0xa9), 0x6c, 0x72};
+ bs = encode4b6b(new byte[] { (byte)0xa7, 0x12 });
+ out = new byte[] { (byte)(0xa9), 0x6c, 0x72 };
if (ByteUtil.compare(bs, out) != 0) {
- LOG.error("encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " + ByteUtil.shortHexString(bs));
+ LOG.error("encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ + ByteUtil.shortHexString(bs));
}
- bs = encode4b6b(new byte[]{(byte) 0xa7, 0x12, (byte) 0xa7});
- out = new byte[]{(byte) (0xa9), 0x6c, 0x72, (byte) 0xa9, 0x65};
+ bs = encode4b6b(new byte[] { (byte)0xa7, 0x12, (byte)0xa7 });
+ out = new byte[] { (byte)(0xa9), 0x6c, 0x72, (byte)0xa9, 0x65 };
if (ByteUtil.compare(bs, out) != 0) {
- LOG.error("encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " + ByteUtil.shortHexString(bs));
+ LOG.error("encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ + ByteUtil.shortHexString(bs));
}
return;
}
@@ -204,17 +206,17 @@ public class RFTools {
public static byte[] decode4b6b(byte[] raw) throws NumberFormatException {
/*
- if ((raw.length % 2) != 0) {
- LOG.error("Warning: data is odd number of bytes");
- }
- */
- byte[] rval = new byte[]{};
+ * if ((raw.length % 2) != 0) {
+ * LOG.error("Warning: data is odd number of bytes");
+ * }
+ */
+ byte[] rval = new byte[] {};
int availableBits = 0;
int codingErrors = 0;
int x = 0;
- //Log.w(TAG,"decode4b6b: untested code");
- //Log.w(TAG,String.format("Decoding %d bytes: %s",raw.length,ByteUtil.shortHexString(raw)));
- for(int i = 0; i < raw.length; i++) {
+ // Log.w(TAG,"decode4b6b: untested code");
+ // Log.w(TAG,String.format("Decoding %d bytes: %s",raw.length,ByteUtil.shortHexString(raw)));
+ for (int i = 0; i < raw.length; i++) {
int unsignedValue = raw[i];
if (unsignedValue < 0) {
unsignedValue += 256;
@@ -224,27 +226,31 @@ public class RFTools {
if (availableBits >= 12) {
// take top six
int highcode = (x >> (availableBits - 6)) & 0x3F;
- int highIndex = codeIndex((byte) (highcode));
+ int highIndex = codeIndex((byte)(highcode));
// take bottom six
int lowcode = (x >> (availableBits - 12)) & 0x3F;
- int lowIndex = codeIndex((byte) (lowcode));
+ int lowIndex = codeIndex((byte)(lowcode));
// special case at end of transmission on uneven boundaries:
if ((highIndex >= 0) && (lowIndex >= 0)) {
- byte decoded = (byte) ((highIndex << 4) + lowIndex);
+ byte decoded = (byte)((highIndex << 4) + lowIndex);
rval = ByteUtil.concat(rval, decoded);
/*
- LOG.debug(String.format("i=%d,x=0x%08X,0x%02X->0x%02X, 0x%02X->0x%02X, result: 0x%02X, %d bits remaining, errors %d, bytes remaining: %s",
- i,x,highcode,highIndex, lowcode, lowIndex,decoded,availableBits,codingErrors,ByteUtil.shortHexString(ByteUtil.substring(raw,i+1,raw.length-i-1))));
- */
+ * LOG.debug(String.format(
+ * "i=%d,x=0x%08X,0x%02X->0x%02X, 0x%02X->0x%02X, result: 0x%02X, %d bits remaining, errors %d, bytes remaining: %s"
+ * ,
+ * i,x,highcode,highIndex, lowcode,
+ * lowIndex,decoded,availableBits,codingErrors,ByteUtil.shortHexString
+ * (ByteUtil.substring(raw,i+1,raw.length-i-1))));
+ */
} else {
- //LOG.debug(String.format("i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining",i,x,highcode,lowcode,availableBits));
+ // LOG.debug(String.format("i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining",i,x,highcode,lowcode,availableBits));
codingErrors++;
}
availableBits -= 12;
x = x & (0x0000ffff >> (16 - availableBits));
} else {
- //LOG.debug(String.format("i=%d, skip: x=0x%08X, available bits %d",i,x,availableBits));
+ // LOG.debug(String.format("i=%d, skip: x=0x%08X, available bits %d",i,x,availableBits));
}
}
if (availableBits != 0) {
@@ -270,14 +276,11 @@ public class RFTools {
}
- private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-
-
public static String toHexString(byte[] array, int offset, int length) {
char[] buf = new char[length * 2];
int bufIndex = 0;
- for(int i = offset; i < offset + length; i++) {
+ for (int i = offset; i < offset + length; i++) {
byte b = array[i];
buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
@@ -286,5 +289,4 @@ public class RFTools {
return new String(buf);
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RileyLinkBLE.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RileyLinkBLE.java
index a955a210fe..8991d3b505 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RileyLinkBLE.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/RileyLinkBLE.java
@@ -1,5 +1,13 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.Semaphore;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
@@ -12,14 +20,6 @@ import android.content.Context;
import android.os.SystemClock;
import android.widget.Toast;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.Semaphore;
-
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
@@ -40,22 +40,16 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.ThreadUtil;
public class RileyLinkBLE {
private static final Logger LOG = LoggerFactory.getLogger(RFTools.class);
-
+ private final Context context;
public boolean gattDebugEnabled = true;
-
+ boolean manualDisconnect = false;
private BluetoothAdapter bluetoothAdapter;
private BluetoothGattCallback bluetoothGattCallback;
-
- private final Context context;
-
private BluetoothDevice rileyLinkDevice;
private BluetoothGatt bluetoothConnectionGatt = null;
-
private BLECommOperation mCurrentOperation;
private Semaphore gattOperationSema = new Semaphore(1, true);
-
private Runnable radioResponseCountNotified;
-
private boolean mIsConnected = false;
@@ -67,10 +61,13 @@ public class RileyLinkBLE {
bluetoothGattCallback = new BluetoothGattCallback() {
@Override
- public void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
+ public void onCharacteristicChanged(final BluetoothGatt gatt,
+ final BluetoothGattCharacteristic characteristic) {
super.onCharacteristicChanged(gatt, characteristic);
if (gattDebugEnabled) {
- LOG.trace(ThreadUtil.sig() + "onCharacteristicChanged " + GattAttributes.lookup(characteristic.getUuid()) + " " + HexDump.toHexString(characteristic.getValue()));
+ LOG.trace(ThreadUtil.sig() + "onCharacteristicChanged "
+ + GattAttributes.lookup(characteristic.getUuid()) + " "
+ + HexDump.toHexString(characteristic.getValue()));
if (characteristic.getUuid().equals(UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT))) {
LOG.debug("Response Count is " + HexDump.toHexString(characteristic.getValue()));
}
@@ -82,25 +79,29 @@ public class RileyLinkBLE {
@Override
- public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, int status) {
+ public void onCharacteristicRead(final BluetoothGatt gatt,
+ final BluetoothGattCharacteristic characteristic, int status) {
super.onCharacteristicRead(gatt, characteristic, status);
-
final String statusMessage = getGattStatusMessage(status);
if (gattDebugEnabled) {
- LOG.trace(ThreadUtil.sig() + "onCharacteristicRead (" + GattAttributes.lookup(characteristic.getUuid()) + ") " + statusMessage + ":" + HexDump.toHexString(characteristic.getValue()));
+ LOG.trace(ThreadUtil.sig() + "onCharacteristicRead ("
+ + GattAttributes.lookup(characteristic.getUuid()) + ") " + statusMessage + ":"
+ + HexDump.toHexString(characteristic.getValue()));
}
mCurrentOperation.gattOperationCompletionCallback(characteristic.getUuid(), characteristic.getValue());
}
@Override
- public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, int status) {
+ public void onCharacteristicWrite(final BluetoothGatt gatt,
+ final BluetoothGattCharacteristic characteristic, int status) {
super.onCharacteristicWrite(gatt, characteristic, status);
final String uuidString = GattAttributes.lookup(characteristic.getUuid());
if (gattDebugEnabled) {
- LOG.trace(ThreadUtil.sig() + "onCharacteristicWrite " + getGattStatusMessage(status) + " " + uuidString + " " + HexDump.toHexString(characteristic.getValue()));
+ LOG.trace(ThreadUtil.sig() + "onCharacteristicWrite " + getGattStatusMessage(status) + " "
+ + uuidString + " " + HexDump.toHexString(characteristic.getValue()));
}
mCurrentOperation.gattOperationCompletionCallback(characteristic.getUuid(), characteristic.getValue());
}
@@ -142,8 +143,9 @@ public class RileyLinkBLE {
}
} else if ((newState == BluetoothProfile.STATE_CONNECTING) || //
- (newState == BluetoothProfile.STATE_DISCONNECTING)) {
- //LOG.debug("We are in {} state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" : "Disconnecting");
+ (newState == BluetoothProfile.STATE_DISCONNECTING)) {
+ // LOG.debug("We are in {} state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" :
+ // "Disconnecting");
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnected);
if (manualDisconnect)
@@ -159,7 +161,8 @@ public class RileyLinkBLE {
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
super.onDescriptorWrite(gatt, descriptor, status);
if (gattDebugEnabled) {
- LOG.warn("onDescriptorWrite " + GattAttributes.lookup(descriptor.getUuid()) + " " + getGattStatusMessage(status) + " written: " + HexDump.toHexString(descriptor.getValue()));
+ LOG.warn("onDescriptorWrite " + GattAttributes.lookup(descriptor.getUuid()) + " "
+ + getGattStatusMessage(status) + " written: " + HexDump.toHexString(descriptor.getValue()));
}
mCurrentOperation.gattOperationCompletionCallback(descriptor.getUuid(), descriptor.getValue());
}
@@ -232,10 +235,12 @@ public class RileyLinkBLE {
if (rileyLinkFound) {
mIsConnected = true;
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkReady);
- //RileyLinkUtil.sendNotification(new ServiceNotification(RileyLinkConst.Intents.RileyLinkReady), null);
+ // RileyLinkUtil.sendNotification(new
+ // ServiceNotification(RileyLinkConst.Intents.RileyLinkReady), null);
} else {
mIsConnected = false;
- RileyLinkUtil.setServiceState(RileyLinkServiceState.RileyLinkError, RileyLinkError.DeviceIsNotRileyLink);
+ RileyLinkUtil.setServiceState(RileyLinkServiceState.RileyLinkError,
+ RileyLinkError.DeviceIsNotRileyLink);
}
} else {
@@ -309,7 +314,7 @@ public class RileyLinkBLE {
debugService(serviceI, indentCount + 4);
}
}
- //}
+ // }
}
@@ -336,7 +341,7 @@ public class RileyLinkBLE {
public boolean enableNotifications() {
BLECommOperationResult result = setNotification_blocking(UUID.fromString(GattAttributes.SERVICE_RADIO), //
- UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT));
+ UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT));
if (result.resultCode != BLECommOperationResult.RESULT_SUCCESS) {
LOG.error("Error setting response count notification");
return false;
@@ -369,9 +374,6 @@ public class RileyLinkBLE {
}
- boolean manualDisconnect = false;
-
-
public void disconnect() {
mIsConnected = false;
LOG.warn("Closing GATT connection");
@@ -380,8 +382,8 @@ public class RileyLinkBLE {
// Not sure if to disconnect or to close first..
bluetoothConnectionGatt.disconnect();
manualDisconnect = true;
- //bluetoothConnectionGatt.close();
- //bluetoothConnectionGatt = null;
+ // bluetoothConnectionGatt.close();
+ // bluetoothConnectionGatt = null;
}
}
@@ -414,7 +416,8 @@ public class RileyLinkBLE {
LOG.error("BT Device not supported");
// TODO: 11/07/2016 UI update for user
} else {
- BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID).getCharacteristic(charaUUID);
+ BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID)
+ .getCharacteristic(charaUUID);
// Tell Android that we want the notifications
bluetoothConnectionGatt.setCharacteristicNotification(chara, true);
List list = chara.getDescriptors();
@@ -425,7 +428,8 @@ public class RileyLinkBLE {
}
BluetoothGattDescriptor descr = list.get(0);
// Tell the remote device to send the notifications
- mCurrentOperation = new DescriptorWriteOperation(bluetoothConnectionGatt, descr, BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
+ mCurrentOperation = new DescriptorWriteOperation(bluetoothConnectionGatt, descr,
+ BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mCurrentOperation.execute(this);
if (mCurrentOperation.timedOut) {
rval.resultCode = BLECommOperationResult.RESULT_TIMEOUT;
@@ -464,14 +468,15 @@ public class RileyLinkBLE {
} else {
if (bluetoothConnectionGatt.getService(serviceUUID) == null) {
// Catch if the service is not supported by the BLE device
- // GGW: Tue Jul 12 01:14:01 UTC 2016: This can also happen if the
+ // GGW: Tue Jul 12 01:14:01 UTC 2016: This can also happen if the
// app that created the bluetoothConnectionGatt has been destroyed/created,
// e.g. when the user switches from portrait to landscape.
rval.resultCode = BLECommOperationResult.RESULT_NONE;
LOG.error("BT Device not supported");
// TODO: 11/07/2016 UI update for user
} else {
- BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID).getCharacteristic(charaUUID);
+ BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID)
+ .getCharacteristic(charaUUID);
mCurrentOperation = new CharacteristicWriteOperation(bluetoothConnectionGatt, chara, value);
mCurrentOperation.execute(this);
if (mCurrentOperation.timedOut) {
@@ -506,7 +511,8 @@ public class RileyLinkBLE {
if (mCurrentOperation != null) {
rval.resultCode = BLECommOperationResult.RESULT_BUSY;
} else {
- BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID).getCharacteristic(charaUUID);
+ BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID).getCharacteristic(
+ charaUUID);
mCurrentOperation = new CharacteristicReadOperation(bluetoothConnectionGatt, chara);
mCurrentOperation.execute(this);
if (mCurrentOperation.timedOut) {
@@ -545,5 +551,4 @@ public class RileyLinkBLE {
return statusMessage;
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyScanResults.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyScanResults.java
index dec8198d62..64a7ceec97 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyScanResults.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyScanResults.java
@@ -8,11 +8,14 @@ import java.util.Comparator;
* Created by geoff on 5/30/16.
*/
public class FrequencyScanResults {
+
public ArrayList trials = new ArrayList<>();
public double bestFrequencyMHz = 0.0;
+
public void sort() {
Collections.sort(trials, new Comparator() {
+
@Override
public int compare(FrequencyTrial trial1, FrequencyTrial trial2) {
return trial1.averageRSSI.compareTo(trial2.averageRSSI);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyTrial.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyTrial.java
index adaedd8505..7cbd2e7d92 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyTrial.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/FrequencyTrial.java
@@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data;
* Created by geoff on 5/30/16.
*/
public class FrequencyTrial {
+
public int tries = 0;
public int successes = 0;
public Double averageRSSI = 0.0;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/GattAttributes.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/GattAttributes.java
index 62238c8c42..708c47bc68 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/GattAttributes.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/GattAttributes.java
@@ -10,7 +10,7 @@ import java.util.UUID;
public class GattAttributes {
// NOTE: these uuid strings must be lower case!
-
+
public static String PREFIX = "0000";
public static String SUFFIX = "-0000-1000-8000-00805f9b34fb";
public static String SERVICE_GAP = PREFIX + "1800" + SUFFIX;
@@ -41,7 +41,6 @@ public class GattAttributes {
attributes.put(CHARA_GAP_NAME, "Name"); //
attributes.put(CHARA_GAP_NUM, "Number"); //
-
attributes.put(SERVICE_BATTERY, "Battery Service");
attributes.put(SERVICE_RADIO, "Radio Interface"); // a
@@ -85,5 +84,4 @@ public class GattAttributes {
return attributesRileyLinkSpecific.containsKey(uuid.toString());
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RFSpyResponse.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RFSpyResponse.java
index acc0c879f3..a7e1f186ad 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RFSpyResponse.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RFSpyResponse.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RFSpy
* Created by geoff on 5/26/16.
*/
public class RFSpyResponse {
+
// 0xaa == timeout
// 0xbb == interrupted
// 0xcc == zero-data
@@ -53,7 +54,7 @@ public class RFSpyResponse {
public boolean wasTimeout() {
if ((raw.length == 1) || (raw.length == 2)) {
- if (raw[0] == (byte) 0xaa) {
+ if (raw[0] == (byte)0xaa) {
return true;
}
}
@@ -63,7 +64,7 @@ public class RFSpyResponse {
public boolean wasInterrupted() {
if ((raw.length == 1) || (raw.length == 2)) {
- if (raw[0] == (byte) 0xbb) {
+ if (raw[0] == (byte)0xbb) {
return true;
}
}
@@ -73,7 +74,7 @@ public class RFSpyResponse {
public boolean isOK() {
if ((raw.length == 1) || (raw.length == 2)) {
- if (raw[0] == (byte) 0x01) {
+ if (raw[0] == (byte)0x01) {
return true;
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RLMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RLMessage.java
index 1d2ed3cde3..dff600dd29 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RLMessage.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RLMessage.java
@@ -7,6 +7,7 @@ public interface RLMessage {
byte[] getTxData();
+
boolean isValid();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioPacket.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioPacket.java
index e393a2a229..e09f7d7bad 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioPacket.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioPacket.java
@@ -9,6 +9,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.CRC;
*/
public class RadioPacket {
+
protected byte[] pkt;
@@ -21,15 +22,17 @@ public class RadioPacket {
return pkt;
}
+
public byte[] getWithCRC() {
byte[] withCRC = ByteUtil.concat(pkt, CRC.crc8(pkt));
return withCRC;
}
+
public byte[] getEncoded() {
byte[] withCRC = ByteUtil.concat(pkt, CRC.crc8(pkt));
byte[] encoded = RFTools.encode4b6b(withCRC);
- byte[] withNullTerm = ByteUtil.concat(encoded, (byte) 0);
+ byte[] withNullTerm = ByteUtil.concat(encoded, (byte)0);
return withNullTerm;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioResponse.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioResponse.java
index e589eff120..fa4d3a011b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioResponse.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/data/RadioResponse.java
@@ -31,6 +31,7 @@ public class RadioResponse {
init(rxData);
}
+
public RadioResponse(RFSpyCommand command, byte[] raw) {
this.command = command;
@@ -40,12 +41,10 @@ public class RadioResponse {
public boolean isValid() {
- if (command!=null && !command.isEncoded())
- {
+ if (command != null && !command.isEncoded()) {
return true;
}
-
if (!decodedOK) {
return false;
}
@@ -71,7 +70,7 @@ public class RadioResponse {
byte[] encodedPayload = ByteUtil.substring(rxData, 2, rxData.length - 2);
try {
- boolean isEncoded = command==null || command.isEncoded();
+ boolean isEncoded = command == null || command.isEncoded();
if (isEncoded) {
byte[] decodeThis = RFTools.decode4b6b(encodedPayload);
@@ -80,15 +79,15 @@ public class RadioResponse {
byte calculatedCRC = CRC.crc8(decodedPayload);
receivedCRC = decodeThis[decodeThis.length - 1];
if (receivedCRC != calculatedCRC) {
- LOG.error(String.format("RadioResponse: CRC mismatch, calculated 0x%02x, received 0x%02x", calculatedCRC, receivedCRC));
+ LOG.error(String.format("RadioResponse: CRC mismatch, calculated 0x%02x, received 0x%02x",
+ calculatedCRC, receivedCRC));
}
- }
- else {
+ } else {
decodedOK = true;
decodedPayload = encodedPayload;
}
- //byte[] decodeThis = RFTools.decode4b6b(encodedPayload);
+ // byte[] decodeThis = RFTools.decode4b6b(encodedPayload);
} catch (NumberFormatException e) {
decodedOK = false;
LOG.error("Failed to decode radio data: " + ByteUtil.shortHexString(encodedPayload));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/CC111XRegister.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/CC111XRegister.java
index 9896e85cac..188464d28b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/CC111XRegister.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/CC111XRegister.java
@@ -37,11 +37,12 @@ public enum CC111XRegister {
paTable0(0x2e), //
;
+
public byte value;
CC111XRegister(int value) {
- this.value = (byte) value;
+ this.value = (byte)value;
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RFSpyCommand.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RFSpyCommand.java
index fd035eaeb7..ea2c20364f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RFSpyCommand.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RFSpyCommand.java
@@ -21,12 +21,12 @@ public enum RFSpyCommand {
RFSpyCommand(int code) {
- this.code = (byte) code;
+ this.code = (byte)code;
}
RFSpyCommand(int code, boolean encoded) {
- this.code = (byte) code;
+ this.code = (byte)code;
this.encoded = encoded;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RXFilterMode.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RXFilterMode.java
index eb200a00ed..f81759f8c2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RXFilterMode.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RXFilterMode.java
@@ -14,6 +14,6 @@ public enum RXFilterMode {
RXFilterMode(int value) {
- this.value = (byte) value;
+ this.value = (byte)value;
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java
index b7d535f942..9c54eb2fd9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java
@@ -25,8 +25,7 @@ public enum RileyLinkTargetFrequency {
public double[] getScanFrequencies() {
- if (maxFrequency == minFrequency)
- {
+ if (maxFrequency == minFrequency) {
double freq[] = new double[1];
freq[0] = minFrequency;
@@ -35,11 +34,11 @@ public enum RileyLinkTargetFrequency {
double diff = maxFrequency - minFrequency;
- int count = (int) (diff / step);
+ int count = (int)(diff / step);
double freq[] = new double[count];
- for(int i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
freq[i] = (minFrequency + (i * step));
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperation.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperation.java
index 7188bffaf1..5d4567fd99 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperation.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperation.java
@@ -1,10 +1,10 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.operations;
-import android.bluetooth.BluetoothGatt;
-
import java.util.UUID;
import java.util.concurrent.Semaphore;
+import android.bluetooth.BluetoothGatt;
+
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkBLE;
/**
@@ -18,16 +18,20 @@ public abstract class BLECommOperation {
protected BluetoothGatt gatt;
protected Semaphore operationComplete = new Semaphore(0, true);
+
// This is to be run on the main thread
public abstract void execute(RileyLinkBLE comm);
+
public void gattOperationCompletionCallback(UUID uuid, byte[] value) {
}
+
public int getGattOperationTimeout_ms() {
return 22000;
}
+
public byte[] getValue() {
return value;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperationResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperationResult.java
index 0ab88de989..04668b2522 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperationResult.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/BLECommOperationResult.java
@@ -4,8 +4,6 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.operation
* Created by geoff on 5/26/16.
*/
public class BLECommOperationResult {
- public byte[] value;
- public int resultCode;
public static final int RESULT_NONE = 0;
public static final int RESULT_SUCCESS = 1;
@@ -13,4 +11,6 @@ public class BLECommOperationResult {
public static final int RESULT_BUSY = 3;
public static final int RESULT_INTERRUPTED = 4;
public static final int RESULT_NOT_CONFIGURED = 5;
+ public byte[] value;
+ public int resultCode;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicReadOperation.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicReadOperation.java
index 278d373a82..323d881232 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicReadOperation.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicReadOperation.java
@@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.operations;
-import android.bluetooth.BluetoothGatt;
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.os.SystemClock;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.os.SystemClock;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkBLE;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
@@ -22,11 +22,13 @@ public class CharacteristicReadOperation extends BLECommOperation {
private BluetoothGattCharacteristic characteristic;
+
public CharacteristicReadOperation(BluetoothGatt gatt, BluetoothGattCharacteristic chara) {
this.gatt = gatt;
this.characteristic = chara;
}
+
@Override
public void execute(RileyLinkBLE comm) {
gatt.readCharacteristic(characteristic);
@@ -34,7 +36,8 @@ public class CharacteristicReadOperation extends BLECommOperation {
try {
boolean didAcquire = operationComplete.tryAcquire(getGattOperationTimeout_ms(), TimeUnit.MILLISECONDS);
if (didAcquire) {
- SystemClock.sleep(1); // This is to allow the IBinder thread to exit before we continue, allowing easier understanding of the sequence of events.
+ SystemClock.sleep(1); // This is to allow the IBinder thread to exit before we continue, allowing easier
+ // understanding of the sequence of events.
// success
} else {
LOG.error("Timeout waiting for gatt write operation to complete");
@@ -47,15 +50,16 @@ public class CharacteristicReadOperation extends BLECommOperation {
value = characteristic.getValue();
}
+
@Override
public void gattOperationCompletionCallback(UUID uuid, byte[] value) {
super.gattOperationCompletionCallback(uuid, value);
if (!characteristic.getUuid().equals(uuid)) {
- LOG.error(String.format("Completion callback: UUID does not match! out of sequence? Found: %s, should be %s",
- GattAttributes.lookup(characteristic.getUuid()), GattAttributes.lookup(uuid)));
+ LOG.error(String.format(
+ "Completion callback: UUID does not match! out of sequence? Found: %s, should be %s",
+ GattAttributes.lookup(characteristic.getUuid()), GattAttributes.lookup(uuid)));
}
operationComplete.release();
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicWriteOperation.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicWriteOperation.java
index cb24753b8a..59f3db9d63 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicWriteOperation.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/CharacteristicWriteOperation.java
@@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.operations;
-import android.bluetooth.BluetoothGatt;
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.os.SystemClock;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.os.SystemClock;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkBLE;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
@@ -22,12 +22,14 @@ public class CharacteristicWriteOperation extends BLECommOperation {
private BluetoothGattCharacteristic characteristic;
+
public CharacteristicWriteOperation(BluetoothGatt gatt, BluetoothGattCharacteristic chara, byte[] value) {
this.gatt = gatt;
this.characteristic = chara;
this.value = value;
}
+
@Override
public void execute(RileyLinkBLE comm) {
@@ -37,7 +39,8 @@ public class CharacteristicWriteOperation extends BLECommOperation {
try {
boolean didAcquire = operationComplete.tryAcquire(getGattOperationTimeout_ms(), TimeUnit.MILLISECONDS);
if (didAcquire) {
- SystemClock.sleep(1); // This is to allow the IBinder thread to exit before we continue, allowing easier understanding of the sequence of events.
+ SystemClock.sleep(1); // This is to allow the IBinder thread to exit before we continue, allowing easier
+ // understanding of the sequence of events.
// success
} else {
LOG.error("Timeout waiting for gatt write operation to complete");
@@ -50,15 +53,16 @@ public class CharacteristicWriteOperation extends BLECommOperation {
}
+
// This will be run on the IBinder thread
@Override
public void gattOperationCompletionCallback(UUID uuid, byte[] value) {
if (!characteristic.getUuid().equals(uuid)) {
- LOG.error(String.format("Completion callback: UUID does not match! out of sequence? Found: %s, should be %s",
- GattAttributes.lookup(characteristic.getUuid()), GattAttributes.lookup(uuid)));
+ LOG.error(String.format(
+ "Completion callback: UUID does not match! out of sequence? Found: %s, should be %s",
+ GattAttributes.lookup(characteristic.getUuid()), GattAttributes.lookup(uuid)));
}
operationComplete.release();
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/DescriptorWriteOperation.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/DescriptorWriteOperation.java
index b772ecffff..15dd617747 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/DescriptorWriteOperation.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/ble/operations/DescriptorWriteOperation.java
@@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.operations;
-import android.bluetooth.BluetoothGatt;
-import android.bluetooth.BluetoothGattDescriptor;
-import android.os.SystemClock;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattDescriptor;
+import android.os.SystemClock;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkBLE;
@@ -28,12 +28,14 @@ public class DescriptorWriteOperation extends BLECommOperation {
this.value = value;
}
+
@Override
public void gattOperationCompletionCallback(UUID uuid, byte[] value) {
super.gattOperationCompletionCallback(uuid, value);
operationComplete.release();
}
+
@Override
public void execute(RileyLinkBLE comm) {
descr.setValue(value);
@@ -42,7 +44,8 @@ public class DescriptorWriteOperation extends BLECommOperation {
try {
boolean didAcquire = operationComplete.tryAcquire(getGattOperationTimeout_ms(), TimeUnit.MILLISECONDS);
if (didAcquire) {
- SystemClock.sleep(1); // This is to allow the IBinder thread to exit before we continue, allowing easier understanding of the sequence of events.
+ SystemClock.sleep(1); // This is to allow the IBinder thread to exit before we continue, allowing easier
+ // understanding of the sequence of events.
// success
} else {
LOG.error("Timeout waiting for descriptor write operation to complete");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/data/RLHistoryItem.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/data/RLHistoryItem.java
index 66f7caf4e9..97b3e16f85 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/data/RLHistoryItem.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/data/RLHistoryItem.java
@@ -2,8 +2,12 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data;
import org.joda.time.LocalDateTime;
+import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkServiceState;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkTargetDevice;
+import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicCommandType;
+import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpDeviceState;
/**
* Created by andy on 5/19/18.
@@ -11,15 +15,38 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLink
public class RLHistoryItem {
+ private MedtronicCommandType medtronicCommandType;
private LocalDateTime dateTime;
+ private RLHistoryItemSource source;
private RileyLinkServiceState serviceState;
private RileyLinkError errorCode;
+ private RileyLinkTargetDevice targetDevice;
+ private PumpDeviceState pumpDeviceState;
- public RLHistoryItem(RileyLinkServiceState serviceState, RileyLinkError errorCode) {
+
+ public RLHistoryItem(RileyLinkServiceState serviceState, RileyLinkError errorCode,
+ RileyLinkTargetDevice targetDevice) {
+ this.targetDevice = targetDevice;
this.dateTime = new LocalDateTime();
this.serviceState = serviceState;
this.errorCode = errorCode;
+ this.source = RLHistoryItemSource.RileyLink;
+ }
+
+
+ public RLHistoryItem(PumpDeviceState pumpDeviceState, RileyLinkTargetDevice targetDevice) {
+ this.pumpDeviceState = pumpDeviceState;
+ this.dateTime = new LocalDateTime();
+ this.targetDevice = targetDevice;
+ this.source = RLHistoryItemSource.MedtronicPump;
+ }
+
+
+ public RLHistoryItem(MedtronicCommandType medtronicCommandType) {
+ this.dateTime = new LocalDateTime();
+ this.medtronicCommandType = medtronicCommandType;
+ source = RLHistoryItemSource.MedtronicCommand;
}
@@ -36,4 +63,53 @@ public class RLHistoryItem {
public RileyLinkError getErrorCode() {
return errorCode;
}
+
+
+ public String getDescription() {
+
+ // TODO extend when we have Omnipod
+ switch (this.source) {
+ case RileyLink:
+ return "State: " + MainApp.gs(serviceState.getResourceId(targetDevice))
+ + (this.errorCode == null ? "" : ", Error Code: " + errorCode);
+
+ case MedtronicPump:
+ return MainApp.gs(pumpDeviceState.getResourceId());
+
+ case MedtronicCommand:
+ return medtronicCommandType.name();
+
+ default:
+ return "Unknown Description";
+ }
+ }
+
+
+ public RLHistoryItemSource getSource() {
+ return source;
+ }
+
+
+ public PumpDeviceState getPumpDeviceState() {
+ return pumpDeviceState;
+ }
+
+ public enum RLHistoryItemSource {
+ RileyLink("RileyLink"), //
+ MedtronicPump("Medtronic"), //
+ MedtronicCommand("Medtronic");
+
+ private String desc;
+
+
+ RLHistoryItemSource(String desc) {
+ this.desc = desc;
+ }
+
+
+ public String getDesc() {
+ return desc;
+ }
+ }
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkError.java
index 3ec19a44e3..e6333f1691 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkError.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkError.java
@@ -10,7 +10,6 @@ public enum RileyLinkError {
// Configuration
-
// BT
NoBluetoothAdapter(R.string.rileylink_error_no_bt_adapter), //
BluetoothDisabled(R.string.rileylink_error_bt_disabled), //
@@ -24,10 +23,10 @@ public enum RileyLinkError {
NoContactWithDevice(R.string.rileylink_error_pump_unreachable, R.string.rileylink_error_pod_unreachable), //
;
-
int resourceId;
Integer resourceIdPod;
+
RileyLinkError(int resourceId) {
this.resourceId = resourceId;
}
@@ -43,7 +42,8 @@ public enum RileyLinkError {
if (this.resourceIdPod != null) {
return targetDevice == RileyLinkTargetDevice.MedtronicPump ? //
- this.resourceId : this.resourceIdPod;
+ this.resourceId
+ : this.resourceIdPod;
} else {
return this.resourceId;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkServiceState.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkServiceState.java
index 06570d51cc..2d7c198de8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkServiceState.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkServiceState.java
@@ -11,78 +11,84 @@ public enum RileyLinkServiceState {
NotStarted(R.string.rileylink_state_not_started), //
// Bluetooth
- BluetoothInitializing(R.string.rileylink_state_bt_init), // (S) init BT (if error no BT interface -> Disabled, BT not enabled -> BluetoothError)
- //BluetoothNotAvailable, // (E) BT not available, would happen only if device has no BT
+ BluetoothInitializing(R.string.rileylink_state_bt_init), // (S) init BT (if error no BT interface -> Disabled, BT
+ // not enabled -> BluetoothError)
+ // BluetoothNotAvailable, // (E) BT not available, would happen only if device has no BT
BluetoothError(R.string.rileylink_state_bt_error), // (E) if BT gets disabled ( -> EnableBluetooth)
BluetoothReady(R.string.rileylink_state_bt_ready), // (OK)
// RileyLink
- RileyLinkInitializing(R.string.rileylink_state_rl_init), // (S) start Gatt discovery (OK -> RileyLinkReady, Error -> BluetoothEnabled) ??
+ RileyLinkInitializing(R.string.rileylink_state_rl_init), // (S) start Gatt discovery (OK -> RileyLinkReady, Error ->
+ // BluetoothEnabled) ??
RileyLinkError(R.string.rileylink_state_rl_error), // (E)
RileyLinkReady(R.string.rileylink_state_connected), // (OK) if tunning was already done we go to PumpConnectorReady
// Tunning
TuneUpDevice(R.string.rileylink_state_pc_tune_up), // (S)
- PumpConnectorError(R.string.rileylink_state_pc_error), // either TuneUp Error or pump couldn't not be contacted error
+ PumpConnectorError(R.string.rileylink_state_pc_error), // either TuneUp Error or pump couldn't not be contacted
+ // error
PumpConnectorReady(R.string.rileylink_state_connected), // (OK) RileyLink Ready for Pump Communication
- //Initializing, // get all parameters required for connection (if not possible -> Disabled, if sucessful -> EnableBluetooth)
+ // Initializing, // get all parameters required for connection (if not possible -> Disabled, if sucessful ->
+ // EnableBluetooth)
+ // EnableBlueTooth, // enable BT (if error no BT interface -> Disabled, BT not enabled -> BluetoothError)
+ // BlueToothEnabled, // -> InitializeRileyLink
+ // RileyLinkInitialized, //
- //EnableBlueTooth, // enable BT (if error no BT interface -> Disabled, BT not enabled -> BluetoothError)
- //BlueToothEnabled, // -> InitializeRileyLink
- //RileyLinkInitialized, //
-
- //RileyLinkConnected, // -> TuneUpPump (on 1st), else PumpConnectorReady
-
- //PumpConnected, //
+ // RileyLinkConnected, // -> TuneUpPump (on 1st), else PumpConnectorReady
+ // PumpConnected, //
;
-
int resourceId;
Integer resourceIdPod;
+
RileyLinkServiceState(int resourceId) {
this.resourceId = resourceId;
}
+
RileyLinkServiceState(int resourceId, int resourceIdPod) {
this.resourceId = resourceId;
this.resourceIdPod = resourceIdPod;
}
+ public static boolean isReady(RileyLinkServiceState serviceState) {
+ return (serviceState == RileyLinkReady || serviceState == PumpConnectorReady);
+ }
+
+
public int getResourceId(RileyLinkTargetDevice targetDevice) {
if (this.resourceIdPod != null) {
- return targetDevice == RileyLinkTargetDevice.MedtronicPump ? //
- this.resourceId : this.resourceIdPod;
+ return (targetDevice == null || targetDevice == RileyLinkTargetDevice.MedtronicPump) ? //
+ this.resourceId
+ : this.resourceIdPod;
} else {
return this.resourceId;
}
}
- public static boolean isReady(RileyLinkServiceState serviceState) {
- return (serviceState == RileyLinkReady || serviceState == PumpConnectorReady);
- }
public boolean isConnecting() {
return (this == RileyLinkServiceState.BluetoothInitializing || //
- //this == RileyLinkServiceState.BluetoothError || //
- this == RileyLinkServiceState.BluetoothReady || //
- this == RileyLinkServiceState.RileyLinkInitializing //
- //this == RileyLinkServiceState.RileyLinkError
+ // this == RileyLinkServiceState.BluetoothError || //
+ this == RileyLinkServiceState.BluetoothReady || //
+ this == RileyLinkServiceState.RileyLinkInitializing //
+ // this == RileyLinkServiceState.RileyLinkError
);
}
+
public boolean isError() {
- return (
- this == RileyLinkServiceState.BluetoothError || //
- //this == RileyLinkServiceState.PumpConnectorError || //
- this == RileyLinkServiceState.RileyLinkError);
+ return (this == RileyLinkServiceState.BluetoothError || //
+ // this == RileyLinkServiceState.PumpConnectorError || //
+ this == RileyLinkServiceState.RileyLinkError);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkTargetDevice.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkTargetDevice.java
index b6320e79c0..9dffd2d2c1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkTargetDevice.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/defs/RileyLinkTargetDevice.java
@@ -1,22 +1,33 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs;
+import info.nightscout.androidaps.R;
+
/**
* Created by andy on 5/19/18.
*/
public enum RileyLinkTargetDevice {
- MedtronicPump(true), //
- Omnipod(false), //
+ MedtronicPump(R.string.rileylink_target_device_medtronic, true), //
+ Omnipod(R.string.rileylink_target_device_omnipod, false), //
;
+ private int resourceId;
private boolean tuneUpEnabled;
- RileyLinkTargetDevice(boolean tuneUpEnabled) {
+
+ RileyLinkTargetDevice(int resourceId, boolean tuneUpEnabled) {
+ this.resourceId = resourceId;
this.tuneUpEnabled = tuneUpEnabled;
}
+
public boolean isTuneUpEnabled() {
return tuneUpEnabled;
}
+
+
+ public int getResourceId() {
+ return resourceId;
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/dialog/RileylinkSettingsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusActivity.java
similarity index 64%
rename from app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/dialog/RileylinkSettingsActivity.java
rename to app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusActivity.java
index f041f08fa2..e00309c780 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/dialog/RileylinkSettingsActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusActivity.java
@@ -1,4 +1,7 @@
-package info.nightscout.androidaps.plugins.PumpCommon.dialog;
+package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
@@ -11,17 +14,14 @@ import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
-import java.util.ArrayList;
-import java.util.List;
-
import butterknife.BindView;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.PumpCommon.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.RileyLinkServiceData;
-public class RileylinkSettingsActivity extends AppCompatActivity {
-
+public class RileyLinkStatusActivity extends AppCompatActivity {
@BindView(R.id.rls_t1_connection_status)
TextView connectionStatus;
@@ -34,79 +34,74 @@ public class RileylinkSettingsActivity extends AppCompatActivity {
@BindView(R.id.rls_t1_connection_error)
TextView connectionError;
-
+ RileyLinkServiceData rileyLinkServiceData;
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
- * fragments for each of the sections. We use a
- * {@link FragmentPagerAdapter} derivative, which will keep every
+ * fragments for each of the sections. We use a {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
- * may be best to switch to a
- * {@link android.support.v4.app.FragmentStatePagerAdapter}.
+ * may be best to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
private FloatingActionButton floatingActionButton;
private TabLayout tabLayout;
-
- RileyLinkServiceData rileyLinkServiceData;
-
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.rileylink_settings);
-
+ setContentView(R.layout.rileylink_status);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
-
// Set up the ViewPager with the sections adapter.
- mViewPager = (ViewPager) findViewById(R.id.rileylink_settings_container);
- //mViewPager.setAdapter(mSectionsPagerAdapter);
+ mViewPager = (ViewPager)findViewById(R.id.rileylink_settings_container);
+ // mViewPager.setAdapter(mSectionsPagerAdapter);
setupViewPager(mViewPager);
- tabLayout = (TabLayout) findViewById(R.id.rileylink_settings_tabs);
+ tabLayout = (TabLayout)findViewById(R.id.rileylink_settings_tabs);
tabLayout.setupWithViewPager(mViewPager);
-
- floatingActionButton = (FloatingActionButton) findViewById(R.id.rileylink_settings_fab);
+ floatingActionButton = (FloatingActionButton)findViewById(R.id.rileylink_settings_fab);
floatingActionButton.setOnClickListener(new View.OnClickListener() {
+
@Override
public void onClick(View v) {
- RefreshableInterface selectableInterface = (RefreshableInterface) mSectionsPagerAdapter.getItem(tabLayout.getSelectedTabPosition());
+ RefreshableInterface selectableInterface = (RefreshableInterface)mSectionsPagerAdapter
+ .getItem(tabLayout.getSelectedTabPosition());
selectableInterface.refreshData();
- //refreshData(tabLayout.getSelectedTabPosition());
+ // refreshData(tabLayout.getSelectedTabPosition());
- //Toast.makeText(getApplicationContext(), "Test pos: " + tabLayout.getSelectedTabPosition(), Toast.LENGTH_LONG);
+ // Toast.makeText(getApplicationContext(), "Test pos: " + tabLayout.getSelectedTabPosition(),
+ // Toast.LENGTH_LONG);
}
});
- this.connectionStatus = (TextView) findViewById(R.id.rls_t1_connection_status);
- this.configuredAddress = (TextView) findViewById(R.id.rls_t1_configured_address);
- this.connectedDevice = (TextView) findViewById(R.id.rls_t1_connected_device);
- this.connectionError = (TextView) findViewById(R.id.rls_t1_connection_error);
-
+ this.connectionStatus = (TextView)findViewById(R.id.rls_t1_connection_status);
+ this.configuredAddress = (TextView)findViewById(R.id.rls_t1_configured_address);
+ this.connectedDevice = (TextView)findViewById(R.id.rls_t1_connected_device);
+ this.connectionError = (TextView)findViewById(R.id.rls_t1_connection_error);
rileyLinkServiceData = RileyLinkUtil.getRileyLinkServiceData();
-// // 7-12
-// int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
-// R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12};
-//
-// for (int id : ids) {
-//
-// TextView tv = (TextView) findViewById(id);
-// tv.setText(tv.getText() + ":");
-// }
+ // // 7-12
+ // int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
+ // R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12};
+ //
+ // for (int id : ids) {
+ //
+ // TextView tv = (TextView) findViewById(id);
+ // tv.setText(tv.getText() + ":");
+ // }
- //refreshData(0);
- //refreshData(1);
+ // refreshData(0);
+ // refreshData(1);
}
@@ -124,7 +119,6 @@ public class RileylinkSettingsActivity extends AppCompatActivity {
}
-
}
@@ -132,14 +126,13 @@ public class RileylinkSettingsActivity extends AppCompatActivity {
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
- mSectionsPagerAdapter.addFragment(new RileyLinkSettingsTab1(), MainApp.gs(R.string.rileylink_settings_tab1));
- mSectionsPagerAdapter.addFragment(new RileyLinkSettingsTab2(), MainApp.gs(R.string.rileylink_settings_tab2));
- //mSectionsPagerAdapter.addFragment(new RileyLinkSettingsTab3(), "Tab 3");
+ mSectionsPagerAdapter.addFragment(new RileyLinkStatusGeneral(), MainApp.gs(R.string.rileylink_settings_tab1));
+ mSectionsPagerAdapter.addFragment(new RileyLinkStatusHistory(), MainApp.gs(R.string.rileylink_settings_tab2));
+ // mSectionsPagerAdapter.addFragment(new RileyLinkSettingsTab3(), "Tab 3");
mViewPager.setAdapter(mSectionsPagerAdapter);
}
-
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
@@ -150,6 +143,7 @@ public class RileylinkSettingsActivity extends AppCompatActivity {
List fragmentTitle = new ArrayList<>();
int lastSelectedPosition = 0;
+
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@@ -161,17 +155,20 @@ public class RileylinkSettingsActivity extends AppCompatActivity {
return fragmentList.get(position);
}
+
@Override
public int getCount() {
// Show 3 total pages.
return fragmentList.size();
}
+
public void addFragment(Fragment fragment, String title) {
this.fragmentList.add(fragment);
this.fragmentTitle.add(title);
}
+
@Override
public CharSequence getPageTitle(int position) {
return fragmentTitle.get(position);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusDevice.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusDevice.java
new file mode 100644
index 0000000000..5152409f37
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusDevice.java
@@ -0,0 +1,156 @@
+package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.PumpCommon.dialog.RefreshableInterface;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.RLHistoryItem;
+import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
+
+/**
+ * Created by andy on 5/19/18.
+ */
+
+// FIXME needs to be implemented
+@Deprecated
+public class RileyLinkStatusDevice extends Fragment implements RefreshableInterface {
+
+ // @BindView(R.id.rileylink_history_list)
+ ListView listView;
+
+ RileyLinkCommandListAdapter adapter;
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.rileylink_status_device, container, false);
+
+ adapter = new RileyLinkCommandListAdapter();
+
+ return rootView;
+ }
+
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ this.listView = (ListView)getActivity().findViewById(R.id.rileylink_history_list);
+
+ listView.setAdapter(adapter);
+
+ refreshData();
+ }
+
+
+ @Override
+ public void refreshData() {
+ // adapter.addItemsAndClean(RileyLinkUtil.getRileyLinkHistory());
+ }
+
+ static class ViewHolder {
+
+ TextView itemTime;
+ TextView itemSource;
+ TextView itemDescription;
+ }
+
+ private class RileyLinkCommandListAdapter extends BaseAdapter {
+
+ private List historyItemList;
+ private LayoutInflater mInflator;
+
+
+ public RileyLinkCommandListAdapter() {
+ super();
+ historyItemList = new ArrayList<>();
+ mInflator = RileyLinkStatusDevice.this.getLayoutInflater();
+ }
+
+
+ public void addItem(RLHistoryItem item) {
+ if (!historyItemList.contains(item)) {
+ historyItemList.add(item);
+ notifyDataSetChanged();
+ }
+ }
+
+
+ public RLHistoryItem getHistoryItem(int position) {
+ return historyItemList.get(position);
+ }
+
+
+ public void addItemsAndClean(List items) {
+ this.historyItemList.clear();
+
+ for (RLHistoryItem item : items) {
+
+ if (!historyItemList.contains(item)) {
+ historyItemList.add(item);
+ }
+ }
+
+ notifyDataSetChanged();
+ }
+
+
+ public void clear() {
+ historyItemList.clear();
+ notifyDataSetChanged();
+ }
+
+
+ @Override
+ public int getCount() {
+ return historyItemList.size();
+ }
+
+
+ @Override
+ public Object getItem(int i) {
+ return historyItemList.get(i);
+ }
+
+
+ @Override
+ public long getItemId(int i) {
+ return i;
+ }
+
+
+ @Override
+ public View getView(int i, View view, ViewGroup viewGroup) {
+ RileyLinkStatusDevice.ViewHolder viewHolder;
+ // General ListView optimization code.
+ if (view == null) {
+ view = mInflator.inflate(R.layout.rileylink_status_device_item, null);
+ viewHolder = new RileyLinkStatusDevice.ViewHolder();
+ viewHolder.itemTime = (TextView)view.findViewById(R.id.rileylink_history_time);
+ viewHolder.itemSource = (TextView)view.findViewById(R.id.rileylink_history_source);
+ viewHolder.itemDescription = (TextView)view.findViewById(R.id.rileylink_history_description);
+ view.setTag(viewHolder);
+ } else {
+ viewHolder = (RileyLinkStatusDevice.ViewHolder)view.getTag();
+ }
+
+ RLHistoryItem item = historyItemList.get(i);
+ viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime()));
+ viewHolder.itemSource.setText("Riley Link"); // for now
+ viewHolder.itemDescription.setText(item.getDescription());
+
+ return view;
+ }
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusGeneral.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusGeneral.java
new file mode 100644
index 0000000000..8d2afc6880
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusGeneral.java
@@ -0,0 +1,127 @@
+package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.dialog;
+
+import java.util.Locale;
+
+import org.joda.time.LocalDateTime;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.PumpCommon.dialog.RefreshableInterface;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkTargetDevice;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.RileyLinkServiceData;
+import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
+import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpStatus;
+import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
+
+/**
+ * Created by andy on 5/19/18.
+ */
+
+public class RileyLinkStatusGeneral extends Fragment implements RefreshableInterface {
+
+ TextView connectionStatus;
+ TextView configuredAddress;
+ TextView connectedDevice;
+ TextView connectionError;
+ TextView deviceType;
+ TextView deviceModel;
+ TextView serialNumber;
+ TextView pumpFrequency;
+ TextView lastUsedFrequency;
+ TextView lastDeviceContact;
+
+ RileyLinkServiceData rileyLinkServiceData;
+
+ MedtronicPumpStatus medtronicPumpStatus;
+ boolean first = false;
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.rileylink_status_general, container, false);
+
+ return rootView;
+ }
+
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ rileyLinkServiceData = RileyLinkUtil.getRileyLinkServiceData();
+
+ this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
+ this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
+ this.connectedDevice = getActivity().findViewById(R.id.rls_t1_connected_device);
+ this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
+ this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
+ this.deviceModel = getActivity().findViewById(R.id.rls_t1_device_model);
+ this.serialNumber = getActivity().findViewById(R.id.rls_t1_serial_number);
+ this.pumpFrequency = getActivity().findViewById(R.id.rls_t1_pump_frequency);
+ this.lastUsedFrequency = getActivity().findViewById(R.id.rls_t1_last_used_frequency);
+ this.lastDeviceContact = getActivity().findViewById(R.id.rls_t1_last_device_contact);
+
+ if (!first) {
+
+ // 7-12
+ int[] ids = { R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
+ R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12 };
+
+ for (int id : ids) {
+
+ TextView tv = (TextView)getActivity().findViewById(id);
+ tv.setText(tv.getText() + ":");
+ }
+
+ first = true;
+ }
+
+ refreshData();
+ }
+
+
+ public void refreshData() {
+
+ RileyLinkTargetDevice targetDevice = RileyLinkUtil.getTargetDevice();
+
+ this.connectionStatus.setText(MainApp.gs(rileyLinkServiceData.serviceState.getResourceId(targetDevice)));
+ this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
+ this.connectionError.setText(rileyLinkServiceData.errorCode == null ? //
+ "-"
+ : MainApp.gs(rileyLinkServiceData.errorCode.getResourceId(targetDevice)));
+
+ // TODO add handling for Omnipod pump status
+ this.medtronicPumpStatus = MedtronicUtil.getPumpStatus();
+
+ if (medtronicPumpStatus != null) {
+ this.deviceType.setText(MainApp.gs(RileyLinkUtil.getTargetDevice().getResourceId()));
+ this.deviceModel.setText(medtronicPumpStatus.pumpType.getDescription());
+ this.serialNumber.setText(medtronicPumpStatus.serialNumber);
+ this.pumpFrequency.setText(medtronicPumpStatus.pumpFrequency);
+ if (MedtronicUtil.getMedtronicPumpModel() != null) // FIXME change this when we have omnipod
+ this.connectedDevice.setText("Medtronic " + MedtronicUtil.getMedtronicPumpModel().getPumpModel());
+ else
+ this.connectedDevice.setText("???");
+
+ if (rileyLinkServiceData.lastGoodFrequency != null)
+ this.lastUsedFrequency.setText(String.format(Locale.ENGLISH, "%.2f MHz",
+ rileyLinkServiceData.lastGoodFrequency));
+
+ // FIXME
+ if (medtronicPumpStatus.lastConnection != 0)
+ this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
+ medtronicPumpStatus.lastDataTime)));
+ else
+ this.lastDeviceContact.setText("Never");
+ }
+
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusHistory.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusHistory.java
new file mode 100644
index 0000000000..4f323b0b9c
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/dialog/RileyLinkStatusHistory.java
@@ -0,0 +1,172 @@
+package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.PumpCommon.dialog.RefreshableInterface;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.RLHistoryItem;
+import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
+import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpDeviceState;
+
+/**
+ * Created by andy on 5/19/18.
+ */
+
+public class RileyLinkStatusHistory extends Fragment implements RefreshableInterface {
+
+ // @BindView(R.id.rileylink_history_list)
+ ListView listView;
+
+ RileyLinkHistoryListAdapter adapter;
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.rileylink_status_history, container, false);
+
+ adapter = new RileyLinkHistoryListAdapter();
+
+ return rootView;
+ }
+
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ this.listView = (ListView)getActivity().findViewById(R.id.rileylink_history_list);
+
+ listView.setAdapter(adapter);
+
+ refreshData();
+ }
+
+
+ @Override
+ public void refreshData() {
+ adapter.addItemsAndClean(RileyLinkUtil.getRileyLinkHistory());
+ }
+
+ static class ViewHolder {
+
+ TextView itemTime;
+ TextView itemSource;
+ TextView itemDescription;
+ }
+
+ private class RileyLinkHistoryListAdapter extends BaseAdapter {
+
+ private List historyItemList;
+ private LayoutInflater mInflator;
+
+
+ public RileyLinkHistoryListAdapter() {
+ super();
+ historyItemList = new ArrayList<>();
+ mInflator = RileyLinkStatusHistory.this.getLayoutInflater();
+ }
+
+
+ public void addItem(RLHistoryItem item) {
+ if (!historyItemList.contains(item)) {
+ historyItemList.add(item);
+ notifyDataSetChanged();
+ }
+ }
+
+
+ public RLHistoryItem getHistoryItem(int position) {
+ return historyItemList.get(position);
+ }
+
+
+ public void addItemsAndClean(List items) {
+ this.historyItemList.clear();
+
+ for (RLHistoryItem item : items) {
+
+ if (!historyItemList.contains(item) && isValidItem(item)) {
+ historyItemList.add(item);
+ }
+ }
+
+ notifyDataSetChanged();
+ }
+
+
+ private boolean isValidItem(RLHistoryItem item) {
+
+ PumpDeviceState pumpState = item.getPumpDeviceState();
+
+ if ((pumpState != null) && //
+ (pumpState == PumpDeviceState.Sleeping || //
+ pumpState == PumpDeviceState.Active || //
+ pumpState == PumpDeviceState.WakingUp //
+ ))
+ return false;
+
+ return true;
+
+ }
+
+
+ public void clear() {
+ historyItemList.clear();
+ notifyDataSetChanged();
+ }
+
+
+ @Override
+ public int getCount() {
+ return historyItemList.size();
+ }
+
+
+ @Override
+ public Object getItem(int i) {
+ return historyItemList.get(i);
+ }
+
+
+ @Override
+ public long getItemId(int i) {
+ return i;
+ }
+
+
+ @Override
+ public View getView(int i, View view, ViewGroup viewGroup) {
+ RileyLinkStatusHistory.ViewHolder viewHolder;
+ // General ListView optimization code.
+ if (view == null) {
+ view = mInflator.inflate(R.layout.rileylink_status_history_item, null);
+ viewHolder = new RileyLinkStatusHistory.ViewHolder();
+ viewHolder.itemTime = (TextView)view.findViewById(R.id.rileylink_history_time);
+ viewHolder.itemSource = (TextView)view.findViewById(R.id.rileylink_history_source);
+ viewHolder.itemDescription = (TextView)view.findViewById(R.id.rileylink_history_description);
+ view.setTag(viewHolder);
+ } else {
+ viewHolder = (RileyLinkStatusHistory.ViewHolder)view.getTag();
+ }
+
+ RLHistoryItem item = historyItemList.get(i);
+ viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime()));
+ viewHolder.itemSource.setText(item.getSource().getDesc()); // for now
+ viewHolder.itemDescription.setText(item.getDescription());
+
+ return view;
+ }
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkService.java
index e4f53b3bca..dd4ed5b228 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkService.java
@@ -1,5 +1,10 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service;
+import static info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil.getRileyLinkCommunicationManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
@@ -9,9 +14,6 @@ import android.content.IntentFilter;
import android.os.PowerManager;
import android.support.v4.content.LocalBroadcastManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
@@ -30,37 +32,29 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.ServiceTaskExecutor;
import info.nightscout.utils.SP;
-import static info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil.getRileyLinkCommunicationManager;
-
//import static info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.;
-
/**
* Created by andy on 5/6/18.
* Split from original file and renamed.
*/
public abstract class RileyLinkService extends Service {
+ protected static final String WAKELOCKNAME = "com.gxwtech.roundtrip2.RoundtripServiceWakeLock";
private static final Logger LOG = LoggerFactory.getLogger(RileyLinkService.class);
-
-
- protected BluetoothAdapter bluetoothAdapter;
-
+ protected static volatile PowerManager.WakeLock lockStatic = null;
// Our hardware/software connection
public RileyLinkBLE rileyLinkBLE; // android-bluetooth management
+ protected BluetoothAdapter bluetoothAdapter;
protected RFSpy rfspy; // interface for RL xxx Mhz radio.
- //protected boolean needBluetoothPermission = true;
- //protected RileyLinkIPCConnection rileyLinkIPCConnection;
+ // protected boolean needBluetoothPermission = true;
+ // protected RileyLinkIPCConnection rileyLinkIPCConnection;
protected Context context;
- //public RileyLinkCommunicationManager pumpCommunicationManager;
+ // public RileyLinkCommunicationManager pumpCommunicationManager;
protected BroadcastReceiver mBroadcastReceiver;
-
protected RileyLinkServiceData rileyLinkServiceData;
protected RileyLinkTargetFrequency rileyLinkTargetFrequency;
- protected static final String WAKELOCKNAME = "com.gxwtech.roundtrip2.RoundtripServiceWakeLock";
- protected static volatile PowerManager.WakeLock lockStatic = null;
-
public RileyLinkService(Context context) {
super();
@@ -116,16 +110,17 @@ public abstract class RileyLinkService extends Service {
super.onCreate();
LOG.debug("onCreate");
- //rileyLinkIPCConnection = new RileyLinkIPCConnection(context); // TODO We might be able to remove this -- Andy
- //RileyLinkUtil.setRileyLinkIPCConnection(rileyLinkIPCConnection);
-
+ // rileyLinkIPCConnection = new RileyLinkIPCConnection(context); // TODO We might be able to remove this -- Andy
+ // RileyLinkUtil.setRileyLinkIPCConnection(rileyLinkIPCConnection);
mBroadcastReceiver = new BroadcastReceiver() {
+
@Override
public void onReceive(Context context, Intent intent) {
- /* here we can listen for local broadcasts, then send ourselves
- * a specific intent to deal with them, if we wish
- */
+ /*
+ * here we can listen for local broadcasts, then send ourselves
+ * a specific intent to deal with them, if we wish
+ */
if (intent == null) {
LOG.error("onReceive: received null intent");
} else {
@@ -135,18 +130,22 @@ public abstract class RileyLinkService extends Service {
} else {
if (action.equals(RileyLinkConst.Intents.BluetoothConnected)) {
- //rileyLinkIPCConnection.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_note_FindingRileyLink), null);
+ // rileyLinkIPCConnection.sendNotification(new
+ // ServiceNotification(RT2Const.IPC.MSG_note_FindingRileyLink), null);
ServiceTaskExecutor.startTask(new DiscoverGattServicesTask());
} else if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnected)) {
if (bluetoothAdapter.isEnabled()) {
- RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothReady, RileyLinkError.RileyLinkUnreachable);
+ RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothReady,
+ RileyLinkError.RileyLinkUnreachable);
} else {
- RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
+ RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError,
+ RileyLinkError.BluetoothDisabled);
}
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
LOG.warn("MedtronicConst.Intents.RileyLinkReady");
// FIXME
- //rileyLinkIPCConnection.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_note_WakingPump), null);
+ // rileyLinkIPCConnection.sendNotification(new
+ // ServiceNotification(RT2Const.IPC.MSG_note_WakingPump), null);
rileyLinkBLE.enableNotifications();
rfspy.startReader(); // call startReader from outside?
@@ -163,7 +162,8 @@ public abstract class RileyLinkService extends Service {
LOG.info("Announcing RileyLink open For business");
} else if (action.equals(RileyLinkConst.Intents.BluetoothReconnected)) {
LOG.debug("Reconnecting Bluetooth");
- //rileyLinkIPCConnection.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_note_FindingRileyLink), null);
+ // rileyLinkIPCConnection.sendNotification(new
+ // ServiceNotification(RT2Const.IPC.MSG_note_FindingRileyLink), null);
bluetoothInit();
ServiceTaskExecutor.startTask(new DiscoverGattServicesTask(true));
} else if (action.equals(RileyLinkConst.IPC.MSG_PUMP_tunePump)) {
@@ -183,56 +183,56 @@ public abstract class RileyLinkService extends Service {
if (RileylinkBLEAddress.equals("")) {
LOG.error("No Rileylink BLE Address saved in app");
} else {
- //showBusy("Configuring Service", 50);
- //rileyLinkBLE.findRileyLink(RileylinkBLEAddress);
+ // showBusy("Configuring Service", 50);
+ // rileyLinkBLE.findRileyLink(RileylinkBLEAddress);
reconfigureRileyLink(RileylinkBLEAddress);
- //MainApp.getServiceClientConnection().setThisRileylink(RileylinkBLEAddress);
+ // MainApp.getServiceClientConnection().setThisRileylink(RileylinkBLEAddress);
}
}
+ /*
+ * else if (RT2Const.serviceLocal.INTENT_sessionCompleted.equals(action)) {
+ * Bundle bundle = intent.getBundleExtra(RT2Const.IPC.bundleKey);
+ * if (bundle != null) {
+ * ServiceTransport transport = new ServiceTransport(bundle);
+ * //rileyLinkIPCConnection.sendTransport(transport, transport.getSenderHashcode());
+ * //RileyLinkUtil.send
+ * } else {
+ * LOG.error("sessionCompleted: no bundle!");
+ * }
+ * }
+ */
-
-
- /*else if (RT2Const.serviceLocal.INTENT_sessionCompleted.equals(action)) {
- Bundle bundle = intent.getBundleExtra(RT2Const.IPC.bundleKey);
- if (bundle != null) {
- ServiceTransport transport = new ServiceTransport(bundle);
- //rileyLinkIPCConnection.sendTransport(transport, transport.getSenderHashcode());
- //RileyLinkUtil.send
- } else {
- LOG.error("sessionCompleted: no bundle!");
- }
- }*/
-
- /*else
-
- if (case RT2Const.local.INTENT_serviceConnected:
- case RT2Const.local.INTENT_NEW_rileylinkAddressKey:
- showIdle();
- /**
- * Client MUST send a "UseThisRileylink" message because it asserts that
- * the user has given explicit permission to use bluetooth.
- *
- * We can change the format so that it is a simple "bluetooth OK" message,
- * rather than an explicit address of a Rileylink, and the Service can
- * use the last known good value. But the kick-off of bluetooth ops must
- * come from an Activity.
- */
- /* String RileylinkBLEAddress = SP.getString(MedtronicConst.Prefs.RileyLinkAddress, "");
- if (RileylinkBLEAddress.equals("")) {
- // TODO: 11/07/2016 @TIM UI message for user
- Log.e(TAG, "No Rileylink BLE Address saved in app");
- } else {
- //showBusy("Configuring Service", 50);
- MainApp.getServiceClientConnection().setThisRileylink(RileylinkBLEAddress);
- }
- break;
- case RT2Const.local.INTENT_NEW_pumpIDKey:
- MainApp.getServiceClientConnection().sendPUMP_useThisDevice(SP.getString(MedtronicConst.Prefs.PumpSerial, ""));
- break;
-
- */
-
+ /*
+ * else
+ *
+ * if (case RT2Const.local.INTENT_serviceConnected:
+ * case RT2Const.local.INTENT_NEW_rileylinkAddressKey:
+ * showIdle();
+ * /**
+ * Client MUST send a "UseThisRileylink" message because it asserts that
+ * the user has given explicit permission to use bluetooth.
+ *
+ * We can change the format so that it is a simple "bluetooth OK" message,
+ * rather than an explicit address of a Rileylink, and the Service can
+ * use the last known good value. But the kick-off of bluetooth ops must
+ * come from an Activity.
+ */
+ /*
+ * String RileylinkBLEAddress = SP.getString(MedtronicConst.Prefs.RileyLinkAddress, "");
+ * if (RileylinkBLEAddress.equals("")) {
+ * // TODO: 11/07/2016 @TIM UI message for user
+ * Log.e(TAG, "No Rileylink BLE Address saved in app");
+ * } else {
+ * //showBusy("Configuring Service", 50);
+ * MainApp.getServiceClientConnection().setThisRileylink(RileylinkBLEAddress);
+ * }
+ * break;
+ * case RT2Const.local.INTENT_NEW_pumpIDKey:
+ * MainApp.getServiceClientConnection().sendPUMP_useThisDevice(SP.getString(MedtronicConst.Prefs.
+ * PumpSerial, ""));
+ * break;
+ */
else {
LOG.error("Unhandled broadcast: action=" + action);
@@ -249,14 +249,14 @@ public abstract class RileyLinkService extends Service {
intentFilter.addAction(RileyLinkConst.Intents.RileyLinkDisconnected);
intentFilter.addAction(RileyLinkConst.Intents.BluetoothReconnected);
intentFilter.addAction(RileyLinkConst.Intents.RileyLinkNewAddressSet);
- //intentFilter.addAction(RT2Const.serviceLocal.ipcBound);
- //intentFilter.addAction(RT2Const.IPC.MSG_BLE_accessGranted);
- //intentFilter.addAction(RT2Const.IPC.MSG_BLE_accessDenied);
- //intentFilter.addAction(RT2Const.IPC.MSG_BLE_useThisDevice);
+ // intentFilter.addAction(RT2Const.serviceLocal.ipcBound);
+ // intentFilter.addAction(RT2Const.IPC.MSG_BLE_accessGranted);
+ // intentFilter.addAction(RT2Const.IPC.MSG_BLE_accessDenied);
+ // intentFilter.addAction(RT2Const.IPC.MSG_BLE_useThisDevice);
intentFilter.addAction(RileyLinkConst.IPC.MSG_PUMP_tunePump);
- //intentFilter.addAction(RT2Const.IPC.MSG_PUMP_useThisAddress);
+ // intentFilter.addAction(RT2Const.IPC.MSG_PUMP_useThisAddress);
intentFilter.addAction(RileyLinkConst.IPC.MSG_ServiceCommand);
- //intentFilter.addAction(RileyLinkConst.serviceLocal.INTENT_sessionCompleted);
+ // intentFilter.addAction(RileyLinkConst.serviceLocal.INTENT_sessionCompleted);
addPumpSpecificIntents(intentFilter);
@@ -268,10 +268,13 @@ public abstract class RileyLinkService extends Service {
public abstract RileyLinkCommunicationManager getDeviceCommunicationManager();
+
public abstract void addPumpSpecificIntents(IntentFilter intentFilter);
+
public abstract void handlePumpSpecificIntents(Intent intent);
+
public abstract void handleIncomingServiceTransport(Intent intent);
@@ -280,24 +283,24 @@ public abstract class RileyLinkService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LOG.debug("onStartCommand");
-// if (intent != null) {
-// PowerManager.WakeLock lock = getLock(this.getApplicationContext());
-//
-// if (!lock.isHeld() || (flags & START_FLAG_REDELIVERY) != 0) {
-// lock.acquire();
-// }
-//
-// // This will end up running onHandleIntent
-// super.onStartCommand(intent, flags, startId);
-// } else {
-// LOG.error("Received null intent?");
-// }
+ // if (intent != null) {
+ // PowerManager.WakeLock lock = getLock(this.getApplicationContext());
+ //
+ // if (!lock.isHeld() || (flags & START_FLAG_REDELIVERY) != 0) {
+ // lock.acquire();
+ // }
+ //
+ // // This will end up running onHandleIntent
+ // super.onStartCommand(intent, flags, startId);
+ // } else {
+ // LOG.error("Received null intent?");
+ // }
RileyLinkUtil.setContext(getApplicationContext());
- //bluetoothInit();
+ // bluetoothInit();
- //return (START_REDELIVER_INTENT | START_STICKY);
+ // return (START_REDELIVER_INTENT | START_STICKY);
return (START_STICKY);
}
@@ -339,22 +342,24 @@ public abstract class RileyLinkService extends Service {
LOG.info("No change to RL address. Not reconnecting.");
return false;
} else {
- LOG.warn("Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress + "), reconnecting to new: " + deviceAddress);
+ LOG.warn("Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
+ + "), reconnecting to new: " + deviceAddress);
rileyLinkBLE.disconnect();
// prolly need to shut down listening thread too?
- //SP.putString(MedtronicConst.Prefs.RileyLinkAddress, deviceAddress);
+ // SP.putString(MedtronicConst.Prefs.RileyLinkAddress, deviceAddress);
rileyLinkServiceData.rileylinkAddress = deviceAddress;
rileyLinkBLE.findRileyLink(rileyLinkServiceData.rileylinkAddress);
return true;
}
} else {
- //Toast.makeText(context, "Using RL " + deviceAddress, Toast.LENGTH_SHORT).show();
+ // Toast.makeText(context, "Using RL " + deviceAddress, Toast.LENGTH_SHORT).show();
LOG.debug("handleIPCMessage: Using RL " + deviceAddress);
if (RileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
if (!bluetoothInit()) {
- LOG.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}", RileyLinkUtil.getError().name());
+ LOG.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
+ RileyLinkUtil.getError().name());
return false;
}
}
@@ -365,33 +370,35 @@ public abstract class RileyLinkService extends Service {
}
}
-//
-// public synchronized static PowerManager.WakeLock getLock(Context context) {
-// if (lockStatic == null) {
-// PowerManager mgr = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
-//
-// lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCKNAME);
-// lockStatic.setReferenceCounted(true);
-// }
-//
-// return lockStatic;
-// }
+ //
+ // public synchronized static PowerManager.WakeLock getLock(Context context) {
+ // if (lockStatic == null) {
+ // PowerManager mgr = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+ //
+ // lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCKNAME);
+ // lockStatic.setReferenceCounted(true);
+ // }
+ //
+ // return lockStatic;
+ // }
public void sendServiceTransportResponse(ServiceTransport transport, ServiceResult serviceResult) {
// get the key (hashcode) of the client who requested this
- /*Integer clientHashcode = transport.getSenderHashcode();
- // make a new bundle to send as the message data
- transport.setServiceResult(serviceResult);
- // FIXME
- transport.setTransportType(RT2Const.IPC.MSG_ServiceResult); */
- //rileyLinkIPCConnection.sendTransport(transport, clientHashcode);
+ /*
+ * Integer clientHashcode = transport.getSenderHashcode();
+ * // make a new bundle to send as the message data
+ * transport.setServiceResult(serviceResult);
+ * // FIXME
+ * transport.setTransportType(RT2Const.IPC.MSG_ServiceResult);
+ */
+ // rileyLinkIPCConnection.sendTransport(transport, clientHashcode);
LOG.error("sendServiceTransportResponse not implemented.");
}
public boolean sendNotification(ServiceNotification notification, Integer clientHashcode) {
- //return rileyLinkIPCConnection.sendNotification(notification, clientHashcode);
+ // return rileyLinkIPCConnection.sendNotification(notification, clientHashcode);
LOG.error("sendNotification not implemented.");
return false;
}
@@ -399,10 +406,10 @@ public abstract class RileyLinkService extends Service {
protected void sendBLERequestForAccess() {
// FIXME
- //serviceConnection.sendMessage(RT2Const.IPC.MSG_BLE_requestAccess);
+ // serviceConnection.sendMessage(RT2Const.IPC.MSG_BLE_requestAccess);
- //Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- //startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+ // Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ // startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
@@ -425,7 +432,7 @@ public abstract class RileyLinkService extends Service {
// we have an old frequency, so let's start there.
newFrequency = getDeviceCommunicationManager().quickTuneForPump(lastGoodFrequency);
if (newFrequency == 0.0) {
- // quick scan failed to find pump. Try full scan
+ // quick scan failed to find pump. Try full scan
LOG.warn("Failed to find pump near last saved frequency, doing full scan");
newFrequency = getDeviceCommunicationManager().tuneForDevice();
}
@@ -447,7 +454,8 @@ public abstract class RileyLinkService extends Service {
if (newFrequency == 0.0d) {
// error tuning pump, pump not present ??
- RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
+ RileyLinkUtil
+ .setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkServiceData.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkServiceData.java
index 53d83caf43..b54316d583 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkServiceData.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/RileyLinkServiceData.java
@@ -1,9 +1,8 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service;
-import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkServiceState;
-
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkTargetDevice;
/**
* Created by andy on 16/05/2018.
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceCommand.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceCommand.java
index b8f4456016..2116e3a746 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceCommand.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceCommand.java
@@ -6,6 +6,7 @@ import android.os.Bundle;
* Created by geoff on 6/25/16.
*/
public class ServiceCommand extends ServiceMessage {
+
public ServiceCommand() {
map = new Bundle();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceMessage.java
index 95bc7ba12e..c0541ac293 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceMessage.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceMessage.java
@@ -8,6 +8,7 @@ import android.os.Bundle;
* Base class for all messages passed between service and client
*/
public class ServiceMessage {
+
protected Bundle map = new Bundle();
@@ -36,5 +37,4 @@ public class ServiceMessage {
return map.getString("ServiceMessageType");
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceNotification.java
index a821e25538..512170d4d5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceNotification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceNotification.java
@@ -5,10 +5,10 @@ import android.os.Bundle;
/**
* Created by geoff on 7/6/16.
*
- * These are "one liner" messages between client and service.
- * Must still be contained within ServiceTransports
+ * These are "one liner" messages between client and service. Must still be contained within ServiceTransports
*/
public class ServiceNotification extends ServiceMessage {
+
public ServiceNotification() {
}
@@ -36,14 +36,13 @@ public class ServiceNotification extends ServiceMessage {
}
- public void setNotificationType(String notificationType) {
- map.putString("NotificationType", notificationType);
- }
-
-
public String getNotificationType() {
return map.getString("NotificationType", "");
}
+ public void setNotificationType(String notificationType) {
+ map.putString("NotificationType", notificationType);
+ }
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceResult.java
index a688e017e7..3cd1d43110 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceResult.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceResult.java
@@ -6,6 +6,13 @@ import android.os.Bundle;
* Created by geoff on 6/25/16.
*/
public class ServiceResult extends ServiceMessage {
+
+ public static final int ERROR_MALFORMED_PUMP_RESPONSE = 1;
+ public static final int ERROR_NULL_PUMP_RESPONSE = 2;
+ public static final int ERROR_INVALID_PUMP_RESPONSE = 3;
+ public static final int ERROR_PUMP_BUSY = 4;
+
+
public ServiceResult() {
init();
}
@@ -20,6 +27,22 @@ public class ServiceResult extends ServiceMessage {
}
+ public static final String getErrorDescription(int errorCode) {
+ switch (errorCode) {
+ case ERROR_MALFORMED_PUMP_RESPONSE:
+ return "Malformed Pump Response";
+ case ERROR_NULL_PUMP_RESPONSE:
+ return "Null pump response";
+ case ERROR_INVALID_PUMP_RESPONSE:
+ return "Invalid pump response";
+ case ERROR_PUMP_BUSY:
+ return "A pump command session is already in progress";
+ default:
+ return "Unknown error code (" + errorCode + ")";
+ }
+ }
+
+
@Override
public void init() {
super.init();
@@ -29,13 +52,13 @@ public class ServiceResult extends ServiceMessage {
}
- public void setServiceResultType(String serviceResultType) {
- map.putString("ServiceResultType", serviceResultType);
+ public String getServiceResultType() {
+ return map.getString("ServiceResultType", "ServiceResult");
}
- public String getServiceResultType() {
- return map.getString("ServiceResultType", "ServiceResult");
+ public void setServiceResultType(String serviceResultType) {
+ map.putString("ServiceResultType", serviceResultType);
}
@@ -56,28 +79,6 @@ public class ServiceResult extends ServiceMessage {
}
- public static final int ERROR_MALFORMED_PUMP_RESPONSE = 1;
- public static final int ERROR_NULL_PUMP_RESPONSE = 2;
- public static final int ERROR_INVALID_PUMP_RESPONSE = 3;
- public static final int ERROR_PUMP_BUSY = 4;
-
-
- public static final String getErrorDescription(int errorCode) {
- switch (errorCode) {
- case ERROR_MALFORMED_PUMP_RESPONSE:
- return "Malformed Pump Response";
- case ERROR_NULL_PUMP_RESPONSE:
- return "Null pump response";
- case ERROR_INVALID_PUMP_RESPONSE:
- return "Invalid pump response";
- case ERROR_PUMP_BUSY:
- return "A pump command session is already in progress";
- default:
- return "Unknown error code (" + errorCode + ")";
- }
- }
-
-
public boolean resultIsOK() {
return ("OK".equals(map.getString("result", "")));
}
@@ -92,5 +93,4 @@ public class ServiceResult extends ServiceMessage {
return map.getString("result", "");
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceTransport.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceTransport.java
index 75cca7c201..9ec6a22c3d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceTransport.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/data/ServiceTransport.java
@@ -6,8 +6,7 @@ import android.os.Parcel;
/**
* Created by geoff on 7/6/16.
*
- * This class exists to hold a ServiceCommand along with transport variables
- * such as time sent, time received, sender.
+ * This class exists to hold a ServiceCommand along with transport variables such as time sent, time received, sender.
* May also contain result, if the command is completed.
*/
public class ServiceTransport extends ServiceMessage {
@@ -39,13 +38,18 @@ public class ServiceTransport extends ServiceMessage {
}
+ public Integer getSenderHashcode() {
+ return map.getInt("senderHashCode", 0);
+ }
+
+
public void setSenderHashcode(Integer senderHashcode) {
map.putInt("senderHashcode", senderHashcode);
}
- public Integer getSenderHashcode() {
- return map.getInt("senderHashCode", 0);
+ public ServiceCommand getServiceCommand() {
+ return new ServiceCommand(map.getBundle("ServiceCommand"));
}
@@ -55,13 +59,13 @@ public class ServiceTransport extends ServiceMessage {
}
- public ServiceCommand getServiceCommand() {
- return new ServiceCommand(map.getBundle("ServiceCommand"));
+ public boolean hasServiceCommand() {
+ return (getMap().containsKey("ServiceCommand"));
}
- public boolean hasServiceCommand() {
- return (getMap().containsKey("ServiceCommand"));
+ public String getTransportType() {
+ return map.getString("transportType", "unknown");
}
@@ -72,8 +76,8 @@ public class ServiceTransport extends ServiceMessage {
}
- public String getTransportType() {
- return map.getString("transportType", "unknown");
+ public ServiceResult getServiceResult() {
+ return new ServiceResult(map.getBundle("ServiceResult"));
}
@@ -83,13 +87,13 @@ public class ServiceTransport extends ServiceMessage {
}
- public ServiceResult getServiceResult() {
- return new ServiceResult(map.getBundle("ServiceResult"));
+ public boolean hasServiceResult() {
+ return (getMap().containsKey("ServiceResult"));
}
- public boolean hasServiceResult() {
- return (getMap().containsKey("ServiceResult"));
+ public ServiceNotification getServiceNotification() {
+ return new ServiceNotification(map.getBundle("ServiceNotification"));
}
@@ -99,11 +103,6 @@ public class ServiceTransport extends ServiceMessage {
}
- public ServiceNotification getServiceNotification() {
- return new ServiceNotification(map.getBundle("ServiceNotification"));
- }
-
-
public boolean hasServiceNotification() {
return (map.containsKey("ServiceNotification"));
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/InitializePumpManagerTask.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/InitializePumpManagerTask.java
index 354d3284e1..e824eb0548 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/InitializePumpManagerTask.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/InitializePumpManagerTask.java
@@ -12,10 +12,10 @@ import info.nightscout.utils.SP;
/**
* Created by geoff on 7/9/16.
*
- * This class is intended to be run by the Service, for the Service.
- * Not intended for clients to run.
+ * This class is intended to be run by the Service, for the Service. Not intended for clients to run.
*/
public class InitializePumpManagerTask extends ServiceTask {
+
private static final String TAG = "InitPumpManagerTask";
@@ -35,7 +35,10 @@ public class InitializePumpManagerTask extends ServiceTask {
// FIXME
double lastGoodFrequency = SP.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0d);
- if ((lastGoodFrequency > 0.0d) && RileyLinkUtil.getRileyLinkCommunicationManager().isValidFrequency(lastGoodFrequency)) {
+ RileyLinkUtil.getRileyLinkServiceData().lastGoodFrequency = lastGoodFrequency;
+
+ if ((lastGoodFrequency > 0.0d)
+ && RileyLinkUtil.getRileyLinkCommunicationManager().isValidFrequency(lastGoodFrequency)) {
Log.i(TAG, String.format("Setting radio frequency to %.2fMHz", lastGoodFrequency));
RileyLinkUtil.getRileyLinkCommunicationManager().setRadioFrequencyForPump(lastGoodFrequency);
@@ -45,13 +48,14 @@ public class InitializePumpManagerTask extends ServiceTask {
// FIXME maybe remove in AAPS
if (foundThePump) {
RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
- //RileyLinkUtil.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_PUMP_pumpFound), null);
+ // RileyLinkUtil.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_PUMP_pumpFound), null);
} else {
- RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.NoContactWithDevice);
- //RileyLinkUtil.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_PUMP_pumpLost), null);
+ RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorError,
+ RileyLinkError.NoContactWithDevice);
+ // RileyLinkUtil.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_PUMP_pumpLost), null);
}
- //RileyLinkUtil.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_note_Idle), null);
+ // RileyLinkUtil.sendNotification(new ServiceNotification(RT2Const.IPC.MSG_note_Idle), null);
} else {
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/PumpTask.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/PumpTask.java
index bd4ea9b609..7da9889055 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/PumpTask.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/PumpTask.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.data.S
* Created by geoff on 7/10/16.
*/
public class PumpTask extends ServiceTask {
+
public PumpTask() {
super();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTask.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTask.java
index 5e428f6702..c9f30e8e70 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTask.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTask.java
@@ -6,9 +6,10 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.data.S
* Created by geoff on 7/9/16.
*/
public class ServiceTask implements Runnable {
+
private static final String TAG = "ServiceTask(base)";
- protected ServiceTransport mTransport;
public boolean completed = false;
+ protected ServiceTransport mTransport;
public ServiceTask() {
@@ -46,9 +47,8 @@ public class ServiceTask implements Runnable {
}
/*
- protected void sendResponse(ServiceResult result) {
- RoundtripService.getInstance().sendServiceTransportResponse(mTransport,result);
- }
- */
+ * protected void sendResponse(ServiceResult result) {
+ * RoundtripService.getInstance().sendServiceTransportResponse(mTransport,result);
+ * }
+ */
}
-
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTaskExecutor.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTaskExecutor.java
index bdecb72294..ee5ec9bb7c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTaskExecutor.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/ServiceTaskExecutor.java
@@ -1,17 +1,18 @@
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks;
-import android.util.Log;
-
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import android.util.Log;
+
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
/**
* Created by geoff on 7/9/16.
*/
public class ServiceTaskExecutor extends ThreadPoolExecutor {
+
private static final String TAG = "ServiceTaskExecutor";
private static ServiceTaskExecutor instance;
private static LinkedBlockingQueue taskQueue = new LinkedBlockingQueue<>();
@@ -20,15 +21,17 @@ public class ServiceTaskExecutor extends ThreadPoolExecutor {
instance = new ServiceTaskExecutor();
}
- public static ServiceTaskExecutor getInstance() {
- return instance;
- }
private ServiceTaskExecutor() {
super(1, 1, 10000, TimeUnit.MILLISECONDS, taskQueue);
}
+ public static ServiceTaskExecutor getInstance() {
+ return instance;
+ }
+
+
public static ServiceTask startTask(ServiceTask task) {
instance.execute(task); // task will be run on async thread from pool.
return task;
@@ -38,7 +41,7 @@ public class ServiceTaskExecutor extends ThreadPoolExecutor {
// FIXME
protected void beforeExecute(Thread t, Runnable r) {
// This is run on either caller UI thread or Service UI thread.
- ServiceTask task = (ServiceTask) r;
+ ServiceTask task = (ServiceTask)r;
Log.v(TAG, "About to run task " + task.getClass().getSimpleName());
RileyLinkUtil.setCurrentTask(task);
task.preOp();
@@ -48,7 +51,7 @@ public class ServiceTaskExecutor extends ThreadPoolExecutor {
// FIXME
protected void afterExecute(Runnable r, Throwable t) {
// This is run on either caller UI thread or Service UI thread.
- ServiceTask task = (ServiceTask) r;
+ ServiceTask task = (ServiceTask)r;
task.postOp();
Log.v(TAG, "Finishing task " + task.getClass().getSimpleName());
RileyLinkUtil.finishCurrentTask(task);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/WakeAndTuneTask.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/WakeAndTuneTask.java
index c593d097ab..58dd7e712a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/WakeAndTuneTask.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/hw/rileylink/service/tasks/WakeAndTuneTask.java
@@ -8,7 +8,6 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.service.RileyLinkMedtron
*/
public class WakeAndTuneTask extends PumpTask {
-
public WakeAndTuneTask() {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ByteUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ByteUtil.java
index 39239e86d3..8dbf7c3e79 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ByteUtil.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ByteUtil.java
@@ -7,18 +7,20 @@ import java.util.List;
* Created by geoff on 4/28/15.
*/
public class ByteUtil {
- private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+ private final static char[] HEX_DIGITS = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
private final static String HEX_DIGITS_STR = "0123456789ABCDEF";
public static byte highByte(short s) {
- return (byte) (s / 256);
+ return (byte)(s / 256);
}
public static byte lowByte(short s) {
- return (byte) (s % 256);
+ return (byte)(s % 256);
}
@@ -26,8 +28,8 @@ public class ByteUtil {
return (b < 0) ? b + 256 : b;
}
- /* For Reference: static void System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length) */
+ /* For Reference: static void System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length) */
public static byte[] concat(byte[] a, byte[] b) {
@@ -78,7 +80,7 @@ public class ByteUtil {
if (ra.length == 0) {
return rval;
}
- for(int i = 0; i < ra.length; i++) {
+ for (int i = 0; i < ra.length; i++) {
rval = rval + HEX_DIGITS[(ra[i] & 0xF0) >> 4];
rval = rval + HEX_DIGITS[(ra[i] & 0x0F)];
if (i < ra.length - 1) {
@@ -91,8 +93,8 @@ public class ByteUtil {
public static String showPrintable(byte[] ra) {
String s = new String();
- for(int i = 0; i < ra.length; i++) {
- char c = (char) ra[i];
+ for (int i = 0; i < ra.length; i++) {
+ char c = (char)ra[i];
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {
s = s + c;
} else {
@@ -105,12 +107,12 @@ public class ByteUtil {
public static byte[] fromHexString(String src) {
String s = src.toUpperCase();
- byte[] rval = new byte[]{};
+ byte[] rval = new byte[] {};
if ((s.length() % 2) != 0) {
// invalid hex string!
return null;
}
- for(int i = 0; i < s.length(); i += 2) {
+ for (int i = 0; i < s.length(); i += 2) {
int highNibbleOrd = HEX_DIGITS_STR.indexOf(s.charAt(i));
if (highNibbleOrd < 0) {
// Not a hex digit.
@@ -121,7 +123,7 @@ public class ByteUtil {
// Not a hex digit
return null;
}
- rval = concat(rval, (byte) (highNibbleOrd * 16 + lowNibbleOrd));
+ rval = concat(rval, (byte)(highNibbleOrd * 16 + lowNibbleOrd));
}
return rval;
}
@@ -129,7 +131,7 @@ public class ByteUtil {
public static byte[] fromByteArray(List byteArray) {
byte[] rval = new byte[byteArray.size()];
- for(int i = 0; i < byteArray.size(); i++) {
+ for (int i = 0; i < byteArray.size(); i++) {
rval[i] = byteArray.get(i);
}
return rval;
@@ -138,7 +140,7 @@ public class ByteUtil {
public static ArrayList toByteArray(byte[] data) {
ArrayList rval = new ArrayList<>(data.length);
- for(int i = 0; i < data.length; i++) {
+ for (int i = 0; i < data.length; i++) {
rval.add(i, new Byte(data[i]));
}
return rval;
@@ -157,7 +159,7 @@ public class ByteUtil {
return -1;
}
int acc = 0;
- for(i = 0; i < len1; i++) {
+ for (i = 0; i < len1; i++) {
acc += s1[i];
acc -= s2[i];
if (acc != 0) {
@@ -171,10 +173,10 @@ public class ByteUtil {
/**
* Converts 4 (or less) ints into int. (Shorts are objects, so you can send null if you have less parameters)
*
- * @param b1 short 1
- * @param b2 short 2
- * @param b3 short 3
- * @param b4 short 4
+ * @param b1 short 1
+ * @param b2 short 2
+ * @param b3 short 3
+ * @param b4 short 4
* @param flag Conversion Flag (Big Endian, Little endian)
* @return int value
*/
@@ -218,16 +220,10 @@ public class ByteUtil {
}
- public enum BitConversion {
- LITTLE_ENDIAN, // 20 0 0 0 = reverse
- BIG_ENDIAN // 0 0 0 20 = normal - java
- }
-
-
public static List getListFromByteArray(byte[] array) {
List listOut = new ArrayList();
- for(byte val : array) {
+ for (byte val : array) {
listOut.add(val);
}
@@ -240,4 +236,9 @@ public class ByteUtil {
return k;
}
+ public enum BitConversion {
+ LITTLE_ENDIAN, // 20 0 0 0 = reverse
+ BIG_ENDIAN // 0 0 0 20 = normal - java
+ }
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/CRC.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/CRC.java
index 81b1538042..ba2c7ac77b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/CRC.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/CRC.java
@@ -5,17 +5,71 @@ package info.nightscout.androidaps.plugins.PumpCommon.utils;
*/
public class CRC {
- static final int[] crc8lookup = new int[]{0, 155, 173, 54, 193, 90, 108, 247, 25, 130, 180, 47, 216, 67, 117, 238, 50, 169, //
- 159, 4, 243, 104, 94, 197, 43, 176, 134, 29, 234, 113, 71, 220, 100, 255, 201, 82, 165, 62, 8, 147, 125, 230, 208, 75, //
- 188, 39, 17, 138, 86, 205, 251, 96, 151, 12, 58, 161, 79, 212, 226, 121, 142, 21, 35, 184, 200, 83, 101, 254, 9, 146, //
- 164, 63, 209, 74, 124, 231, 16, 139, 189, 38, 250, 97, 87, 204, 59, 160, 150, 13, 227, 120, 78, 213, 34, 185, 143, 20, //
- 172, 55, 1, 154, 109, 246, 192, 91, 181, 46, 24, 131, 116, 239, 217, 66, 158, 5, 51, 168, 95, 196, 242, 105, 135, 28, 42, //
- 177, 70, 221, 235, 112, 11, 144, 166, 61, 202, 81, 103, 252, 18, 137, 191, 36, 211, 72, 126, 229, 57, 162, 148, 15, 248, //
- 99, 85, 206, 32, 187, 141, 22, 225, 122, 76, 215, 111, 244, 194, 89, 174, 53, 3, 152, 118, 237, 219, 64, 183, 44, 26, 129, //
- 93, 198, 240, 107, 156, 7, 49, 170, 68, 223, 233, 114, 133, 30, 40, 179, 195, 88, 110, 245, 2, 153, 175, 52, 218, 65, 119, //
- 236, 27, 128, 182, 45, 241, 106, 92, 199, 48, 171, 157, 6, 232, 115, 69, 222, 41, 178, 132, 31, 167, 60, 10, 145, 102, 253, //
- 203, 80, 190, 37, 19, 136, 127, 228, 210, 73, 149, 14, 56, 163, 84, 207, 249, 98, 140, 23, 33, 186, 77, 214, 224, 123};
-
+ static final int[] crc8lookup = new int[] {
+ 0, 155, 173, 54, 193, 90, 108, 247, 25,
+ 130,
+ 180,
+ 47,
+ 216,
+ 67,
+ 117,
+ 238,
+ 50,
+ 169, //
+ 159, 4, 243, 104, 94, 197, 43, 176, 134, 29, 234, 113, 71, 220, 100, 255, 201,
+ 82,
+ 165,
+ 62,
+ 8,
+ 147,
+ 125,
+ 230,
+ 208,
+ 75, //
+ 188, 39, 17, 138, 86, 205, 251, 96, 151, 12, 58, 161, 79, 212, 226, 121, 142, 21,
+ 35,
+ 184,
+ 200,
+ 83,
+ 101,
+ 254,
+ 9,
+ 146, //
+ 164, 63, 209, 74, 124, 231, 16, 139, 189, 38, 250, 97, 87, 204, 59, 160, 150, 13, 227,
+ 120,
+ 78,
+ 213,
+ 34,
+ 185,
+ 143,
+ 20, //
+ 172, 55, 1, 154, 109, 246, 192, 91, 181, 46, 24, 131, 116, 239, 217, 66, 158, 5, 51, 168, 95,
+ 196,
+ 242,
+ 105,
+ 135,
+ 28,
+ 42, //
+ 177, 70, 221, 235, 112, 11, 144, 166, 61, 202, 81, 103, 252, 18, 137, 191, 36, 211, 72, 126, 229,
+ 57,
+ 162,
+ 148,
+ 15,
+ 248, //
+ 99, 85, 206, 32, 187, 141, 22, 225, 122, 76, 215, 111, 244, 194, 89, 174, 53, 3, 152, 118, 237, 219, 64,
+ 183,
+ 44,
+ 26,
+ 129, //
+ 93, 198, 240, 107, 156, 7, 49, 170, 68, 223, 233, 114, 133, 30, 40, 179, 195, 88, 110, 245, 2, 153, 175, 52,
+ 218,
+ 65,
+ 119, //
+ 236, 27, 128, 182, 45, 241, 106, 92, 199, 48, 171, 157, 6, 232, 115, 69, 222, 41, 178, 132, 31, 167, 60, 10,
+ 145, 102,
+ 253, //
+ 203, 80, 190, 37, 19, 136, 127, 228, 210, 73, 149, 14, 56, 163, 84, 207, 249, 98, 140, 23, 33, 186, 77, 214,
+ 224, 123 };
public static byte crc8(byte[] data, int len) {
@@ -26,16 +80,16 @@ public class CRC {
if (len > data.length) {
len = data.length;
}
- for(int i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
int tmp = result;
int tmp2 = tmp ^ data[i];
int tmp3 = tmp2 & 0xFF;
int idx = tmp3;
- result = (byte) crc8lookup[idx];
-// log(String.format("iter=%d,tmp=0x%02x, tmp2=0x%02x, tmp3=0x%02x, lookup=0x%02x",i,tmp,tmp2,tmp3,result));
+ result = (byte)crc8lookup[idx];
+ // log(String.format("iter=%d,tmp=0x%02x, tmp2=0x%02x, tmp3=0x%02x, lookup=0x%02x",i,tmp,tmp2,tmp3,result));
}
// orig python:
- //result = klass.lookup[ ( result ^ block[ i ] & 0xFF ) ]
+ // result = klass.lookup[ ( result ^ block[ i ] & 0xFF ) ]
return result;
}
@@ -51,18 +105,19 @@ public class CRC {
int polynomial = 0x1021;
if (data != null) {
if (data.length > 0) {
- for(int j = 0; j < data.length; j++) {
+ for (int j = 0; j < data.length; j++) {
byte b = data[j];
- for(int i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
boolean bit = ((b >> (7 - i) & 1) == 1);
boolean c15 = ((crc >> 15 & 1) == 1);
crc <<= 1;
- if (c15 ^ bit) crc ^= polynomial;
+ if (c15 ^ bit)
+ crc ^= polynomial;
}
}
}
}
crc &= 0xffff;
- return new byte[]{(byte) ((crc & 0xFF00) >> 8), (byte) (crc & 0xFF)};
+ return new byte[] { (byte)((crc & 0xFF00) >> 8), (byte)(crc & 0xFF) };
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/HexDump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/HexDump.java
index e94a796529..bc394789ef 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/HexDump.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/HexDump.java
@@ -23,7 +23,9 @@ import java.util.List;
* only.
*/
public class HexDump {
- private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+ private final static char[] HEX_DIGITS = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
public static String dumpHexString(byte[] array) {
@@ -40,11 +42,11 @@ public class HexDump {
result.append("\n0x");
result.append(toHexString(offset));
- for(int i = offset; i < offset + length; i++) {
+ for (int i = offset; i < offset + length; i++) {
if (lineIndex == 16) {
result.append(" ");
- for(int j = 0; j < 16; j++) {
+ for (int j = 0; j < 16; j++) {
if (line[j] > ' ' && line[j] < '~') {
result.append(new String(line, j, 1));
} else {
@@ -68,11 +70,11 @@ public class HexDump {
if (lineIndex != 16) {
int count = (16 - lineIndex) * 3;
count++;
- for(int i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
result.append(" ");
}
- for(int i = 0; i < lineIndex; i++) {
+ for (int i = 0; i < lineIndex; i++) {
if (line[i] > ' ' && line[i] < '~') {
result.append(new String(line, i, 1));
} else {
@@ -99,7 +101,7 @@ public class HexDump {
char[] buf = new char[length * 2];
int bufIndex = 0;
- for(int i = offset; i < offset + length; i++) {
+ for (int i = offset; i < offset + length; i++) {
byte b = array[i];
buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
@@ -120,7 +122,7 @@ public class HexDump {
sb.append("Zero-length array");
} else {
- for(byte element : arr) {
+ for (byte element : arr) {
sb.append(getCorrectHexValue(element));
sb.append(" ");
}
@@ -134,7 +136,7 @@ public class HexDump {
public static String toHexStringDisplayable(List data) {
StringBuilder sb = new StringBuilder();
- for(byte element : data) {
+ for (byte element : data) {
sb.append(getCorrectHexValue(element));
sb.append(" ");
}
@@ -144,7 +146,7 @@ public class HexDump {
public static String getCorrectHexValue(byte inp) {
- String hx = Integer.toHexString((char) inp);
+ String hx = Integer.toHexString((char)inp);
hx = hx.toUpperCase();
if (hx.length() == 0)
@@ -185,10 +187,10 @@ public class HexDump {
public static byte[] toByteArray(int i) {
byte[] array = new byte[4];
- array[3] = (byte) (i & 0xFF);
- array[2] = (byte) ((i >> 8) & 0xFF);
- array[1] = (byte) ((i >> 16) & 0xFF);
- array[0] = (byte) ((i >> 24) & 0xFF);
+ array[3] = (byte)(i & 0xFF);
+ array[2] = (byte)((i >> 8) & 0xFF);
+ array[1] = (byte)((i >> 16) & 0xFF);
+ array[0] = (byte)((i >> 24) & 0xFF);
return array;
}
@@ -197,8 +199,8 @@ public class HexDump {
public static byte[] toByteArray(short i) {
byte[] array = new byte[2];
- array[1] = (byte) (i & 0xFF);
- array[0] = (byte) ((i >> 8) & 0xFF);
+ array[1] = (byte)(i & 0xFF);
+ array[0] = (byte)((i >> 8) & 0xFF);
return array;
}
@@ -220,12 +222,11 @@ public class HexDump {
int length = hexString.length();
byte[] buffer = new byte[length / 2];
- for(int i = 0; i < length; i += 2) {
- buffer[i / 2] = (byte) ((toByte(hexString.charAt(i)) << 4) | toByte(hexString.charAt(i + 1)));
+ for (int i = 0; i < length; i += 2) {
+ buffer[i / 2] = (byte)((toByte(hexString.charAt(i)) << 4) | toByte(hexString.charAt(i + 1)));
}
return buffer;
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/LocationHelper.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/LocationHelper.java
index 00d4a2c1ca..f00fe21c20 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/LocationHelper.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/LocationHelper.java
@@ -10,11 +10,11 @@ import android.os.Build;
import info.nightscout.androidaps.R;
-
/**
* Helper for checking if location services are enabled on the device.
*/
public class LocationHelper {
+
/**
* Determine if GPS is currently enabled.
*
@@ -24,10 +24,11 @@ public class LocationHelper {
* @return true if location is enabled, false otherwise.
*/
public static boolean isLocationEnabled(Context context) {
- LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
+ LocationManager locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
+
/**
* Prompt the user to enable GPS location if it isn't already on.
*
@@ -44,6 +45,7 @@ public class LocationHelper {
builder.setTitle(R.string.location_not_found_title);
builder.setMessage(R.string.location_not_found_message);
builder.setPositiveButton(R.string.location_yes, new DialogInterface.OnClickListener() {
+
public void onClick(DialogInterface dialogInterface, int i) {
parent.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
@@ -52,6 +54,7 @@ public class LocationHelper {
builder.create().show();
}
+
/**
* Prompt the user to enable GPS location on devices that need it for Bluetooth discovery.
*
@@ -66,8 +69,9 @@ public class LocationHelper {
}
}
- //public static Boolean locationPermission(ActivityWithMenu act) {
- // return ActivityCompat.checkSelfPermission(act, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
- //}
+ // public static Boolean locationPermission(ActivityWithMenu act) {
+ // return ActivityCompat.checkSelfPermission(act, Manifest.permission.ACCESS_FINE_LOCATION) ==
+ // PackageManager.PERMISSION_GRANTED;
+ // }
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java
index a18ff6f7bf..529b8bf1bd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java
@@ -11,13 +11,12 @@ import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
public class PumpUtil {
- public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType)
- {
+ public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType) {
setPumpDescription(pumpDescription, pumpType, false);
}
- public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType, boolean isVirtualPump)
- {
+
+ public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType, boolean isVirtualPump) {
PumpCapability pumpCapability = isVirtualPump ? PumpCapability.VirtualPump : pumpType.getPumpCapability();
pumpDescription.isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus);
@@ -30,14 +29,11 @@ public class PumpUtil {
pumpDescription.isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TBR);
- if (pumpType.getPumpTempBasalType()==PumpTempBasalType.Percent)
- {
+ if (pumpType.getPumpTempBasalType() == PumpTempBasalType.Percent) {
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
pumpDescription.maxTempPercent = pumpType.getTbrSettings().getMaxDose().intValue();
pumpDescription.tempPercentStep = (int)pumpType.getTbrSettings().getStep();
- }
- else
- {
+ } else {
pumpDescription.tempBasalStyle = PumpDescription.ABSOLUTE;
pumpDescription.maxTempAbsolute = pumpType.getTbrSettings().getMaxDose();
pumpDescription.tempAbsoluteStep = pumpType.getTbrSettings().getStep();
@@ -46,7 +42,6 @@ public class PumpUtil {
pumpDescription.tempDurationStep = pumpType.getTbrSettings().getDurationStep();
pumpDescription.tempMaxDuration = pumpType.getTbrSettings().getMaxDuration();
-
pumpDescription.isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet);
pumpDescription.basalStep = pumpType.getBaseBasalStep();
pumpDescription.basalMinimumRate = pumpType.getBaseBasalMinValue();
@@ -55,5 +50,4 @@ public class PumpUtil {
pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/StringUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/StringUtil.java
index c2e494e978..28a4b8b32b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/StringUtil.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/StringUtil.java
@@ -1,18 +1,18 @@
package info.nightscout.androidaps.plugins.PumpCommon.utils;
-import org.joda.time.LocalDateTime;
-
import java.nio.charset.Charset;
import java.text.DecimalFormat;
import java.util.ArrayList;
+import org.joda.time.LocalDateTime;
+
/**
* Created by geoff on 4/28/15.
*/
public class StringUtil {
-
- public static DecimalFormat DecimalFormaters[] = {new DecimalFormat("#0"), new DecimalFormat("#0.0"), new DecimalFormat("#0.00"), new DecimalFormat("#0.000")};
+ public static DecimalFormat DecimalFormaters[] = {
+ new DecimalFormat("#0"), new DecimalFormat("#0.0"), new DecimalFormat("#0.00"), new DecimalFormat("#0.000") };
public static String fromBytes(byte[] ra) {
@@ -25,7 +25,7 @@ public class StringUtil {
int sz = ra.size();
String rval = "";
int n;
- for(n = 0; n < sz; n++) {
+ for (n = 0; n < sz; n++) {
rval = rval + ra.get(n);
if (n < sz - 1) {
rval = rval + joiner;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ThreadUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ThreadUtil.java
index 565c029a4e..d8894b4bdd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ThreadUtil.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/ThreadUtil.java
@@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.PumpCommon.utils;
* Created by geoff on 5/27/16.
*/
public class ThreadUtil {
+
public static long getThreadId() {
return Thread.currentThread().getId();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicFragment.java
index 9094ec30e8..41ea15768f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicFragment.java
@@ -1,5 +1,9 @@
package info.nightscout.androidaps.plugins.PumpMedtronic;
+import java.util.Date;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import android.annotation.SuppressLint;
import android.app.Activity;
@@ -15,18 +19,14 @@ import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
import com.crashlytics.android.Crashlytics;
import com.joanzapata.iconify.widget.IconTextView;
import com.squareup.otto.Subscribe;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Date;
-
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
@@ -34,11 +34,11 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.plugins.PumpCommon.dialog.RileylinkSettingsActivity;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkServiceState;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.defs.RileyLinkTargetDevice;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.dialog.RileyLinkStatusActivity;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpStatus;
@@ -53,10 +53,40 @@ import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SetWarnColor;
public class MedtronicFragment extends SubscriberFragment {
- private static Logger LOG = LoggerFactory.getLogger(MedtronicFragment.class);
+ private static Logger LOG = LoggerFactory.getLogger(MedtronicFragment.class);
+ @BindView(R.id.medtronic_lastconnection)
+ TextView lastConnectionView;
+ @BindView(R.id.medtronic_lastbolus)
+ TextView lastBolusView;
+ @BindView(R.id.medtronic_basabasalrate)
+ TextView basaBasalRateView;
+
+ // @BindView(R.id.medtronic_btconnection)
+ // TextView btConnectionView;
+ @BindView(R.id.medtronic_tempbasal)
+ TextView tempBasalView;
+ @BindView(R.id.medtronic_pumpstate_battery)
+ TextView batteryView;
+ @BindView(R.id.medtronic_rl_status)
+ IconTextView rileyLinkStatus;
+ @BindView(R.id.medtronic_reservoir)
+ TextView reservoirView;
+ @BindView(R.id.medtronic_errors)
+ TextView errorsView;
+ @BindView(R.id.medtronic_queue)
+ TextView queueView;
+ @BindView(R.id.overview_pumpstatuslayout)
+ LinearLayout pumpStatusLayout;
+ @BindView(R.id.overview_pump_medtronic)
+ TextView overviewPumpMedtronicView;
+ @BindView(R.id.medtronic_pump_status)
+ IconTextView pumpStatusIconView;
+ @BindView(R.id.medtronic_refresh)
+ Button refreshButton;
private Handler loopHandler = new Handler();
private Runnable refreshLoop = new Runnable() {
+
@Override
public void run() {
updateGUI();
@@ -64,53 +94,11 @@ public class MedtronicFragment extends SubscriberFragment {
}
};
- @BindView(R.id.medtronic_lastconnection)
- TextView lastConnectionView;
-
- //@BindView(R.id.medtronic_btconnection)
- //TextView btConnectionView;
-
- @BindView(R.id.medtronic_lastbolus)
- TextView lastBolusView;
-
- @BindView(R.id.medtronic_basabasalrate)
- TextView basaBasalRateView;
-
- @BindView(R.id.medtronic_tempbasal)
- TextView tempBasalView;
-
- @BindView(R.id.medtronic_pumpstate_battery)
- TextView batteryView;
-
- @BindView(R.id.medtronic_rl_status)
- IconTextView rileyLinkStatus;
-
- @BindView(R.id.medtronic_reservoir)
- TextView reservoirView;
-
- @BindView(R.id.medtronic_errors)
- TextView errorsView;
-
-
- @BindView(R.id.medtronic_queue)
- TextView queueView;
-
- @BindView(R.id.overview_pumpstatuslayout)
- LinearLayout pumpStatusLayout;
-
- @BindView(R.id.overview_pump_medtronic)
- TextView overviewPumpMedtronicView;
-
- @BindView(R.id.medtronic_pump_status)
- IconTextView pumpStatusIconView;
-
- @BindView(R.id.medtronic_refresh)
- Button refreshButton;
-
public MedtronicFragment() {
}
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -124,9 +112,9 @@ public class MedtronicFragment extends SubscriberFragment {
loopHandler.removeCallbacks(refreshLoop);
}
+
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.medtronic_fragment, container, false);
unbinder = ButterKnife.bind(this, view);
@@ -148,17 +136,20 @@ public class MedtronicFragment extends SubscriberFragment {
return null;
}
+
@OnClick(R.id.medtronic_history)
void onHistoryClick() {
- //startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
+ // startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
}
+
@OnClick(R.id.medtronic_refresh)
void onRefreshClick() {
refreshButton.setEnabled(false);
MedtronicPumpPlugin.getPlugin().resetStatusState();
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked refresh", new Callback() {
+
@Override
public void run() {
refreshButton.setEnabled(true);
@@ -166,9 +157,10 @@ public class MedtronicFragment extends SubscriberFragment {
});
}
+
@OnClick(R.id.medtronic_stats)
void onStatsClick() {
- startActivity(new Intent(getContext(), RileylinkSettingsActivity.class));
+ startActivity(new Intent(getContext(), RileyLinkStatusActivity.class));
}
@@ -182,18 +174,17 @@ public class MedtronicFragment extends SubscriberFragment {
public void onStatusEvent(final EventMedtronicDeviceStatusChange eventStatusChange) {
LOG.info("onStatusEvent(EventMedtronicDeviceStatusChange): {}", eventStatusChange);
Activity activity = getActivity();
- //final String status = c.textStatus();
+ // final String status = c.textStatus();
if (activity != null) {
- activity.runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
+ activity.runOnUiThread(new Runnable() {
- MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
- setDeviceStatus(pumpStatus);
- }
- }
- );
+ @Override
+ public void run() {
+
+ MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
+ setDeviceStatus(pumpStatus);
+ }
+ });
}
}
@@ -201,7 +192,8 @@ public class MedtronicFragment extends SubscriberFragment {
private void setDeviceStatus(MedtronicPumpStatus pumpStatus) {
- pumpStatus.rileyLinkServiceState = (RileyLinkServiceState) checkStatusSet(pumpStatus.rileyLinkServiceState, RileyLinkUtil.getServiceState());
+ pumpStatus.rileyLinkServiceState = (RileyLinkServiceState)checkStatusSet(pumpStatus.rileyLinkServiceState,
+ RileyLinkUtil.getServiceState());
if (pumpStatus.rileyLinkServiceState != null) {
@@ -222,7 +214,7 @@ public class MedtronicFragment extends SubscriberFragment {
}
}
- pumpStatus.rileyLinkError = (RileyLinkError) checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
+ pumpStatus.rileyLinkError = (RileyLinkError)checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
if (pumpStatus.rileyLinkError != null) {
int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice());
@@ -230,11 +222,11 @@ public class MedtronicFragment extends SubscriberFragment {
} else
errorsView.setText("-");
-
- pumpStatus.pumpDeviceState = (PumpDeviceState) checkStatusSet(pumpStatus.pumpDeviceState, MedtronicUtil.getPumpDeviceState());
+ pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState,
+ MedtronicUtil.getPumpDeviceState());
if (pumpStatus.pumpDeviceState != null) {
- // TODO Pump State
+ // TODO Pump State
switch (pumpStatus.pumpDeviceState) {
case Sleeping:
@@ -260,17 +252,17 @@ public class MedtronicFragment extends SubscriberFragment {
pumpStatusIconView.setText(" " + cmd.name());
}
- break;
+ break;
-// // FIXME
-//
-// pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
-// break;
-//
-// // FIXME
-//
-// pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
-// break;
+ // // FIXME
+ //
+ // pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
+ // break;
+ //
+ // // FIXME
+ //
+ // pumpStatusIconView.setText(" " + pumpStatus.pumpDeviceState.name());
+ // break;
default:
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
}
@@ -278,7 +270,6 @@ public class MedtronicFragment extends SubscriberFragment {
pumpStatusIconView.setText("{fa-bed} ");
}
-
if (queueView != null) {
Spanned status = ConfigBuilderPlugin.getCommandQueue().spannedStatus();
if (status.toString().equals("")) {
@@ -289,7 +280,6 @@ public class MedtronicFragment extends SubscriberFragment {
}
}
-
}
@@ -320,32 +310,37 @@ public class MedtronicFragment extends SubscriberFragment {
updateGUI();
}
+
@Subscribe
public void onStatusEvent(final EventTempBasalChange s) {
updateGUI();
}
+
@Subscribe
public void onStatusEvent(final EventExtendedBolusChange s) {
updateGUI();
}
+
@Subscribe
public void onStatusEvent(final EventQueueChanged s) {
updateGUI();
}
+
// GUI functions
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null && basaBasalRateView != null)
activity.runOnUiThread(new Runnable() {
+
@SuppressLint("SetTextI18n")
@Override
public void run() {
- MedtronicPumpPlugin plugin = (MedtronicPumpPlugin) MedtronicPumpPlugin.getPlugin();
+ MedtronicPumpPlugin plugin = (MedtronicPumpPlugin)MedtronicPumpPlugin.getPlugin();
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
setDeviceStatus(pumpStatus);
@@ -384,22 +379,23 @@ public class MedtronicFragment extends SubscriberFragment {
lastBolusView.setText("");
}
-
// base basal rate
- basaBasalRateView.setText("(" + (pumpStatus.activeProfileName) + ") " + MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
-
+ basaBasalRateView.setText("(" + (pumpStatus.activeProfileName) + ") "
+ + MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
// FIXME temp basal - check - maybe set as combo ??
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
- tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
+ tempBasalView.setText(TreatmentsPlugin.getPlugin()
+ .getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else {
tempBasalView.setText("");
}
} else {
// v2 plugin
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
- tempBasalView.setText(TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
+ tempBasalView.setText(TreatmentsPlugin.getPlugin()
+ .getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else {
tempBasalView.setText("");
}
@@ -410,7 +406,8 @@ public class MedtronicFragment extends SubscriberFragment {
SetWarnColor.setColorInverse(batteryView, pumpStatus.batteryRemaining, 51d, 26d);
// reservoir
- reservoirView.setText(DecimalFormatter.to0Decimal(pumpStatus.reservoirRemainingUnits) + " / " + pumpStatus.reservoirFullUnits + " " + MainApp.gs(R.string.insulin_unit_shortname));
+ reservoirView.setText(DecimalFormatter.to0Decimal(pumpStatus.reservoirRemainingUnits) + " / "
+ + pumpStatus.reservoirFullUnits + " " + MainApp.gs(R.string.insulin_unit_shortname));
SetWarnColor.setColorInverse(reservoirView, pumpStatus.reservoirRemainingUnits, 50d, 20d);
errorsView.setText(pumpStatus.getErrorInfo());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicPumpPlugin.java
index f7cb1d959e..ab158bb1f2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/MedtronicPumpPlugin.java
@@ -1,18 +1,19 @@
package info.nightscout.androidaps.plugins.PumpMedtronic;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.joda.time.LocalDateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.SystemClock;
import android.support.annotation.NonNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
@@ -30,6 +31,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpCommon.PumpPluginAbstract;
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
+import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.ServiceTaskExecutor;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.WakeAndTuneTask;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.ui.MedtronicUIComm;
@@ -53,10 +55,8 @@ import info.nightscout.utils.SP;
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpPlugin.class);
-
-
- private RileyLinkMedtronicService medtronicService;
protected static MedtronicPumpPlugin plugin = null;
+ private RileyLinkMedtronicService medtronicService;
private MedtronicPumpStatus pumpStatusLocal = null;
private MedtronicUIComm medtronicUIComm = new MedtronicUIComm();
@@ -68,32 +68,24 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private Map statusRefreshMap = new HashMap<>();
- public static MedtronicPumpPlugin getPlugin() {
- if (plugin == null)
- plugin = new MedtronicPumpPlugin();
- return plugin;
- }
-
-
private MedtronicPumpPlugin() {
-// super(new PluginDescription() //
-// .mainType(PluginType.PUMP) //
-// .fragmentClass(MedtronicFragment.class.getName()) //
-// .pluginName(R.string.medtronic_name) //
-// .shortName(R.string.medtronic_name_short) //
-// .preferencesId(R.xml.pref_medtronic));
-
+ // super(new PluginDescription() //
+ // .mainType(PluginType.PUMP) //
+ // .fragmentClass(MedtronicFragment.class.getName()) //
+ // .pluginName(R.string.medtronic_name) //
+ // .shortName(R.string.medtronic_name_short) //
+ // .preferencesId(R.xml.pref_medtronic));
super(new MedtronicPumpDriver(), //
- "MedtronicPump", //
- new PluginDescription() //
- .mainType(PluginType.PUMP) //
- .fragmentClass(MedtronicFragment.class.getName()) //
- .pluginName(R.string.medtronic_name) //
- .shortName(R.string.medtronic_name_short) //
- .preferencesId(R.xml.pref_medtronic), //
- PumpType.Medtronic_512_712 // we default to most basic model, correct model from config is loaded later
+ "MedtronicPump", //
+ new PluginDescription() //
+ .mainType(PluginType.PUMP) //
+ .fragmentClass(MedtronicFragment.class.getName()) //
+ .pluginName(R.string.medtronic_name) //
+ .shortName(R.string.medtronic_name_short) //
+ .preferencesId(R.xml.pref_medtronic), //
+ PumpType.Medtronic_512_712 // we default to most basic model, correct model from config is loaded later
);
serviceConnection = new ServiceConnection() {
@@ -103,9 +95,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
medtronicService = null;
}
+
public void onServiceConnected(ComponentName name, IBinder service) {
LOG.debug("RileyLinkMedtronicService is connected");
- RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder) service;
+ RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder)service;
medtronicService = mLocalBinder.getServiceInstance();
new Thread(() -> {
@@ -126,12 +119,22 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
+ public static MedtronicPumpPlugin getPlugin() {
+ if (plugin == null)
+ plugin = new MedtronicPumpPlugin();
+ return plugin;
+ }
+
+
@Override
public void initPumpStatusData() {
this.pumpStatusLocal = new MedtronicPumpStatus(pumpDescription);
MedtronicUtil.setPumpStatus(pumpStatusLocal);
+ pumpStatusLocal.lastConnection = SP.getLong(RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
+ pumpStatusLocal.lastDataTime = new LocalDateTime(pumpStatusLocal.lastConnection);
+
pumpStatusLocal.refreshConfiguration();
LOG.debug("initPumpStatusData: {}", this.pumpStatusLocal);
@@ -164,6 +167,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
+
public void onStartCustomActions() {
// check status every minute
@@ -178,7 +182,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} while (serviceRunning);
-
}).start();
}
@@ -193,6 +196,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return "Medtronic";
}
+
@Override
public PumpDescription getPumpDescription() {
return this.pumpDescription;
@@ -216,6 +220,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return isServiceSet() && medtronicService.isInitialized();
}
+
// FIXME
public boolean isSuspended() {
return isServiceSet() && medtronicService.isSuspended();
@@ -246,7 +251,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
getMDTPumpStatus();
-
if (firstRun) {
initializePump(true);
} else {
@@ -261,6 +265,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
firstRun = true;
}
+
private void refreshAnyStatusThatNeedsToBeRefreshed() {
if (!doWeHaveAnyStatusNeededRefereshing()) {
@@ -277,7 +282,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
case PumpHistory: {
readPumpHistory();
}
- break;
+ break;
case PumpTime:
case BatteryStatus:
@@ -287,7 +292,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
scheduleNextRefresh(refreshType.getKey());
resetTime = true;
}
- break;
+ break;
}
}
}
@@ -310,6 +315,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return false;
}
+
private void initializePump(boolean realInit) {
LOG.error("initializePump - start");
@@ -322,7 +328,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} else {
if (pumpStatusLocal.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
LOG.warn("Configured pump is not the same as one detected.");
- Notification notification = new Notification(Notification.MEDTRONIC_PUMP_ALARM, MainApp.gs(R.string.medtronic_error_pump_type_set_differs_from_detected), Notification.NORMAL);
+ Notification notification = new Notification(Notification.MEDTRONIC_PUMP_ALARM,
+ MainApp.gs(R.string.medtronic_error_pump_type_set_differs_from_detected), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
}
@@ -331,7 +338,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// pump history handling - special, updates every 5 minutes ???
readPumpHistory();
-
// TODO rewrite reading of data to be done in background or different thread perhaps ??
// remaining insulin (>50 = 4h; 50-20 = 1h; 15m)
@@ -352,7 +358,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// read profile (once, later its controlled by isThisProfileSet method)
medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD);
-
// TODO handle if tunning was needed (more than 5 timeouts)
int errorCount = medtronicUIComm.getInvalidResponsesCount();
@@ -406,7 +411,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
index++;
}
-
if (!invalid) {
LOG.debug("Basal profile is same as AAPS one.");
} else {
@@ -427,12 +431,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
public Date lastDataTime() {
if (pumpStatusLocal != null && pumpStatusLocal.lastDataTime != null) {
- return pumpStatusLocal.lastDataTime;
+ return pumpStatusLocal.lastDataTime.toDate();
}
return new Date();
}
+
@Override
public double getBaseBasalRate() {
return getMDTPumpStatus().getBasalProfileForHour();
@@ -462,9 +467,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.error("MedtronicPumpPlugin::deliverBolus Not fully implemented - Just base command.");
// TODO should wait and display bolus delivery
- MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus, detailedBolusInfo.insulin);
+ MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
+ detailedBolusInfo.insulin);
- Boolean response = (Boolean) responseTask.returnData;
+ Boolean response = (Boolean)responseTask.returnData;
// TODO display bolus
@@ -472,128 +478,133 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// FIXME this needs to be fixed to read info from history
boolean treatmentCreated = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
- getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin; // we subtract insulin, exact amount will be visible with next remainingInsulin update.
+ getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin; // we subtract insulin, exact
+ // amount will be visible with
+ // next remainingInsulin
+ // update.
- incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses : MedtronicConst.Statistics.StandardBoluses);
+ incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
+ : MedtronicConst.Statistics.StandardBoluses);
}
readPumpHistory();
-
return new PumpEnactResult().success(response).enacted(response);
-
-// pump.activity = MainApp.gs(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
-// MainApp.bus().post(new EventComboPumpUpdateGUI());
-//
-// // check pump is ready and all pump bolus records are known
-// CommandResult stateResult = runCommand(null, 2, () -> ruffyScripter.readQuickInfo(1));
-// if (!stateResult.success) {
-// return new PumpEnactResult().success(false).enacted(false)
-// .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
-// }
-// if (stateResult.reservoirLevel != -1 && stateResult.reservoirLevel - 0.5 < detailedBolusInfo.insulin) {
-// return new PumpEnactResult().success(false).enacted(false)
-// .comment(MainApp.gs(R.string.combo_reservoir_level_insufficient_for_bolus));
-// }
-// // the commands above ensured a connection was made, which updated this field
-// if (pumpHistoryChanged) {
-// return new PumpEnactResult().success(false).enacted(false)
-// .comment(MainApp.gs(R.string.combo_bolus_rejected_due_to_pump_history_change));
-// }
-//
-// Bolus previousBolus = stateResult.history != null && !stateResult.history.bolusHistory.isEmpty()
-// ? stateResult.history.bolusHistory.get(0)
-// : new Bolus(0, 0, false);
-//
-// // reject a bolus if one with the exact same size was successfully delivered
-// // within the last 1-2 minutes
-// if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
-// && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
-// log.debug("Bolu request rejected, same bolus was successfully delivered very recently");
-// return new PumpEnactResult().success(false).enacted(false)
-// .comment(MainApp.gs(R.string.bolus_frequency_exceeded));
-// }
-//
-//
-//
-// if (cancelBolus) {
-// return new PumpEnactResult().success(true).enacted(false);
-// }
-//
-// BolusProgressReporter progressReporter = detailedBolusInfo.isSMB ? nullBolusProgressReporter : bolusProgressReporter;
-//
-// // start bolus delivery
-// scripterIsBolusing = true;
-// runCommand(null, 0,
-// () -> ruffyScripter.deliverBolus(detailedBolusInfo.insulin, progressReporter));
-// scripterIsBolusing = false;
-//
-// // Note that the result of the issued bolus command is not checked. If there was
-// // a connection problem, ruffyscripter tried to recover and we can just check the
-// // history below to see what was actually delivered
-//
-// // get last bolus from pump history for verification
-// // (reads 2 records to update `recentBoluses` further down)
-// CommandResult postBolusStateResult = runCommand(null, 3, () -> ruffyScripter.readQuickInfo(2));
-// if (!postBolusStateResult.success) {
-// return new PumpEnactResult().success(false).enacted(false)
-// .comment(MainApp.gs(R.string.combo_error_bolus_verification_failed));
-// }
-// Bolus lastPumpBolus = postBolusStateResult.history != null && !postBolusStateResult.history.bolusHistory.isEmpty()
-// ? postBolusStateResult.history.bolusHistory.get(0)
-// : null;
-//
-// // no bolus delivered?
-// if (lastPumpBolus == null || lastPumpBolus.equals(previousBolus)) {
-// if (cancelBolus) {
-// return new PumpEnactResult().success(true).enacted(false);
-// } else {
-// return new PumpEnactResult()
-// .success(false)
-// .enacted(false)
-// .comment(MainApp.gs(R.string.combo_error_no_bolus_delivered));
-// }
-// }
-//
-// // at least some insulin delivered, so add it to treatments
-// if (!addBolusToTreatments(detailedBolusInfo, lastPumpBolus))
-// return new PumpEnactResult().success(false).enacted(true)
-// .comment(MainApp.gs(R.string.combo_error_updating_treatment_record));
-//
-// // check pump bolus record has a sane timestamp
-// long now = System.currentTimeMillis();
-// if (lastPumpBolus.timestamp < now - 10 * 60 * 1000 || lastPumpBolus.timestamp > now + 10 * 60 * 1000) {
-// Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_suspious_bolus_time), Notification.URGENT);
-// MainApp.bus().post(new EventNewNotification(notification));
-// }
-//
-// // update `recentBoluses` so the bolus was just delivered won't be detected as a new
-// // bolus that has been delivered on the pump
-// recentBoluses = postBolusStateResult.history.bolusHistory;
-//
-// // only a partial bolus was delivered
-// if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) {
-// if (cancelBolus) {
-// return new PumpEnactResult().success(true).enacted(true);
-// }
-// return new PumpEnactResult().success(false).enacted(true)
-// .comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered,
-// lastPumpBolus.amount, detailedBolusInfo.insulin));
-// }
-//
-// // full bolus was delivered successfully
-// incrementBolusCount();
-// return new PumpEnactResult()
-// .success(true)
-// .enacted(lastPumpBolus.amount > 0)
-// .bolusDelivered(lastPumpBolus.amount)
-// .carbsDelivered(detailedBolusInfo.carbs);
+ // pump.activity = MainApp.gs(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
+ // MainApp.bus().post(new EventComboPumpUpdateGUI());
+ //
+ // // check pump is ready and all pump bolus records are known
+ // CommandResult stateResult = runCommand(null, 2, () -> ruffyScripter.readQuickInfo(1));
+ // if (!stateResult.success) {
+ // return new PumpEnactResult().success(false).enacted(false)
+ // .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
+ // }
+ // if (stateResult.reservoirLevel != -1 && stateResult.reservoirLevel - 0.5 < detailedBolusInfo.insulin) {
+ // return new PumpEnactResult().success(false).enacted(false)
+ // .comment(MainApp.gs(R.string.combo_reservoir_level_insufficient_for_bolus));
+ // }
+ // // the commands above ensured a connection was made, which updated this field
+ // if (pumpHistoryChanged) {
+ // return new PumpEnactResult().success(false).enacted(false)
+ // .comment(MainApp.gs(R.string.combo_bolus_rejected_due_to_pump_history_change));
+ // }
+ //
+ // Bolus previousBolus = stateResult.history != null && !stateResult.history.bolusHistory.isEmpty()
+ // ? stateResult.history.bolusHistory.get(0)
+ // : new Bolus(0, 0, false);
+ //
+ // // reject a bolus if one with the exact same size was successfully delivered
+ // // within the last 1-2 minutes
+ // if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
+ // && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
+ // log.debug("Bolu request rejected, same bolus was successfully delivered very recently");
+ // return new PumpEnactResult().success(false).enacted(false)
+ // .comment(MainApp.gs(R.string.bolus_frequency_exceeded));
+ // }
+ //
+ //
+ //
+ // if (cancelBolus) {
+ // return new PumpEnactResult().success(true).enacted(false);
+ // }
+ //
+ // BolusProgressReporter progressReporter = detailedBolusInfo.isSMB ? nullBolusProgressReporter :
+ // bolusProgressReporter;
+ //
+ // // start bolus delivery
+ // scripterIsBolusing = true;
+ // runCommand(null, 0,
+ // () -> ruffyScripter.deliverBolus(detailedBolusInfo.insulin, progressReporter));
+ // scripterIsBolusing = false;
+ //
+ // // Note that the result of the issued bolus command is not checked. If there was
+ // // a connection problem, ruffyscripter tried to recover and we can just check the
+ // // history below to see what was actually delivered
+ //
+ // // get last bolus from pump history for verification
+ // // (reads 2 records to update `recentBoluses` further down)
+ // CommandResult postBolusStateResult = runCommand(null, 3, () -> ruffyScripter.readQuickInfo(2));
+ // if (!postBolusStateResult.success) {
+ // return new PumpEnactResult().success(false).enacted(false)
+ // .comment(MainApp.gs(R.string.combo_error_bolus_verification_failed));
+ // }
+ // Bolus lastPumpBolus = postBolusStateResult.history != null &&
+ // !postBolusStateResult.history.bolusHistory.isEmpty()
+ // ? postBolusStateResult.history.bolusHistory.get(0)
+ // : null;
+ //
+ // // no bolus delivered?
+ // if (lastPumpBolus == null || lastPumpBolus.equals(previousBolus)) {
+ // if (cancelBolus) {
+ // return new PumpEnactResult().success(true).enacted(false);
+ // } else {
+ // return new PumpEnactResult()
+ // .success(false)
+ // .enacted(false)
+ // .comment(MainApp.gs(R.string.combo_error_no_bolus_delivered));
+ // }
+ // }
+ //
+ // // at least some insulin delivered, so add it to treatments
+ // if (!addBolusToTreatments(detailedBolusInfo, lastPumpBolus))
+ // return new PumpEnactResult().success(false).enacted(true)
+ // .comment(MainApp.gs(R.string.combo_error_updating_treatment_record));
+ //
+ // // check pump bolus record has a sane timestamp
+ // long now = System.currentTimeMillis();
+ // if (lastPumpBolus.timestamp < now - 10 * 60 * 1000 || lastPumpBolus.timestamp > now + 10 * 60 * 1000) {
+ // Notification notification = new Notification(Notification.COMBO_PUMP_ALARM,
+ // MainApp.gs(R.string.combo_suspious_bolus_time), Notification.URGENT);
+ // MainApp.bus().post(new EventNewNotification(notification));
+ // }
+ //
+ // // update `recentBoluses` so the bolus was just delivered won't be detected as a new
+ // // bolus that has been delivered on the pump
+ // recentBoluses = postBolusStateResult.history.bolusHistory;
+ //
+ // // only a partial bolus was delivered
+ // if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) {
+ // if (cancelBolus) {
+ // return new PumpEnactResult().success(true).enacted(true);
+ // }
+ // return new PumpEnactResult().success(false).enacted(true)
+ // .comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered,
+ // lastPumpBolus.amount, detailedBolusInfo.insulin));
+ // }
+ //
+ // // full bolus was delivered successfully
+ // incrementBolusCount();
+ // return new PumpEnactResult()
+ // .success(true)
+ // .enacted(lastPumpBolus.amount > 0)
+ // .bolusDelivered(lastPumpBolus.amount)
+ // .carbsDelivered(detailedBolusInfo.carbs);
} finally {
-// pump.activity = null;
-// MainApp.bus().post(new EventComboPumpUpdateGUI());
+ // pump.activity = null;
+ // MainApp.bus().post(new EventComboPumpUpdateGUI());
MainApp.bus().post(new EventRefreshOverview("Bolus"));
-// cancelBolus = false;
+ // cancelBolus = false;
triggerUIChange();
}
}
@@ -609,7 +620,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged),
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
+ boolean enforceNew) {
LOG.error("MedtronicPumpPlugin::setTempBasalAbsolute Not fully implemented - Just base command.");
@@ -625,7 +637,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// TODO translate
return new PumpEnactResult().success(false).enacted(false).comment("Couldn't read current TBR.");
} else {
- LOG.info("MedtronicPumpPlugin::setTempBasalAbsolute: Current Basal: duration: {} min, rate={}", tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
+ LOG.info("MedtronicPumpPlugin::setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
+ tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
}
// FIXME doesn't work correctly. Read current TBR first
@@ -647,7 +660,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// if not the same rate, we cancel and start new
}
-
// if TBR is running we will cancel it.
if (tbrCurrent.getInsulinRate() != 0.0f && tbrCurrent.getDurationMinutes() > 0) {
LOG.info("MedtronicPumpPlugin::setTempBasalAbsolute - TBR running - so canceling it.");
@@ -656,21 +668,22 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
- Boolean response = (Boolean) responseTask2.returnData;
+ Boolean response = (Boolean)responseTask2.returnData;
if (response) {
LOG.info("MedtronicPumpPlugin::setTempBasalAbsolute - Current TBR cancelled.");
} else {
LOG.error("MedtronicPumpPlugin::setTempBasalAbsolute - Cancel TBR failed.");
- return new PumpEnactResult().success(false).enacted(false).comment("Couldn't cancel current TBR. Stopping operation. ");
+ return new PumpEnactResult().success(false).enacted(false)
+ .comment("Couldn't cancel current TBR. Stopping operation. ");
}
}
-
// now start new TBR
- MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal, absoluteRate, durationInMinutes);
+ MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal,
+ absoluteRate, durationInMinutes);
- Boolean response = (Boolean) responseTask.returnData;
+ Boolean response = (Boolean)responseTask.returnData;
LOG.info("MedtronicPumpPlugin::setTempBasalAbsolute - setTBR. Response: " + response);
@@ -681,11 +694,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
pumpStatusLocal.tempBasalLength = durationInMinutes;
// FIXME should be read from history
- TemporaryBasal tempStart = new TemporaryBasal()
- .date(System.currentTimeMillis())
- .duration(durationInMinutes)
- .absolute(absoluteRate)
- .source(Source.USER);
+ TemporaryBasal tempStart = new TemporaryBasal().date(System.currentTimeMillis())
+ .duration(durationInMinutes).absolute(absoluteRate).source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
incrementStatistics(MedtronicConst.Statistics.TBRsSet);
@@ -740,13 +750,14 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
statusRefreshMap.put(refreshType, getTimeInFutureFromMinutes(min));
}
- break;
+ break;
case Configuration:
case PumpHistory: {
- statusRefreshMap.put(refreshType, getTimeInFutureFromMinutes(refreshType.getRefreshTime() + additionalTimeInMinutes));
+ statusRefreshMap.put(refreshType, getTimeInFutureFromMinutes(refreshType.getRefreshTime()
+ + additionalTimeInMinutes));
}
- break;
+ break;
}
}
@@ -774,7 +785,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal);
if (responseTask.hasData()) {
- TempBasalPair tbr = (TempBasalPair) responseTask.returnData;
+ TempBasalPair tbr = (TempBasalPair)responseTask.returnData;
// we sometimes get rate returned even if TBR is no longer running
if (tbr.getDurationMinutes() == 0) {
@@ -787,6 +798,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
}
+
// TODO
@Override
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
@@ -807,7 +819,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
- Boolean response = (Boolean) responseTask2.returnData;
+ Boolean response = (Boolean)responseTask2.returnData;
if (response) {
LOG.info("MedtronicPumpPlugin::cancelTempBasal - Cancel TBR successful.");
@@ -826,7 +838,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
public PumpEnactResult setNewBasalProfile(Profile profile) {
LOG.warn("MedtronicPumpPlugin::setNewBasalProfile NOT IMPLEMENTED YET.");
- return new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.medtronic_cmd_profile_not_set));
+ return new PumpEnactResult().success(false).enacted(false)
+ .comment(MainApp.gs(R.string.medtronic_cmd_profile_not_set));
}
@@ -841,7 +854,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
- public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
+ public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile,
+ boolean enforceNew) {
LOG.error("setTempBasalPercent NOT IMPLEMENTED.");
// we will never come here unless somebody has played with configuration in PumpType
return OPERATION_NOT_SUPPORTED;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/MedtronicCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/MedtronicCommunicationManager.java
index aaf6d0146e..9fc2474802 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/MedtronicCommunicationManager.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/MedtronicCommunicationManager.java
@@ -1,15 +1,15 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm;
-import android.content.Context;
-import android.os.SystemClock;
+import java.util.ArrayList;
+import java.util.Map;
import org.joda.time.Instant;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Map;
+import android.content.Context;
+import android.os.SystemClock;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RFSpy;
@@ -40,7 +40,6 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.PumpMedtronic.service.RileyLinkMedtronicService;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
-
/**
* Original file created by geoff on 5/30/16.
*
@@ -53,9 +52,9 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private static final int DEFAULT_TIMEOUT = 2000;
static MedtronicCommunicationManager medtronicCommunicationManager;
- private MedtronicConverter medtronicConverter;
-
String errorMessage;
+ private MedtronicConverter medtronicConverter;
+ private boolean debugSetCommands = true;
public MedtronicCommunicationManager(Context context, RFSpy rfspy, RileyLinkTargetFrequency targetFrequency) {
@@ -65,6 +64,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
+ public static MedtronicCommunicationManager getInstance() {
+ return medtronicCommunicationManager;
+ }
+
+
@Override
protected void configurePumpSpecificSettings() {
pumpStatus = MedtronicUtil.getPumpStatus();
@@ -74,7 +78,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
@Override
public E createResponseMessage(byte[] payload, Class clazz) {
PumpMessage pumpMessage = new PumpMessage(payload);
- return (E) pumpMessage;
+ return (E)pumpMessage;
}
@@ -86,7 +90,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
MedtronicDeviceType pumpModel = getPumpModel();
- // Andy (4.6.2018): we do retry if no data returned. We might need to do that everywhere, but that might require little bit of rewrite of RF Code.
+ // Andy (4.6.2018): we do retry if no data returned. We might need to do that everywhere, but that might require
+ // little bit of rewrite of RF Code.
if (pumpModel == MedtronicDeviceType.Unknown_Device) {
SystemClock.sleep(1000);
@@ -94,7 +99,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
pumpModel = getPumpModel();
}
-
boolean connected = (pumpModel != MedtronicDeviceType.Unknown_Device);
if (connected) {
@@ -102,10 +106,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
setLastConnectionTime();
}
-
return (pumpModel != MedtronicDeviceType.Unknown_Device);
}
+
private void setLastConnectionTime() {
// FIXME rename
@@ -113,29 +117,21 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// FIXME set to SP
-
}
+
private void checkFirstConnectionTime() {
// FIXME set to SP
}
- public static MedtronicCommunicationManager getInstance() {
- return medtronicCommunicationManager;
- }
-
-
- private boolean debugSetCommands = true;
-
-
// FIXME remove debugs - Andy
private PumpMessage runCommandWithArgs(PumpMessage msg) {
if (debugSetCommands)
LOG.debug("Run command with Args: ");
PumpMessage rval;
- PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[]{0}));
+ PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[] { 0 }));
// look for ack from short message
PumpMessage shortResponse = sendAndListen(shortMessage);
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
@@ -157,7 +153,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
LOG.debug("Run command with Args (Long): {}", commandType.name());
PumpMessage rval = null;
- PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0}));
+ PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[] { 0 }));
// look for ack from short message
PumpMessage shortResponse = sendAndListen(shortMessage);
@@ -167,7 +163,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return new PumpMessage("No ACK after start message.");
}
-
int start = 0;
int frameNr = 1;
int len = 0;
@@ -190,7 +185,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
byte frame[] = new byte[65];
- frame[0] = (byte) frameNr;
+ frame[0] = (byte)frameNr;
System.arraycopy(content, start, frame, 1, len);
@@ -214,11 +209,9 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} while (true);
-
return rval;
-
- //return new PumpMessage("No ACK");
+ // return new PumpMessage("No ACK");
}
@@ -226,17 +219,19 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
public Page getPumpHistoryPage(int pageNumber) {
RawHistoryPage rval = new RawHistoryPage();
wakeUp(receiverDeviceAwakeForMinutes, false);
- PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData, new GetHistoryPageCarelinkMessageBody(pageNumber));
- //LOG.info("getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData()));
+ PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
+ new GetHistoryPageCarelinkMessageBody(pageNumber));
+ // LOG.info("getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData()));
// Ask the pump to transfer history (we get first frame?)
PumpMessage firstResponse = runCommandWithArgs(getHistoryMsg);
- //LOG.info("getPumpHistoryPage("+pageNumber+"): " + ByteUtil.shortHexString(firstResponse.getContents()));
+ // LOG.info("getPumpHistoryPage("+pageNumber+"): " + ByteUtil.shortHexString(firstResponse.getContents()));
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
- GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse.getMessageBody().getTxData());
+ GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
+ .getMessageBody().getTxData());
int expectedFrameNum = 1;
boolean done = false;
- //while (expectedFrameNum == currentResponse.getFrameNumber()) {
+ // while (expectedFrameNum == currentResponse.getFrameNumber()) {
int failures = 0;
while (!done) {
// examine current response for problems.
@@ -249,7 +244,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
// handle successful frame data
rval.appendData(currentResponse.getFrameData());
- RileyLinkMedtronicService.getInstance().announceProgress(((100 / 16) * currentResponse.getFrameNumber() + 1));
+ RileyLinkMedtronicService.getInstance().announceProgress(
+ ((100 / 16) * currentResponse.getFrameNumber() + 1));
LOG.info("getPumpHistoryPage: Got frame " + currentResponse.getFrameNumber());
// Do we need to ask for the next frame?
if (expectedFrameNum < 16) { // This number may not be correct for pumps other than 522/722
@@ -261,13 +257,15 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (frameData == null) {
LOG.error("null frame data, retrying");
} else if (currentResponse.getFrameNumber() != expectedFrameNum) {
- LOG.warn("Expected frame number {}, received {} (retrying)", expectedFrameNum, currentResponse.getFrameNumber());
+ LOG.warn("Expected frame number {}, received {} (retrying)", expectedFrameNum,
+ currentResponse.getFrameNumber());
} else if (frameData.length == 0) {
LOG.warn("Frame has zero length, retrying");
}
failures++;
if (failures == 6) {
- LOG.error("6 failures in attempting to download frame {} of page {}, giving up.", expectedFrameNum, pageNumber);
+ LOG.error("6 failures in attempting to download frame {} of page {}, giving up.", expectedFrameNum,
+ pageNumber);
done = true; // failure completion.
}
}
@@ -287,7 +285,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
rval.dumpToDebug();
Page page = new Page();
- //page.parseFrom(rval.getData(),PumpModel.MM522);
+ // page.parseFrom(rval.getData(),PumpModel.MM522);
// FIXME
page.parseFrom(rval.getData(), MedtronicDeviceType.Medtronic_522);
@@ -329,7 +327,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// See ButtonPressCarelinkMessageBody
public void pressButton(int which) {
wakeUp(receiverDeviceAwakeForMinutes, false);
- PumpMessage pressButtonMessage = makePumpMessage(MedtronicCommandType.PushButton, new ButtonPressCarelinkMessageBody(which));
+ PumpMessage pressButtonMessage = makePumpMessage(MedtronicCommandType.PushButton,
+ new ButtonPressCarelinkMessageBody(which));
PumpMessage resp = sendAndListen(pressButtonMessage);
if (resp.commandType != MedtronicCommandType.CommandACK) {
LOG.error("Pump did not ack button press.");
@@ -338,32 +337,30 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// FIXME
- //@Override
- // public RLMessage makeRLMessage(RLMessageType type, byte[] data) {
- // switch (type) {
- // case PowerOn:
- // return makePumpMessage(MedtronicCommandType.RFPowerOn, new CarelinkShortMessageBody(data));
+ // @Override
+ // public RLMessage makeRLMessage(RLMessageType type, byte[] data) {
+ // switch (type) {
+ // case PowerOn:
+ // return makePumpMessage(MedtronicCommandType.RFPowerOn, new CarelinkShortMessageBody(data));
//
- // case ReadSimpleData:
- // return makePumpMessage(MedtronicCommandType.PumpModel, new GetPumpModelCarelinkMessageBody());
+ // case ReadSimpleData:
+ // return makePumpMessage(MedtronicCommandType.PumpModel, new GetPumpModelCarelinkMessageBody());
//
- // }
- // return null;
- // }
-
-
- // @Override
- // public RLMessage makeRLMessage(byte[] data) {
- // return makePumpMessage(data);
- // }
+ // }
+ // return null;
+ // }
+ // @Override
+ // public RLMessage makeRLMessage(byte[] data) {
+ // return makePumpMessage(data);
+ // }
@Override
public byte[] createPumpMessageContent(RLMessageType type) {
switch (type) {
case PowerOn:
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.RFPowerOn, //
- new byte[]{2, 1, (byte) receiverDeviceAwakeForMinutes}); // maybe this is better FIXME
+ new byte[] { 2, 1, (byte)receiverDeviceAwakeForMinutes }); // maybe this is better FIXME
case ReadSimpleData:
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.PumpModel, null);
@@ -373,12 +370,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
protected PumpMessage makePumpMessage(MedtronicCommandType messageType, byte[] body) {
- return makePumpMessage(messageType, body == null ? new CarelinkShortMessageBody() : new CarelinkShortMessageBody(body));
+ return makePumpMessage(messageType, body == null ? new CarelinkShortMessageBody()
+ : new CarelinkShortMessageBody(body));
}
protected PumpMessage makePumpMessage(MedtronicCommandType messageType) {
- return makePumpMessage(messageType, (byte[]) null);
+ return makePumpMessage(messageType, (byte[])null);
}
@@ -389,12 +387,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
- // protected PumpMessage makePumpMessage(byte[] typeAndBody) {
- // PumpMessage msg = new PumpMessage();
- // msg.init(ByteUtil.concat(ByteUtil.concat(new byte[]{PacketType.Carelink.getValue()}, rileyLinkServiceData.pumpIDBytes), typeAndBody));
- // return msg;
- // }
-
+ // protected PumpMessage makePumpMessage(byte[] typeAndBody) {
+ // PumpMessage msg = new PumpMessage();
+ // msg.init(ByteUtil.concat(ByteUtil.concat(new byte[]{PacketType.Carelink.getValue()},
+ // rileyLinkServiceData.pumpIDBytes), typeAndBody));
+ // return msg;
+ // }
private PumpMessage sendAndGetResponse(MedtronicCommandType commandType) {
@@ -413,6 +411,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return sendAndGetResponse(commandType, bodyData, DEFAULT_TIMEOUT);
}
+
/**
* Main wrapper method for sending data - (for getting responses)
*
@@ -445,23 +444,22 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// FIXME remove
- // private PumpMessage sendAndGetACK(MedtronicCommandType commandType, byte[] bodyData, int timeoutMs) {
- // // wakeUp
- // wakeUp(receiverDeviceAwakeForMinutes, false);
+ // private PumpMessage sendAndGetACK(MedtronicCommandType commandType, byte[] bodyData, int timeoutMs) {
+ // // wakeUp
+ // wakeUp(receiverDeviceAwakeForMinutes, false);
//
- // // create message
- // PumpMessage msg;
+ // // create message
+ // PumpMessage msg;
//
- // if (bodyData == null)
- // msg = makePumpMessage(commandType);
- // else
- // msg = makePumpMessage(commandType, bodyData);
+ // if (bodyData == null)
+ // msg = makePumpMessage(commandType);
+ // else
+ // msg = makePumpMessage(commandType, bodyData);
//
- // // send and wait for ACK
- // PumpMessage response = send(msg, timeoutMs);
- // return response;
- // }
-
+ // // send and wait for ACK
+ // PumpMessage response = send(msg, timeoutMs);
+ // return response;
+ // }
protected PumpMessage sendAndListen(RLMessage msg) {
return sendAndListen(msg, 4000); // 2000
@@ -484,7 +482,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
for (int retries = 0; retries < MAX_COMMAND_RETRIES; retries++) {
- PumpMessage response = sendAndGetResponse(commandType, bodyData, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
+ PumpMessage response = sendAndGetResponse(commandType, bodyData, DEFAULT_TIMEOUT
+ + (DEFAULT_TIMEOUT * retries));
String check = checkResponseContent(response, commandType.commandDescription, commandType.expectedLength);
@@ -497,7 +496,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return dataResponse;
} else {
this.errorMessage = check;
- //return null;
+ // return null;
}
}
@@ -514,7 +513,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return responseData;
}
-
byte[] contents = response.getRawContent();
if (contents != null) {
@@ -523,7 +521,9 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return null;
} else {
- String responseData = String.format("%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, "" + expectedLength, "" + contents.length);
+ String responseData = String.format(
+ "%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
+ + expectedLength, "" + contents.length);
LOG.warn(responseData);
return responseData;
@@ -537,48 +537,46 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// TODO remove not needed - probably
- // @Deprecated
- // private void executeSetCommand(MedtronicCommandType commandType, byte[] bodyData) {
+ // @Deprecated
+ // private void executeSetCommand(MedtronicCommandType commandType, byte[] bodyData) {
//
- // LOG.debug("Executing Set for {} - 1st call", commandType.name());
+ // LOG.debug("Executing Set for {} - 1st call", commandType.name());
//
- // // first we send command without paramters and wait for ACK
- // PumpMessage pumpMessage = sendAndGetACK(commandType, null, 4000);
+ // // first we send command without paramters and wait for ACK
+ // PumpMessage pumpMessage = sendAndGetACK(commandType, null, 4000);
//
- // // FIXME check if ACK
- // LOG.debug("Response 1 - {}", HexDump.toHexStringDisplayable(pumpMessage.getRawContent()));
+ // // FIXME check if ACK
+ // LOG.debug("Response 1 - {}", HexDump.toHexStringDisplayable(pumpMessage.getRawContent()));
//
//
- // LOG.debug("Executing Set for {} - 2nd call", commandType.name());
- // // second we send command with parameters and full package 64 bits with zeroed empty places
+ // LOG.debug("Executing Set for {} - 2nd call", commandType.name());
+ // // second we send command with parameters and full package 64 bits with zeroed empty places
//
- // byte newBodyData[] = new byte[64];
- // for(int i = 0; i < 64; i++) {
- // newBodyData[i] = 0x00;
- // }
+ // byte newBodyData[] = new byte[64];
+ // for(int i = 0; i < 64; i++) {
+ // newBodyData[i] = 0x00;
+ // }
//
- // newBodyData[0] = (byte) bodyData.length;
+ // newBodyData[0] = (byte) bodyData.length;
//
- // for(int i = 0; i < bodyData.length; i++) {
- // newBodyData[i + 1] = bodyData[i];
- // }
+ // for(int i = 0; i < bodyData.length; i++) {
+ // newBodyData[i + 1] = bodyData[i];
+ // }
//
- // PumpMessage pumpMessage2 = sendAndGetACK(commandType, newBodyData, 4000);
+ // PumpMessage pumpMessage2 = sendAndGetACK(commandType, newBodyData, 4000);
//
//
- // LOG.debug("Response 2 - {}", HexDump.toHexStringDisplayable(pumpMessage.getRawContent()));
+ // LOG.debug("Response 2 - {}", HexDump.toHexStringDisplayable(pumpMessage.getRawContent()));
//
- // }
-
+ // }
// PUMP SPECIFIC COMMANDS
-
public Float getRemainingInsulin() {
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetRemainingInsulin);
- return responseObject == null ? null : (Float) responseObject;
+ return responseObject == null ? null : (Float)responseObject;
}
@@ -587,10 +585,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.PumpModel);
if (!MedtronicUtil.isModelSet()) {
- MedtronicUtil.setMedtronicPumpModel((MedtronicDeviceType) responseObject);
+ MedtronicUtil.setMedtronicPumpModel((MedtronicDeviceType)responseObject);
}
- return responseObject == null ? null : (MedtronicDeviceType) responseObject;
+ return responseObject == null ? null : (MedtronicDeviceType)responseObject;
}
@@ -598,7 +596,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetBasalProfileSTD);
- return responseObject == null ? null : (BasalProfile) responseObject;
+ return responseObject == null ? null : (BasalProfile)responseObject;
}
@@ -606,7 +604,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.RealTimeClock);
- return responseObject == null ? null : (LocalDateTime) responseObject;
+ return responseObject == null ? null : (LocalDateTime)responseObject;
}
@@ -614,15 +612,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.ReadTemporaryBasal);
- return responseObject == null ? null : (TempBasalPair) responseObject;
+ return responseObject == null ? null : (TempBasalPair)responseObject;
}
public Map getPumpSettings() {
- Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.getSettings(MedtronicUtil.getMedtronicPumpModel()));
+ Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.getSettings(MedtronicUtil
+ .getMedtronicPumpModel()));
- return responseObject == null ? null : (Map) responseObject;
+ return responseObject == null ? null : (Map)responseObject;
}
@@ -639,7 +638,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
LOG.debug("Set Bolus: Body - {}", HexDump.toHexStringDisplayable(body));
PumpMessage msg = makePumpMessage(MedtronicCommandType.SetBolus, //
- new CarelinkLongMessageBody(ByteUtil.concat((byte) body.length, body)));
+ new CarelinkLongMessageBody(ByteUtil.concat((byte)body.length, body)));
PumpMessage pumpMessage = runCommandWithArgs(msg);
@@ -661,7 +660,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
LOG.debug("Set TBR: Body - {}", HexDump.toHexStringDisplayable(body));
PumpMessage msg = makePumpMessage(MedtronicCommandType.SetTemporaryBasal, //
- new CarelinkLongMessageBody(tbr.getAsRawData()));
+ new CarelinkLongMessageBody(tbr.getAsRawData()));
PumpMessage pumpMessage = runCommandWithArgs(msg);
@@ -682,13 +681,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetBatteryStatus);
- return responseObject == null ? null : (BatteryStatusDTO) responseObject;
+ return responseObject == null ? null : (BatteryStatusDTO)responseObject;
}
// FIXME --- After this line commands in development --- REMOVE THIS COMMANDS
-
// TODO test
// TODO remove, we will see state from History
@@ -707,7 +705,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// TODO remove, we will see bolus status from History
public PumpMessage getBolusStatus() {
- PumpMessage response = sendAndGetResponse(MedtronicCommandType.SetBolus, new byte[]{0x03, 0x00, 0x00, 0x00}, 4000);
+ PumpMessage response = sendAndGetResponse(MedtronicCommandType.SetBolus, new byte[] { 0x03, 0x00, 0x00, 0x00 },
+ 4000);
byte[] data = response.getRawContent();
@@ -722,59 +721,83 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// TODO generateRawData (check if it works correctly) and test
public Boolean setBasalProfile(BasalProfile basalProfile) {
+ // [RileyLinkDevice] ======================== Save Basal Profile ===========================
+ // [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 1 bytes), 0,
+ // 0.180000, 3)
+ // [PeripheralManager+RileyLink] RL Send: 19050000000000000000b4030000a9659a6b19b199c555b2c000
+ // [PeripheralManager+RileyLink] RL Recv(single): bb
+ // [PeripheralManager+RileyLink] RileyLink response: PacketResponse(code:
+ // RileyLinkBLEKit.ResponseCode.commandInterrupted, packet: nil)
+ // [PeripheralManager+RileyLink] RL Recv(single): dd0dbca9659a6b19b156655534d500
+ // [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0,
+ // 0.180000, 3)
+ // [PeripheralManager+RileyLink] RL Send:
+ // 79050000000000000000b4030000a9659a6b19b199c571c9a555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555556000
+ // 2018-06-30 15:03:13.333962-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd10bda9659a6b19b156655534d500
+ // 2018-06-30 15:03:13.334927-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink,
+ // setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
+ // 2018-06-30 15:03:13.337923-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send:
+ // 79050000000000000000b4030000a9659a6b19b199c5725555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555ac000
+ // 2018-06-30 15:03:14.114024-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd0ebea9659a6b19b156655534d500
+ // 2018-06-30 15:03:14.115017-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink,
+ // setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
+ // 2018-06-30 15:03:14.117600-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send:
+ // 79050000000000000000b4030000a9659a6b19b199c6a355555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555570e000
+ // 2018-06-30 15:03:15.644502-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd0ebfa9659a6b19b156655534d500
+ // 2018-06-30 15:03:15.645388-0500 Loop[24609:13622484] [RileyLinkDevice] ------------------------ Save Basal
+ // Profile ---------------------------
- // [RileyLinkDevice] ======================== Save Basal Profile ===========================
- // [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 1 bytes), 0, 0.180000, 3)
- // [PeripheralManager+RileyLink] RL Send: 19050000000000000000b4030000a9659a6b19b199c555b2c000
- // [PeripheralManager+RileyLink] RL Recv(single): bb
- // [PeripheralManager+RileyLink] RileyLink response: PacketResponse(code: RileyLinkBLEKit.ResponseCode.commandInterrupted, packet: nil)
- // [PeripheralManager+RileyLink] RL Recv(single): dd0dbca9659a6b19b156655534d500
- // [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
- // [PeripheralManager+RileyLink] RL Send: 79050000000000000000b4030000a9659a6b19b199c571c9a555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555556000
- // 2018-06-30 15:03:13.333962-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single): dd10bda9659a6b19b156655534d500
- // 2018-06-30 15:03:13.334927-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
- // 2018-06-30 15:03:13.337923-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send: 79050000000000000000b4030000a9659a6b19b199c5725555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555ac000
- // 2018-06-30 15:03:14.114024-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single): dd0ebea9659a6b19b156655534d500
- // 2018-06-30 15:03:14.115017-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
- // 2018-06-30 15:03:14.117600-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send: 79050000000000000000b4030000a9659a6b19b199c6a355555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555570e000
- // 2018-06-30 15:03:15.644502-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single): dd0ebfa9659a6b19b156655534d500
- // 2018-06-30 15:03:15.645388-0500 Loop[24609:13622484] [RileyLinkDevice] ------------------------ Save Basal Profile ---------------------------
+ // 2018-06-30 15:03:12.167767-0500 Loop[24609:13622484] [RileyLinkDevice] ======================== Save Basal
+ // Profile ===========================
+ // 2018-06-30 15:03:12.168652-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink,
+ // setBasalProfileStandard, 3 bytes, 1 bytes), 0, 0.180000, 3)
+ // 2018-06-30 15:03:12.169518-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send:
+ // 19050000000000000000b4030000a9659a6b19b199c555b2c000
+ // 2018-06-30 15:03:12.463546-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single): bb
+ // 2018-06-30 15:03:12.463954-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RileyLink response:
+ // PacketResponse(code: RileyLinkBLEKit.ResponseCode.commandInterrupted, packet: nil)
+ // 2018-06-30 15:03:12.554051-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd0dbca9659a6b19b156655534d500
+ // 2018-06-30 15:03:12.555175-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink,
+ // setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
+ // 2018-06-30 15:03:12.557953-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send:
+ // 79050000000000000000b4030000a9659a6b19b199c571c9a555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555556000
+ // 2018-06-30 15:03:13.333962-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd10bda9659a6b19b156655534d500
+ // 2018-06-30 15:03:13.334927-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink,
+ // setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
+ // 2018-06-30 15:03:13.337923-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send:
+ // 79050000000000000000b4030000a9659a6b19b199c5725555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555ac000
+ // 2018-06-30 15:03:14.114024-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd0ebea9659a6b19b156655534d500
+ // 2018-06-30 15:03:14.115017-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink,
+ // setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
+ // 2018-06-30 15:03:14.117600-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send:
+ // 79050000000000000000b4030000a9659a6b19b199c6a355555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555570e000
+ // 2018-06-30 15:03:15.644502-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single):
+ // dd0ebfa9659a6b19b156655534d500
+ // 2018-06-30 15:03:15.645388-0500 Loop[24609:13622484] [RileyLinkDevice] ------------------------ Save Basal
+ // Profile ---------------------------
+ // byte[] body = basalProfile.generateRawData();
- // 2018-06-30 15:03:12.167767-0500 Loop[24609:13622484] [RileyLinkDevice] ======================== Save Basal Profile ===========================
- // 2018-06-30 15:03:12.168652-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 1 bytes), 0, 0.180000, 3)
- // 2018-06-30 15:03:12.169518-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send: 19050000000000000000b4030000a9659a6b19b199c555b2c000
- // 2018-06-30 15:03:12.463546-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single): bb
- // 2018-06-30 15:03:12.463954-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RileyLink response: PacketResponse(code: RileyLinkBLEKit.ResponseCode.commandInterrupted, packet: nil)
- // 2018-06-30 15:03:12.554051-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single): dd0dbca9659a6b19b156655534d500
- // 2018-06-30 15:03:12.555175-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
- // 2018-06-30 15:03:12.557953-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send: 79050000000000000000b4030000a9659a6b19b199c571c9a555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555556000
- // 2018-06-30 15:03:13.333962-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single): dd10bda9659a6b19b156655534d500
- // 2018-06-30 15:03:13.334927-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
- // 2018-06-30 15:03:13.337923-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send: 79050000000000000000b4030000a9659a6b19b199c5725555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555ac000
- // 2018-06-30 15:03:14.114024-0500 Loop[24609:13622486] [PeripheralManager+RileyLink] RL Recv(single): dd0ebea9659a6b19b156655534d500
- // 2018-06-30 15:03:14.115017-0500 Loop[24609:13622484] [PumpMessageSender] getResponse(PumpMessage(carelink, setBasalProfileStandard, 3 bytes, 65 bytes), 0, 0.180000, 3)
- // 2018-06-30 15:03:14.117600-0500 Loop[24609:13622484] [PeripheralManager+RileyLink] RL Send: 79050000000000000000b4030000a9659a6b19b199c6a355555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555570e000
- // 2018-06-30 15:03:15.644502-0500 Loop[24609:13622692] [PeripheralManager+RileyLink] RL Recv(single): dd0ebfa9659a6b19b156655534d500
- // 2018-06-30 15:03:15.645388-0500 Loop[24609:13622484] [RileyLinkDevice] ------------------------ Save Basal Profile ---------------------------
-
-
- //byte[] body = basalProfile.generateRawData();
-
- byte[] body = new byte[]{32, 0, 0, 38, 0, 13, 44, 0, 19, 38, 0, 28};
+ byte[] body = new byte[] { 32, 0, 0, 38, 0, 13, 44, 0, 19, 38, 0, 28 };
PumpMessage responseMessage;
if (debugSetCommands)
LOG.debug("Set Basal Profile: Body [{}] - {}", body.length, HexDump.toHexStringDisplayable(body));
- // if (body.length <= 64) {
+ // if (body.length <= 64) {
//
- // PumpMessage msg = makePumpMessage(MedtronicCommandType.SetBasalProfileA, //
- // new CarelinkLongMessageBody(ByteUtil.concat((byte) body.length, body)));
+ // PumpMessage msg = makePumpMessage(MedtronicCommandType.SetBasalProfileA, //
+ // new CarelinkLongMessageBody(ByteUtil.concat((byte) body.length, body)));
//
- // responseMessage = runCommandWithArgs(msg);
- // } else
+ // responseMessage = runCommandWithArgs(msg);
+ // } else
{
responseMessage = runCommandWithArgsLong(MedtronicCommandType.SetBasalProfileA, body);
@@ -788,31 +811,29 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
-// public byte[] getFullMessageBody(byte[] bodyData, int length) {
-// byte newBodyData[] = getEmptyMessage(length);
-//
-// newBodyData[0] = (byte) bodyData.length;
-//
-// for (int i = 0; i < bodyData.length; i++) {
-// newBodyData[i + 1] = bodyData[i];
-// }
-//
-// return newBodyData;
-// }
-
-
-// public byte[] getEmptyMessage(int length) {
-// byte newBodyData[] = new byte[length];
-// for (int i = 0; i < length; i++) {
-// newBodyData[i] = 0x00;
-// }
-//
-// return newBodyData;
-// }
+ // public byte[] getFullMessageBody(byte[] bodyData, int length) {
+ // byte newBodyData[] = getEmptyMessage(length);
+ //
+ // newBodyData[0] = (byte) bodyData.length;
+ //
+ // for (int i = 0; i < bodyData.length; i++) {
+ // newBodyData[i + 1] = bodyData[i];
+ // }
+ //
+ // return newBodyData;
+ // }
+ // public byte[] getEmptyMessage(int length) {
+ // byte newBodyData[] = new byte[length];
+ // for (int i = 0; i < length; i++) {
+ // newBodyData[i] = 0x00;
+ // }
+ //
+ // return newBodyData;
+ // }
public PumpMessage cancelBolus() {
- //? maybe suspend and resume
+ // ? maybe suspend and resume
return null;
}
@@ -830,44 +851,44 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return null;
}
- // Set TBR 100%
- // Cancel TBR (set TBR 100%) 100%
- // Get Status (40%)
- // Set Bolus 100%
- // Set Extended Bolus 20%
- // Cancel Bolus 0% -- NOT SUPPORTED
- // Cancel Extended Bolus 0% -- NOT SUPPORTED
+ // Set TBR 100%
+ // Cancel TBR (set TBR 100%) 100%
+ // Get Status (40%)
- // Get Basal Profile (0x92) Read STD 100%
- // Set Basal Profile 0% -- NOT SUPPORTED
- // Read History 60%
- // Load TDD ?
+ // Set Bolus 100%
+ // Set Extended Bolus 20%
+ // Cancel Bolus 0% -- NOT SUPPORTED
+ // Cancel Extended Bolus 0% -- NOT SUPPORTED
+ // Get Basal Profile (0x92) Read STD 100%
+ // Set Basal Profile 0% -- NOT SUPPORTED
+ // Read History 60%
+ // Load TDD ?
// FIXME remove - each part needs to be gotten manually
public void updatePumpManagerStatus() {
- //Integer resp = getRemainingBattery();
- //pumpStatus.batteryRemaining = resp == null ? -1 : resp;
+ // Integer resp = getRemainingBattery();
+ // pumpStatus.batteryRemaining = resp == null ? -1 : resp;
- //pumpStatus.remainUnits = getRemainingInsulin();
+ // pumpStatus.remainUnits = getRemainingInsulin();
/* current basal */
- //TempBasalPair basalRate = getCurrentBasalRate();
+ // TempBasalPair basalRate = getCurrentBasalRate();
// FIXME
- // byte[] basalRateBytes = resp.getContents();
- // if (basalRateBytes != null) {
- // if (basalRateBytes.length == 2) {
- // /**
- // * 0x98 0x06
- // * 0x98 is "basal rate"
- // * 0x06 is what? Not currently running a temp basal, current basal is "standard" at 0
- // */
- // double basalRate = ByteUtil.asUINT8(basalRateBytes[1]);
- // pumpStatus.currentBasal = basalRate;
- // }
- // }
+ // byte[] basalRateBytes = resp.getContents();
+ // if (basalRateBytes != null) {
+ // if (basalRateBytes.length == 2) {
+ // /**
+ // * 0x98 0x06
+ // * 0x98 is "basal rate"
+ // * 0x06 is what? Not currently running a temp basal, current basal is "standard" at 0
+ // */
+ // double basalRate = ByteUtil.asUINT8(basalRateBytes[1]);
+ // pumpStatus.currentBasal = basalRate;
+ // }
+ // }
// get last bolus amount
// get last bolus time
// get tempBasalInProgress
@@ -877,11 +898,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// get pump time
LocalDateTime clockResult = getPumpTime();
if (clockResult != null) {
- //pumpStatus.time = clockResult.toDate();
+ // pumpStatus.time = clockResult.toDate();
}
// get last sync time
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/Page.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/Page.java
index e7a58728aa..73b1e12a2d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/Page.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/Page.java
@@ -28,15 +28,15 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data;
* GGW: TODO: examine src/ecc1/medtronic for better history parsing
*/
-import android.os.Bundle;
-import android.util.Log;
-
-import org.joda.time.DateTime;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.joda.time.DateTime;
+
+import android.os.Bundle;
+import android.util.Log;
+
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.CRC;
import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
@@ -49,14 +49,14 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType
@Deprecated
public class Page {
+
private final static String TAG = "Page";
private static final boolean DEBUG_PAGE = true;
-
- private byte[] crc;
- private byte[] data;
- //protected PumpModel model;
+ // protected PumpModel model;
public static MedtronicDeviceType model = MedtronicDeviceType.Medtronic_522;
public List mRecordList;
+ private byte[] crc;
+ private byte[] data;
public Page() {
@@ -65,6 +65,104 @@ public class Page {
}
+ /*
+ * attemptParseRecord will attempt to create a subclass of Record from the given
+ * data and offset. It will return NULL if it fails. If it succeeds, the returned
+ * subclass of Record can be examined for its length, so that the next attempt can be made.
+ *
+ * TODO maybe try to change this, so that we can loose all the classes and using enum instead with full
+ * configuration. Its something to think about for later versions -- Andy
+ */
+ public static T attemptParseRecord(byte[] data, int offsetStart) {
+ // no data?
+ if (data == null) {
+ return null;
+ }
+ // invalid offset?
+ if (data.length < offsetStart) {
+ return null;
+ }
+ // Log.d(TAG,String.format("checking for handler for record type 0x%02X at index %d",data[offsetStart],offsetStart));
+ RecordTypeEnum en = RecordTypeEnum.fromByte(data[offsetStart]);
+ T record = en.getRecordClassInstance(model);
+ if (record != null) {
+ // have to do this to set the record's opCode
+ byte[] tmpData = new byte[data.length];
+ System.arraycopy(data, offsetStart, tmpData, 0, data.length - offsetStart);
+ boolean didParse = record.parseWithOffset(tmpData, model, offsetStart);
+ if (!didParse) {
+ Log.e(
+ TAG,
+ String.format("attemptParseRecord: class %s (opcode 0x%02X) failed to parse at offset %d",
+ record.getShortTypeName(), data[offsetStart], offsetStart));
+ }
+ }
+ return record;
+ }
+
+
+ public static DateTime parseSimpleDate(byte[] data, int offset) {
+ DateTime timeStamp = null;
+ int seconds = 0;
+ int minutes = 0;
+ int hour = 0;
+ // int high = data[0] >> 4;
+ int low = data[0 + offset] & 0x1F;
+ // int year_high = data[1] >> 4;
+ int mhigh = (data[0 + offset] & 0xE0) >> 4;
+ int mlow = (data[1 + offset] & 0x80) >> 7;
+ int month = mhigh + mlow;
+ int dayOfMonth = low + 1;
+ // python code says year is data[1] & 0x0F, but that will cause problem in 2016.
+ // Hopefully, the remaining bits are part of the year...
+ int year = data[1 + offset] & 0x3F;
+ /*
+ * Log.w(TAG, String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
+ * year + 2000, month, dayOfMonth, hour, minutes, seconds));
+ */
+ try {
+ timeStamp = new DateTime(year + 2000, month, dayOfMonth, hour, minutes, seconds);
+ } catch (org.joda.time.IllegalFieldValueException e) {
+ // Log.e(TAG,"Illegal DateTime field");
+ // e.printStackTrace();
+ return null;
+ }
+ return timeStamp;
+ }
+
+
+ public static void discoverRecords(byte[] data) {
+ int i = 0;
+ boolean done = false;
+
+ ArrayList keyLocations = new ArrayList();
+ while (!done) {
+ RecordTypeEnum en = RecordTypeEnum.fromByte(data[i]);
+ if (en != RecordTypeEnum.Null) {
+ keyLocations.add(i);
+ Log.v(TAG, String.format("Possible record of type %s found at index %d", en, i));
+ }
+ /*
+ * DateTime ts = parseSimpleDate(data,i);
+ * if (ts != null) {
+ * if (ts.year().get() == 2015) {
+ * Log.w(TAG, String.format("Possible simple date at index %d", i));
+ * }
+ * }
+ */
+ i = i + 1;
+ done = (i >= data.length - 2);
+ }
+ // for each of the discovered key locations, attempt to parse a sequence of records
+ for (RecordTypeEnum en : RecordTypeEnum.values()) {
+
+ }
+ for (int ix = 0; ix < keyLocations.size(); ix++) {
+
+ }
+ }
+
+
public byte[] getRawData() {
if (data == null) {
return crc;
@@ -91,7 +189,8 @@ public class Page {
this.model = model;
int pageOffset = 0;
- if ((rawPage == null) || (rawPage.length == 0)) return false;
+ if ((rawPage == null) || (rawPage.length == 0))
+ return false;
this.data = Arrays.copyOfRange(rawPage, 0, rawPage.length - 2);
this.crc = Arrays.copyOfRange(rawPage, rawPage.length - 2, rawPage.length);
byte[] expectedCrc = CRC.calculate16CCITT(this.data);
@@ -99,7 +198,10 @@ public class Page {
Log.i(TAG, String.format("Data length: %d", data.length));
}
if (!Arrays.equals(crc, expectedCrc)) {
- Log.w(TAG, String.format("CRC does not match expected value. Expected: %s Was: %s", HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
+ Log.w(
+ TAG,
+ String.format("CRC does not match expected value. Expected: %s Was: %s",
+ HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
} else {
if (DEBUG_PAGE) {
Log.i(TAG, "CRC OK");
@@ -110,7 +212,9 @@ public class Page {
while (pageOffset < data.length) {
if (data[pageOffset] == 0) {
if (record != null) {
- Log.i(TAG, String.format("End of page or Previous parse fail: prev opcode 0x%02x, curr offset %d, %d bytes remaining", record.getRecordOp(), pageOffset, data.length - pageOffset + 1));
+ Log.i(TAG, String.format(
+ "End of page or Previous parse fail: prev opcode 0x%02x, curr offset %d, %d bytes remaining",
+ record.getRecordOp(), pageOffset, data.length - pageOffset + 1));
break;
} else {
Log.i(TAG, "WTF?");
@@ -132,8 +236,8 @@ public class Page {
ArrayList pickyRecords = new ArrayList<>();
pickyRecords.addAll(mRecordList);
parseByDates(rawPage, model);
- for(Record r : mRecordList) {
- for(Record r2 : pickyRecords) {
+ for (Record r : mRecordList) {
+ for (Record r2 : pickyRecords) {
if (r.getFoundAtOffset() == r2.getFoundAtOffset()) {
Log.v(TAG, "Found matching record at offset " + r.getFoundAtOffset());
}
@@ -147,7 +251,7 @@ public class Page {
mRecordList = new ArrayList<>();
if (rawPage.length != 1024) {
Log.e(TAG, "Unexpected page size. Expected: 1024 Was: " + rawPage.length);
- //return false;
+ // return false;
}
Page.model = model;
if (DEBUG_PAGE) {
@@ -166,7 +270,10 @@ public class Page {
Log.i(TAG, String.format("Data length: %d", data.length));
}
if (!Arrays.equals(crc, expectedCrc)) {
- Log.w(TAG, String.format("CRC does not match expected value. Expected: %s Was: %s", HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
+ Log.w(
+ TAG,
+ String.format("CRC does not match expected value. Expected: %s Was: %s",
+ HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
} else {
if (DEBUG_PAGE) {
Log.i(TAG, "CRC OK");
@@ -201,7 +308,6 @@ public class Page {
pageOffset++;
}
-
return true;
}
@@ -210,7 +316,7 @@ public class Page {
mRecordList = new ArrayList<>(); // wipe old contents each time when parsing.
if (rawPage.length != 1024) {
Log.e(TAG, "Unexpected page size. Expected: 1024 Was: " + rawPage.length);
- //return false;
+ // return false;
}
this.model = model;
if (DEBUG_PAGE) {
@@ -229,7 +335,10 @@ public class Page {
Log.i(TAG, String.format("Data length: %d", data.length));
}
if (!Arrays.equals(crc, expectedCrc)) {
- Log.w(TAG, String.format("CRC does not match expected value. Expected: %s Was: %s", HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
+ Log.w(
+ TAG,
+ String.format("CRC does not match expected value. Expected: %s Was: %s",
+ HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
} else {
if (DEBUG_PAGE) {
Log.i(TAG, "CRC OK");
@@ -249,12 +358,14 @@ public class Page {
record = null;
}
} else {
- Log.v(TAG, "Zero opcode encountered -- end of page. " + (rawPage.length - dataIndex) + " bytes remaining.");
+ Log.v(TAG, "Zero opcode encountered -- end of page. " + (rawPage.length - dataIndex)
+ + " bytes remaining.");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Possible parsing problem: ");
stringBuilder.append("Previous record: " + previousRecord);
- stringBuilder.append(" Content of previous record: " + HexDump.toHexStringDisplayable(previousRecord.getRawbytes()));
+ stringBuilder.append(" Content of previous record: "
+ + HexDump.toHexStringDisplayable(previousRecord.getRawbytes()));
int remainingData = rawPage.length - dataIndex;
byte[] tmpData = new byte[remainingData + 10];
@@ -269,10 +380,13 @@ public class Page {
if (record != null) {
if (record instanceof IgnoredHistoryEntry) {
- IgnoredHistoryEntry he = (IgnoredHistoryEntry) record;
- Log.v(TAG, "parseFrom: found event " + he.getShortTypeName() + " length=" + record.getLength() + " offset=" + record.getFoundAtOffset() + " -- IGNORING");
+ IgnoredHistoryEntry he = (IgnoredHistoryEntry)record;
+ Log.v(TAG, "parseFrom: found event " + he.getShortTypeName() + " length=" + record.getLength()
+ + " offset=" + record.getFoundAtOffset() + " -- IGNORING");
} else {
- Log.v(TAG, "parseFrom: found event " + record.getClass().getSimpleName() + " length=" + record.getLength() + " offset=" + record.getFoundAtOffset());
+ Log.v(TAG,
+ "parseFrom: found event " + record.getClass().getSimpleName() + " length=" + record.getLength()
+ + " offset=" + record.getFoundAtOffset());
mRecordList.add(record);
}
@@ -283,19 +397,19 @@ public class Page {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Possible parsing problem: ");
stringBuilder.append("Previous record: " + previousRecord);
- stringBuilder.append(" Content of previous record: " + HexDump.toHexStringDisplayable(previousRecord.getRawbytes()));
+ stringBuilder.append(" Content of previous record: "
+ + HexDump.toHexStringDisplayable(previousRecord.getRawbytes()));
int remainingData = data.length - dataIndex;
byte[] tmpData = Arrays.copyOfRange(data, dataIndex, 1022);
-
- //new byte[remainingData];
- //System.arraycopy(data, dataIndex, tmpData, 0, remainingData - 2);
+ // new byte[remainingData];
+ // System.arraycopy(data, dataIndex, tmpData, 0, remainingData - 2);
stringBuilder.append(" Remaining data: " + HexDump.toHexStringDisplayable(tmpData));
-
- Log.e(TAG, String.format("parseFrom: Failed to parse opcode 0x%02x, offset=%d", data[dataIndex], dataIndex));
+ Log.e(TAG,
+ String.format("parseFrom: Failed to parse opcode 0x%02x, offset=%d", data[dataIndex], dataIndex));
done = true;
}
if (dataIndex >= data.length - 2) {
@@ -308,7 +422,7 @@ public class Page {
if (DEBUG_PAGE) {
Log.i(TAG, String.format("Number of records: %d", mRecordList.size()));
int index = 1;
- for(Record r : mRecordList) {
+ for (Record r : mRecordList) {
Log.v(TAG, String.format("Record #%d: %s", index, r.getShortTypeName()));
index += 1;
}
@@ -317,112 +431,17 @@ public class Page {
}
- /* attemptParseRecord will attempt to create a subclass of Record from the given
- * data and offset. It will return NULL if it fails. If it succeeds, the returned
- * subclass of Record can be examined for its length, so that the next attempt can be made.
- *
- * TODO maybe try to change this, so that we can loose all the classes and using enum instead with full
- * configuration. Its something to think about for later versions -- Andy
- */
- public static T attemptParseRecord(byte[] data, int offsetStart) {
- // no data?
- if (data == null) {
- return null;
- }
- // invalid offset?
- if (data.length < offsetStart) {
- return null;
- }
- //Log.d(TAG,String.format("checking for handler for record type 0x%02X at index %d",data[offsetStart],offsetStart));
- RecordTypeEnum en = RecordTypeEnum.fromByte(data[offsetStart]);
- T record = en.getRecordClassInstance(model);
- if (record != null) {
- // have to do this to set the record's opCode
- byte[] tmpData = new byte[data.length];
- System.arraycopy(data, offsetStart, tmpData, 0, data.length - offsetStart);
- boolean didParse = record.parseWithOffset(tmpData, model, offsetStart);
- if (!didParse) {
- Log.e(TAG, String.format("attemptParseRecord: class %s (opcode 0x%02X) failed to parse at offset %d", record.getShortTypeName(), data[offsetStart], offsetStart));
- }
- }
- return record;
- }
-
-
- public static DateTime parseSimpleDate(byte[] data, int offset) {
- DateTime timeStamp = null;
- int seconds = 0;
- int minutes = 0;
- int hour = 0;
- //int high = data[0] >> 4;
- int low = data[0 + offset] & 0x1F;
- //int year_high = data[1] >> 4;
- int mhigh = (data[0 + offset] & 0xE0) >> 4;
- int mlow = (data[1 + offset] & 0x80) >> 7;
- int month = mhigh + mlow;
- int dayOfMonth = low + 1;
- // python code says year is data[1] & 0x0F, but that will cause problem in 2016.
- // Hopefully, the remaining bits are part of the year...
- int year = data[1 + offset] & 0x3F;
- /*
- Log.w(TAG, String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
- year + 2000, month, dayOfMonth, hour, minutes, seconds));
- */
- try {
- timeStamp = new DateTime(year + 2000, month, dayOfMonth, hour, minutes, seconds);
- } catch (org.joda.time.IllegalFieldValueException e) {
- //Log.e(TAG,"Illegal DateTime field");
- //e.printStackTrace();
- return null;
- }
- return timeStamp;
- }
-
-
- public static void discoverRecords(byte[] data) {
- int i = 0;
- boolean done = false;
-
- ArrayList keyLocations = new ArrayList();
- while (!done) {
- RecordTypeEnum en = RecordTypeEnum.fromByte(data[i]);
- if (en != RecordTypeEnum.Null) {
- keyLocations.add(i);
- Log.v(TAG, String.format("Possible record of type %s found at index %d", en, i));
- }
- /*
- DateTime ts = parseSimpleDate(data,i);
- if (ts != null) {
- if (ts.year().get() == 2015) {
- Log.w(TAG, String.format("Possible simple date at index %d", i));
- }
- }
- */
- i = i + 1;
- done = (i >= data.length - 2);
- }
- // for each of the discovered key locations, attempt to parse a sequence of records
- for(RecordTypeEnum en : RecordTypeEnum.values()) {
-
- }
- for(int ix = 0; ix < keyLocations.size(); ix++) {
-
- }
- }
-
/*
- *
- * For IPC serialization
- *
+ *
+ * For IPC serialization
*/
/*
- private byte[] crc;
- private byte[] data;
- protected PumpModel model;
- public List mRecordList;
- */
-
+ * private byte[] crc;
+ * private byte[] data;
+ * protected PumpModel model;
+ * public List mRecordList;
+ */
public Bundle pack() {
Bundle bundle = new Bundle();
@@ -430,7 +449,7 @@ public class Page {
bundle.putByteArray("data", data);
bundle.putString("model", model.name());
ArrayList records = new ArrayList<>();
- for(int i = 0; i < mRecordList.size(); i++) {
+ for (int i = 0; i < mRecordList.size(); i++) {
try {
records.add(mRecordList.get(i).dictionaryRepresentation());
} catch (NullPointerException e) {
@@ -449,7 +468,7 @@ public class Page {
ArrayList records = in.getParcelableArrayList("mRecordList");
mRecordList = new ArrayList<>();
if (records != null) {
- for(int i = 0; i < records.size(); i++) {
+ for (int i = 0; i < records.size(); i++) {
Record r = RecordTypeEnum.getRecordClassInstance(records.get(i), model);
r.readFromBundle(records.get(i));
mRecordList.add(r);
@@ -457,5 +476,4 @@ public class Page {
}
}
-
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/RawHistoryPage.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/RawHistoryPage.java
index cd4fa62de2..e1055c8302 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/RawHistoryPage.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/RawHistoryPage.java
@@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data;
-import android.util.Log;
+import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Arrays;
+import android.util.Log;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.CRC;
@@ -15,6 +15,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
* Created by geoff on 6/4/16.
*/
public class RawHistoryPage {
+
private static final String TAG = "RawHistoryPage";
private static final Logger LOG = LoggerFactory.getLogger(RawHistoryPage.class);
byte[] data = new byte[0];
@@ -54,9 +55,11 @@ public class RawHistoryPage {
int crcStored = ByteUtil.toInt(data[1022], data[1023]);
if (crcCalculated != crcStored) {
- LOG.error("Stored CRC ({}) is different than calculated ({}), but ignored for now.", crcStored, crcCalculated);
+ LOG.error("Stored CRC ({}) is different than calculated ({}), but ignored for now.", crcStored,
+ crcCalculated);
} else {
- if (MedtronicUtil.isLowLevelDebug()) LOG.debug("CRC ok.");
+ if (MedtronicUtil.isLowLevelDebug())
+ LOG.debug("CRC ok.");
}
return crcCalculated == crcStored;
@@ -76,5 +79,4 @@ public class RawHistoryPage {
}
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/PumpTimeStamp.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/PumpTimeStamp.java
index 895cde06f3..d83dcff8c2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/PumpTimeStamp.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/PumpTimeStamp.java
@@ -8,16 +8,20 @@ import org.joda.time.LocalDateTime;
* Exists to easily merge 2 byte timestamps and 5 byte timestamps.
*/
public class PumpTimeStamp {
+
private LocalDateTime localDateTime;
+
public PumpTimeStamp() {
localDateTime = new LocalDateTime(1973, 1, 1, 1, 1);
}
+
public PumpTimeStamp(String stringRepresentation) {
localDateTime.parse(stringRepresentation);
}
+
public PumpTimeStamp(LocalDate localDate) {
try {
localDateTime = new LocalDateTime(localDate);
@@ -27,14 +31,17 @@ public class PumpTimeStamp {
}
}
+
public PumpTimeStamp(LocalDateTime localDateTime) {
this.localDateTime = localDateTime;
}
+
public LocalDateTime getLocalDateTime() {
return localDateTime;
}
+
@Override
public String toString() {
return getLocalDateTime().toString();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/Record.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/Record.java
index 2fb68848b3..24f2f6a55c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/Record.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/Record.java
@@ -8,10 +8,21 @@ abstract public class Record {
protected MedtronicDeviceType model;
protected byte recordOp;
- //protected int length;
+ // protected int length;
protected int foundAtOffset;
protected byte[] rawbytes = new byte[0];
- //protected String recordTypeName = this.getClass().getSimpleName();
+
+
+ // protected String recordTypeName = this.getClass().getSimpleName();
+
+ public Record() {
+
+ }
+
+
+ protected static int asUINT8(byte b) {
+ return (b < 0) ? b + 256 : b;
+ }
public String getRecordTypeName() {
@@ -34,11 +45,6 @@ abstract public class Record {
}
- public Record() {
-
- }
-
-
public boolean parseWithOffset(byte[] data, MedtronicDeviceType model, int foundAtOffset) {
// keep track of where the record was found for later analysis
this.foundAtOffset = foundAtOffset;
@@ -83,11 +89,6 @@ abstract public class Record {
}
- protected static int asUINT8(byte b) {
- return (b < 0) ? b + 256 : b;
- }
-
-
public Bundle dictionaryRepresentation() {
Bundle rval = new Bundle();
writeToBundle(rval);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/RecordTypeEnum.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/RecordTypeEnum.java
index c7546d918e..c7a2ce8625 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/RecordTypeEnum.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/RecordTypeEnum.java
@@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history;
-import android.os.Bundle;
-
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
+import android.os.Bundle;
+
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record.AlarmClockReminderPumpEvent;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record.AlarmSensorPumpEvent;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record.BGReceivedPumpEvent;
@@ -68,36 +68,35 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType
@Deprecated
public enum RecordTypeEnum {
- Null((byte) 0x00, null, 0), //
+ Null((byte)0x00, null, 0), //
// Good Events
BolusNormal(0x01, BolusNormalPumpEvent.class), // OK
- Prime((byte) 0x03, PrimePumpEvent.class), // OK
- AlarmPump((byte) 0x06, PumpAlarmPumpEvent.class), //
- ResultDailyTotal((byte) 0x07, ResultDailyTotalPumpEvent.class), // OK
- ChangeBasalProfile_old_profile((byte) 0x08, ChangeBasalProfilePatternPumpEvent.class), // OK
- ChangeBasalProfile_new_profile((byte) 0x09, ChangeBasalProfilePumpEvent.class), // OK
+ Prime((byte)0x03, PrimePumpEvent.class), // OK
+ AlarmPump((byte)0x06, PumpAlarmPumpEvent.class), //
+ ResultDailyTotal((byte)0x07, ResultDailyTotalPumpEvent.class), // OK
+ ChangeBasalProfile_old_profile((byte)0x08, ChangeBasalProfilePatternPumpEvent.class), // OK
+ ChangeBasalProfile_new_profile((byte)0x09, ChangeBasalProfilePumpEvent.class), // OK
- CalBgForPh((byte) 0x0A, CalBgForPhPumpEvent.class), //
- AlarmSensor((byte) 0x0B, AlarmSensorPumpEvent.class), //
- ClearAlarm((byte) 0x0C, ClearAlarmPumpEvent.class), //
- SelectBasalProfile((byte) 0x14, IgnoredHistoryEntry.class, 7), // OK
- TempBasalDuration((byte) 0x16, TempBasalDurationPumpEvent.class), // OK
- ChangeTime((byte) 0x17, ChangeTimePumpEvent.class), // OK
- NewTimeSet((byte) 0x18, NewTimeSet.class), // OK
+ CalBgForPh((byte)0x0A, CalBgForPhPumpEvent.class), //
+ AlarmSensor((byte)0x0B, AlarmSensorPumpEvent.class), //
+ ClearAlarm((byte)0x0C, ClearAlarmPumpEvent.class), //
+ SelectBasalProfile((byte)0x14, IgnoredHistoryEntry.class, 7), // OK
+ TempBasalDuration((byte)0x16, TempBasalDurationPumpEvent.class), // OK
+ ChangeTime((byte)0x17, ChangeTimePumpEvent.class), // OK
+ NewTimeSet((byte)0x18, NewTimeSet.class), // OK
-
- JournalEntryPumpLowBattery((byte) 0x19, JournalEntryPumpLowBatteryPumpEvent.class), //
- RECORD_TYPE_BATTERY((byte) 0x1A, BatteryPumpEvent.class), //
+ JournalEntryPumpLowBattery((byte)0x19, JournalEntryPumpLowBatteryPumpEvent.class), //
+ RECORD_TYPE_BATTERY((byte)0x1A, BatteryPumpEvent.class), //
SetAutoOff(0x1b, 7), //
- Suspend((byte) 0x1E, SuspendPumpEvent.class), // OK
- Resume((byte) 0x1F, ResumePumpEvent.class), // OK
+ Suspend((byte)0x1E, SuspendPumpEvent.class), // OK
+ Resume((byte)0x1F, ResumePumpEvent.class), // OK
SelfTest(0x20, 7), //
- Rewind((byte) 0x21, RewindPumpEvent.class), //
+ Rewind((byte)0x21, RewindPumpEvent.class), //
ClearSettings(0x22, 7), //
- ChangeChildBlockEnable((byte) 0x23, ChangeChildBlockEnablePumpEvent.class), //
- ChangeMaxBolus((byte) 0x24, ChangeMaxBolusPumpEvent.class), //
- EnableDisableRemote((byte) 0x26, EnableDisableRemotePumpEvent.class), //
+ ChangeChildBlockEnable((byte)0x23, ChangeChildBlockEnablePumpEvent.class), //
+ ChangeMaxBolus((byte)0x24, ChangeMaxBolusPumpEvent.class), //
+ EnableDisableRemote((byte)0x26, EnableDisableRemotePumpEvent.class), //
ChangeMaxBasal(0x2c, 7), //
EnableBolusWizard(0x2d, 7), //
Andy2E(0x2e, 7), //
@@ -105,9 +104,9 @@ public enum RecordTypeEnum {
Andy30(0x30, 7), //
ChangeBGReminderOffset(0x31, 7), //
ChangeAlarmClockTime(0x32, 7), //
- tempBasal((byte) 0x33, TempBasalRatePumpEvent.class), //
- journalEntryPumpLowReservoir((byte) 0x34, JournalEntryPumpLowReservoirPumpEvent.class), //
- AlarmClockReminder((byte) 0x35, AlarmClockReminderPumpEvent.class), //
+ tempBasal((byte)0x33, TempBasalRatePumpEvent.class), //
+ journalEntryPumpLowReservoir((byte)0x34, JournalEntryPumpLowReservoirPumpEvent.class), //
+ AlarmClockReminder((byte)0x35, AlarmClockReminderPumpEvent.class), //
ChangeMeterId(0x36, 7), // 715 = 21 ??
MM512_Event_0x37(0x37, 7), //
MM512_Event_0x38(0x38, 7), //
@@ -117,11 +116,11 @@ public enum RecordTypeEnum {
changeParadigmLinkID(0x3c, 7), //
MM512_Event_0x3D(0x3D, 7), //
MM512_Event_0x3E(0x3e, 7), //
- bgReceived((byte) 0x3F, BGReceivedPumpEvent.class), //
+ bgReceived((byte)0x3F, BGReceivedPumpEvent.class), //
JournalEntryMealMarker(0x40, 7), //
- JournalEntryExerciseMarker((byte) 0x41, JournalEntryExerciseMarkerPumpEvent.class), //
- JournalEntryInsulinMarker((byte) 0x42, Unknown7ByteEvent1.class), //
- journalEntryOtherMarker((byte) 0x43, InsulinMarkerEvent.class), //
+ JournalEntryExerciseMarker((byte)0x41, JournalEntryExerciseMarkerPumpEvent.class), //
+ JournalEntryInsulinMarker((byte)0x42, Unknown7ByteEvent1.class), //
+ journalEntryOtherMarker((byte)0x43, InsulinMarkerEvent.class), //
MM512_Event_0x44(0x44, 7), //
MM512_Event_0x45(0x45, 7), //
@@ -135,52 +134,50 @@ public enum RecordTypeEnum {
MM512_Event_0x4d(0x4d, 7), //
MM512_Event_0x4e(0x4e, 7), //
+ // case changeBolusWizardSetup = 0x4f, 7), //
- // case changeBolusWizardSetup = 0x4f, 7), //
+ changeSensorSetup2((byte)0x50, ChangeSensorSetup2PumpEvent.class), //
+ // case restoreMystery51 = 0x51, 7), //
+ // case restoreMystery52 = 0x52, 7), //
+ // case changeSensorAlarmSilenceConfig = 0x53, 7), //
+ // case restoreMystery54 = 0x54, 7), //
+ // case restoreMystery55 = 0x55, 7), //
+ ChangeSensorRateOfChangeAlertSetup((byte)0x56, ChangeSensorRateOfChangeAlertSetupPumpEvent.class), //
+ ChangeBolusScrollStepSize((byte)0x57, ChangeBolusScrollStepSizePumpEvent.class), //
+ ChangeBolusWizardSetup((byte)0x5A, ChangeBolusWizardSetupPumpEvent.class), //
+ BolusWizardBolusEstimate((byte)0x5B, BolusWizardBolusEstimatePumpEvent.class), //
+ unabsorbedInsulin((byte)0x5C, UnabsorbedInsulin.class), //
+ // case saveSettings = 0x5d, 7), //
+ changeVariableBolus((byte)0x5e, ChangeVariableBolusPumpEvent.class), //
+ changeAudioBolus((byte)0x5f, ChangeAudioBolusPumpEvent.class), //
+ ChangeBGReminderEnable((byte)0x60, ChangeBGReminderEnablePumpEvent.class), //
+ ChangeAlarmClockEnable((byte)0x61, ChangeAlarmClockEnablePumpEvent.class), //
- changeSensorSetup2((byte) 0x50, ChangeSensorSetup2PumpEvent.class), //
- // case restoreMystery51 = 0x51, 7), //
- // case restoreMystery52 = 0x52, 7), //
- // case changeSensorAlarmSilenceConfig = 0x53, 7), //
- // case restoreMystery54 = 0x54, 7), //
- // case restoreMystery55 = 0x55, 7), //
- ChangeSensorRateOfChangeAlertSetup((byte) 0x56, ChangeSensorRateOfChangeAlertSetupPumpEvent.class), //
- ChangeBolusScrollStepSize((byte) 0x57, ChangeBolusScrollStepSizePumpEvent.class), //
- ChangeBolusWizardSetup((byte) 0x5A, ChangeBolusWizardSetupPumpEvent.class), //
- BolusWizardBolusEstimate((byte) 0x5B, BolusWizardBolusEstimatePumpEvent.class), //
- unabsorbedInsulin((byte) 0x5C, UnabsorbedInsulin.class), //
- // case saveSettings = 0x5d, 7), //
- changeVariableBolus((byte) 0x5e, ChangeVariableBolusPumpEvent.class), //
- changeAudioBolus((byte) 0x5f, ChangeAudioBolusPumpEvent.class), //
- ChangeBGReminderEnable((byte) 0x60, ChangeBGReminderEnablePumpEvent.class), //
- ChangeAlarmClockEnable((byte) 0x61, ChangeAlarmClockEnablePumpEvent.class), //
-
-
- ChangeTempBasalType((byte) 0x62, ChangeTempBasalTypePumpEvent.class), //
- ChangeAlarmNotifyMode((byte) 0x63, ChangeAlarmNotifyModePumpEvent.class), //
- ChangeTimeFormat((byte) 0x64, ChangeTimeFormatPumpEvent.class), //
- ChangeReservoirWarningTime((byte) 0x65, ChangeReservoirWarningTimePumpEvent.class), //
- ChangeBolusReminderEnable((byte) 0x66, ChangeBolusReminderEnablePumpEvent.class), //
- ChangeBolusReminderTime((byte) 0x67, ChangeBolusReminderTimePumpEvent.class), //
- DeleteBolusReminderTime((byte) 0x68, DeleteBolusReminderTimePumpEvent.class), //
+ ChangeTempBasalType((byte)0x62, ChangeTempBasalTypePumpEvent.class), //
+ ChangeAlarmNotifyMode((byte)0x63, ChangeAlarmNotifyModePumpEvent.class), //
+ ChangeTimeFormat((byte)0x64, ChangeTimeFormatPumpEvent.class), //
+ ChangeReservoirWarningTime((byte)0x65, ChangeReservoirWarningTimePumpEvent.class), //
+ ChangeBolusReminderEnable((byte)0x66, ChangeBolusReminderEnablePumpEvent.class), //
+ ChangeBolusReminderTime((byte)0x67, ChangeBolusReminderTimePumpEvent.class), //
+ DeleteBolusReminderTime((byte)0x68, DeleteBolusReminderTimePumpEvent.class), //
// case bolusReminder = 0x69, 7), //
- DeleteAlarmClockTime((byte) 0x6a, DeleteAlarmClockTimePumpEvent.class), //
+ DeleteAlarmClockTime((byte)0x6a, DeleteAlarmClockTimePumpEvent.class), //
DailyTotal515(0x6c, 38), // FIXME
- dailyTotal522((byte) 0x6D, Model522ResultTotalsPumpEvent.class), //
- dailyTotal523((byte) 0x6E, IgnoredHistoryEntry.class, 52), // Sara6E // FIXME
- ChangeCarbUnits((byte) 0x6f, ChangeCarbUnitsPumpEvent.class), //
- basalProfileStart((byte) 0x7B, BasalProfileStart.class), //
- ChangeWatchdogEnable((byte) 0x7c, ChangeWatchdogEnablePumpEvent.class), //
- ChangeOtherDeviceID((byte) 0x7d, ChangeOtherDeviceIDPumpEvent.class), //
- ChangeWatchdogMarriageProfile((byte) 0x81, ChangeWatchdogMarriageProfilePumpEvent.class), //
- DeleteOtherDeviceID((byte) 0x82, DeleteOtherDeviceIDPumpEvent.class), //
- ChangeCaptureEventEnable((byte) 0x83, ChangeCaptureEventEnablePumpEvent.class),
+ dailyTotal522((byte)0x6D, Model522ResultTotalsPumpEvent.class), //
+ dailyTotal523((byte)0x6E, IgnoredHistoryEntry.class, 52), // Sara6E // FIXME
+ ChangeCarbUnits((byte)0x6f, ChangeCarbUnitsPumpEvent.class), //
+ basalProfileStart((byte)0x7B, BasalProfileStart.class), //
+ ChangeWatchdogEnable((byte)0x7c, ChangeWatchdogEnablePumpEvent.class), //
+ ChangeOtherDeviceID((byte)0x7d, ChangeOtherDeviceIDPumpEvent.class), //
+ ChangeWatchdogMarriageProfile((byte)0x81, ChangeWatchdogMarriageProfilePumpEvent.class), //
+ DeleteOtherDeviceID((byte)0x82, DeleteOtherDeviceIDPumpEvent.class), //
+ ChangeCaptureEventEnable((byte)0x83, ChangeCaptureEventEnablePumpEvent.class),
// Irelevant records (events that don't concern us for AAPS usage)
-
;
+ private static final String TAG = "RecordTypeEnum";
private static Map mapByOpCode = null;
private byte opcode;
private Class mRecordClass;
@@ -188,24 +185,14 @@ public enum RecordTypeEnum {
private String shortTypeName;
- public byte opcode() {
- return opcode;
- }
-
-
- public Class recordClass() {
- return mRecordClass;
- }
-
-
RecordTypeEnum(int b, Class c) {
- opcode = (byte) b;
+ opcode = (byte)b;
mRecordClass = c;
}
RecordTypeEnum(int b, Class c, int length) {
- opcode = (byte) b;
+ opcode = (byte)b;
mRecordClass = c;
this.length = length;
}
@@ -217,7 +204,7 @@ public enum RecordTypeEnum {
public static RecordTypeEnum fromByte(byte b) {
- for(RecordTypeEnum en : RecordTypeEnum.values()) {
+ for (RecordTypeEnum en : RecordTypeEnum.values()) {
if (en.opcode() == b) {
return en;
}
@@ -226,7 +213,21 @@ public enum RecordTypeEnum {
}
- private static final String TAG = "RecordTypeEnum";
+ public static T getRecordClassInstance(Bundle bundle, MedtronicDeviceType model) {
+ byte opcode = bundle.getByte("_opcode");
+ RecordTypeEnum e = RecordTypeEnum.fromByte(opcode);
+ return e.getRecordClassInstance(model);
+ }
+
+
+ public byte opcode() {
+ return opcode;
+ }
+
+
+ public Class recordClass() {
+ return mRecordClass;
+ }
public T getRecordClassInstance(MedtronicDeviceType model) {
@@ -242,7 +243,7 @@ public enum RecordTypeEnum {
// if this is IgnoredHistoryEntry we need to set type so that we get correct length and name
if (record instanceof IgnoredHistoryEntry) {
- IgnoredHistoryEntry he = (IgnoredHistoryEntry) record;
+ IgnoredHistoryEntry he = (IgnoredHistoryEntry)record;
he.init(this);
}
}
@@ -261,13 +262,6 @@ public enum RecordTypeEnum {
}
- public static T getRecordClassInstance(Bundle bundle, MedtronicDeviceType model) {
- byte opcode = bundle.getByte("_opcode");
- RecordTypeEnum e = RecordTypeEnum.fromByte(opcode);
- return e.getRecordClassInstance(model);
- }
-
-
public int getLength() {
return length;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeFormat.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeFormat.java
index af8ac17cb3..ce3fe25070 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeFormat.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeFormat.java
@@ -1,30 +1,33 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history;
-import android.util.Log;
-
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
+import android.util.Log;
+
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
/**
* Created by geoff on 6/4/16.
*/
public class TimeFormat {
+
+ public static final String standardFormatString = "YYYY-MM-dd HH:mm:ss";
private static final boolean DEBUG_TIMEFORMAT = false;
private static final String TAG = "TimeFormat";
+
public TimeFormat() {
}
- public static final String standardFormatString = "YYYY-MM-dd HH:mm:ss";
public static DateTimeFormatter standardFormatter() {
return DateTimeFormat.forPattern(standardFormatString);
}
+
public static LocalDate parse2ByteDate(byte[] data, int offset) throws org.joda.time.IllegalFieldValueException {
int low = ByteUtil.asUINT8(data[0 + offset]) & 0x1F;
int mhigh = (ByteUtil.asUINT8(data[0 + offset]) & 0xE0) >> 4;
@@ -33,29 +36,29 @@ public class TimeFormat {
int dayOfMonth = low + 1;
int year = 2000 + (ByteUtil.asUINT8(data[offset + 1]) & 0x7F);
/*
- Log.w(TAG, String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
- year + 2000, month, dayOfMonth, hour, minutes, seconds));
- */
-// try {
+ * Log.w(TAG, String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
+ * year + 2000, month, dayOfMonth, hour, minutes, seconds));
+ */
+ // try {
LocalDate rval = new LocalDate(year, month, dayOfMonth);
return rval;
/*
- } catch (org.joda.time.IllegalFieldValueException e) {
- Log.e(TAG,"Illegal DateTime field");
- //e.printStackTrace();
- return new LocalDate(1973,3,3);
- }
- */
+ * } catch (org.joda.time.IllegalFieldValueException e) {
+ * Log.e(TAG,"Illegal DateTime field");
+ * //e.printStackTrace();
+ * return new LocalDate(1973,3,3);
+ * }
+ */
}
+
// for relation to old code, replace offset with headerSize
-
public static LocalDateTime parse5ByteDate(byte[] data, int offset) throws org.joda.time.IllegalFieldValueException {
- //offset = headerSize;
+ // offset = headerSize;
if (DEBUG_TIMEFORMAT) {
- Log.w(TAG, String.format("bytes to parse: 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X",
- data[offset], data[offset + 1], data[offset + 2], data[offset + 3], data[offset + 4]));
+ Log.w(TAG, String.format("bytes to parse: 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X", data[offset],
+ data[offset + 1], data[offset + 2], data[offset + 3], data[offset + 4]));
}
int seconds = data[offset] & 0x3F;
int minutes = data[offset + 1] & 0x3F;
@@ -63,22 +66,22 @@ public class TimeFormat {
int dayOfMonth = data[offset + 3] & 0x1F;
// Yes, the month bits are stored in the high bits above seconds and minutes!!
int month = ((data[offset] >> 4) & 0x0c) + ((data[offset + 1] >> 6) & 0x03);
- int year = data[offset + 4] & 0x3F; // Assuming this is correct, need to verify. Otherwise this will be a problem in 2016.
+ int year = data[offset + 4] & 0x3F; // Assuming this is correct, need to verify. Otherwise this will be a
+ // problem in 2016.
/*
- Log.w(TAG,String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
- year+2000,month,dayOfMonth,hour,minutes,seconds));
- */
-// try {
+ * Log.w(TAG,String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
+ * year+2000,month,dayOfMonth,hour,minutes,seconds));
+ */
+ // try {
LocalDateTime timeStamp = new LocalDateTime(year + 2000, month, dayOfMonth, hour, minutes, seconds);
return timeStamp;
/*
- } catch (org.joda.time.IllegalFieldValueException e) {
- Log.e(TAG, "Illegal DateTime field");
- //e.printStackTrace();
- return new LocalDateTime(1973,2,2,2,2);
- }
- */
+ * } catch (org.joda.time.IllegalFieldValueException e) {
+ * Log.e(TAG, "Illegal DateTime field");
+ * //e.printStackTrace();
+ * return new LocalDateTime(1973,2,2,2,2);
+ * }
+ */
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeStampedRecord.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeStampedRecord.java
index ace918d9a5..d8059c1ea9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeStampedRecord.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/TimeStampedRecord.java
@@ -11,8 +11,15 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType
* Many of the subclasses of this class only override the opcode.
*/
abstract public class TimeStampedRecord extends Record {
- //private final static String TAG = "TimeStampedRecord";
+
+ // private final static String TAG = "TimeStampedRecord";
private final static boolean DEBUG_TIMESTAMPEDRECORD = false;
+ protected PumpTimeStamp timestamp;
+
+
+ public TimeStampedRecord() {
+ timestamp = new PumpTimeStamp();
+ }
@Override
@@ -26,14 +33,6 @@ abstract public class TimeStampedRecord extends Record {
}
- protected PumpTimeStamp timestamp;
-
-
- public TimeStampedRecord() {
- timestamp = new PumpTimeStamp();
- }
-
-
@Override
public PumpTimeStamp getTimestamp() {
return timestamp;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmClockReminderPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmClockReminderPumpEvent.java
index 6c8f172769..915bcf570a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmClockReminderPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmClockReminderPumpEvent.java
@@ -10,11 +10,13 @@ public class AlarmClockReminderPumpEvent extends TimeStampedRecord {
public AlarmClockReminderPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Alarm Reminder";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmSensorPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmSensorPumpEvent.java
index a57832cc2e..abb57be3da 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmSensorPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/AlarmSensorPumpEvent.java
@@ -1,25 +1,28 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
/**
* Created by geoff on 6/5/16.
*/
public class AlarmSensorPumpEvent extends TimeStampedRecord {
+
public AlarmSensorPumpEvent() {
}
+
@Override
public int getLength() {
return 8;
}
+
@Override
public String getShortTypeName() {
return "Alarm Sensor";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BGReceivedPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BGReceivedPumpEvent.java
index e9f46ab6ae..1538eba683 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BGReceivedPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BGReceivedPumpEvent.java
@@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import android.os.Bundle;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
@@ -8,6 +7,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class BGReceivedPumpEvent extends TimeStampedRecord {
+
private int amount = 0;
private byte[] meter = new byte[3];
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BasalProfileStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BasalProfileStart.java
index 2427237a59..3ee75888e7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BasalProfileStart.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BasalProfileStart.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class BasalProfileStart extends TimeStampedRecord {
+
private static final String TAG = "BasalProfileStart";
private int offset = 0;
private double rate = 0.0;
@@ -36,7 +37,7 @@ public class BasalProfileStart extends TimeStampedRecord {
profileIndex = asUINT8(data[1]);
offset = asUINT8(data[7]) * 30 * 1000 * 60;
- rate = (double) (asUINT8(data[8])) / 40.0;
+ rate = (double)(asUINT8(data[8])) / 40.0;
return true;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BatteryPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BatteryPumpEvent.java
index 460e812cce..6fb9324287 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BatteryPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BatteryPumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class BatteryPumpEvent extends TimeStampedRecord {
+
public BatteryPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Battery";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusNormalPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusNormalPumpEvent.java
index c4ab31b916..1021895840 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusNormalPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusNormalPumpEvent.java
@@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import android.os.Bundle;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.PumpTimeStamp;
@@ -9,6 +8,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class BolusNormalPumpEvent extends TimeStampedRecord {
+
private final static String TAG = "BolusNormalPumpEvent";
private double programmedAmount = 0.0;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusWizardBolusEstimatePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusWizardBolusEstimatePumpEvent.java
index 2667fe1428..5dc4d4c0de 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusWizardBolusEstimatePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/BolusWizardBolusEstimatePumpEvent.java
@@ -20,7 +20,7 @@ public class BolusWizardBolusEstimatePumpEvent extends TimeStampedRecord {
public BolusWizardBolusEstimatePumpEvent() {
- correctionEstimate = (double) 0.0;
+ correctionEstimate = (double)0.0;
bloodGlucose = 0;
carbohydrates = 0;
carbRatio = 0.0;
@@ -141,24 +141,24 @@ public class BolusWizardBolusEstimatePumpEvent extends TimeStampedRecord {
carbohydrates = (asUINT8(data[8]) & 0x0c << 6) + asUINT8(data[7]);
bloodGlucose = (asUINT8(data[8]) & 0x03 << 8) + asUINT8(data[1]);
foodEstimate = insulinDecode(asUINT8(data[14]), asUINT8(data[15]));
- correctionEstimate = (double) ((asUINT8(data[16]) & 0b111000) << 5 + asUINT8(data[13])) / 40.0;
+ correctionEstimate = (double)((asUINT8(data[16]) & 0b111000) << 5 + asUINT8(data[13])) / 40.0;
bolusEstimate = insulinDecode(asUINT8(data[19]), asUINT8(data[20]));
unabsorbedInsulinTotal = insulinDecode(asUINT8(data[17]), asUINT8(data[18]));
bgTargetLow = asUINT8(data[12]);
bgTargetHigh = asUINT8(data[21]);
insulinSensitivity = asUINT8(data[11]);
- carbRatio = (double) (((asUINT8(data[9]) & 0x07) << 8) + asUINT8(data[10])) / 40.0;
+ carbRatio = (double)(((asUINT8(data[9]) & 0x07) << 8) + asUINT8(data[10])) / 40.0;
} else {
carbohydrates = asUINT8(data[7]);
bloodGlucose = ((asUINT8(data[8]) & 0x03) << 8) + asUINT8(data[1]);
- foodEstimate = (double) (asUINT8(data[13])) / 10.0;
- correctionEstimate = (double) ((asUINT8(data[14]) << 8) + asUINT8(data[12])) / 10.0;
- bolusEstimate = (double) (asUINT8(data[18])) / 10.0;
- unabsorbedInsulinTotal = (double) (asUINT8(data[16])) / 10.0;
+ foodEstimate = (double)(asUINT8(data[13])) / 10.0;
+ correctionEstimate = (double)((asUINT8(data[14]) << 8) + asUINT8(data[12])) / 10.0;
+ bolusEstimate = (double)(asUINT8(data[18])) / 10.0;
+ unabsorbedInsulinTotal = (double)(asUINT8(data[16])) / 10.0;
bgTargetLow = asUINT8(data[11]);
bgTargetHigh = asUINT8(data[19]);
insulinSensitivity = asUINT8(data[10]);
- carbRatio = (double) asUINT8(data[9]);
+ carbRatio = (double)asUINT8(data[9]);
}
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/CalBgForPhPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/CalBgForPhPumpEvent.java
index a72d06c9e4..970ee66367 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/CalBgForPhPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/CalBgForPhPumpEvent.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class CalBgForPhPumpEvent extends TimeStampedRecord {
+
private int amount = 0;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmClockEnablePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmClockEnablePumpEvent.java
index 674e11dbbd..a0cf5722d0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmClockEnablePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmClockEnablePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeAlarmClockEnablePumpEvent extends TimeStampedRecord {
+
public ChangeAlarmClockEnablePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Alarm Clock Enable";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmNotifyModePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmNotifyModePumpEvent.java
index a0b8608107..9962132550 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmNotifyModePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAlarmNotifyModePumpEvent.java
@@ -3,18 +3,20 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ChangeAlarmNotifyModePumpEvent extends TimeStampedRecord {
+
public ChangeAlarmNotifyModePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Alarm Notify Mode";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAudioBolusPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAudioBolusPumpEvent.java
index 8e33cab0f7..fddf57b5d5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAudioBolusPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeAudioBolusPumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeAudioBolusPumpEvent extends TimeStampedRecord {
+
public ChangeAudioBolusPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Audio Bolus";
}
+
@Override
public boolean isAAPSRelevant() {
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBGReminderEnablePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBGReminderEnablePumpEvent.java
index c6c897a423..79ec26f5df 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBGReminderEnablePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBGReminderEnablePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeBGReminderEnablePumpEvent extends TimeStampedRecord {
+
public ChangeBGReminderEnablePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch BG Rmndr Enable";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePatternPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePatternPumpEvent.java
index 9e4ed1c39f..1f1f9ec05a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePatternPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePatternPumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeBasalProfilePatternPumpEvent extends TimeStampedRecord {
+
public ChangeBasalProfilePatternPumpEvent() {
}
+
@Override
public int getLength() {
return 152;
}
+
@Override
public String getShortTypeName() {
return "Ch Basal Prof Pat";
}
+
@Override
public boolean isAAPSRelevant() {
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePumpEvent.java
index 60bf5c1a68..a32a1f3681 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBasalProfilePumpEvent.java
@@ -3,19 +3,23 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ChangeBasalProfilePumpEvent extends TimeStampedRecord {
+
public ChangeBasalProfilePumpEvent() {
}
+
@Override
public int getLength() {
return 152;
}
+
@Override
public String getShortTypeName() {
return "Ch Basal Profile";
}
+
@Override
public boolean isAAPSRelevant() {
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderEnablePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderEnablePumpEvent.java
index 7a833b3a5b..e1959eba02 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderEnablePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderEnablePumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeBolusReminderEnablePumpEvent extends TimeStampedRecord {
+
public ChangeBolusReminderEnablePumpEvent() {
}
+
@Override
public int getLength() {
return 9;
}
+
@Override
public String getShortTypeName() {
return "Ch Bolus Rmndr Enable";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderTimePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderTimePumpEvent.java
index e368bc91a7..dca6b3be04 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderTimePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusReminderTimePumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeBolusReminderTimePumpEvent extends TimeStampedRecord {
+
public ChangeBolusReminderTimePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Bolus Rmndr Time";
}
+
@Override
public int getLength() {
return 9;
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusScrollStepSizePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusScrollStepSizePumpEvent.java
index 0305bb5bf2..1be80a3029 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusScrollStepSizePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusScrollStepSizePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeBolusScrollStepSizePumpEvent extends TimeStampedRecord {
+
public ChangeBolusScrollStepSizePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Bolus Scroll SS";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusWizardSetupPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusWizardSetupPumpEvent.java
index c279cb611c..1d2b8e6d28 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusWizardSetupPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeBolusWizardSetupPumpEvent.java
@@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ChangeBolusWizardSetupPumpEvent extends TimeStampedRecord {
@@ -8,16 +7,19 @@ public class ChangeBolusWizardSetupPumpEvent extends TimeStampedRecord {
public ChangeBolusWizardSetupPumpEvent() {
}
+
@Override
public int getLength() {
return 144;
}
+
@Override
public String getShortTypeName() {
return "Ch Bolus Wizard Setup";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCaptureEventEnablePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCaptureEventEnablePumpEvent.java
index eeba52e308..0624df5d54 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCaptureEventEnablePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCaptureEventEnablePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeCaptureEventEnablePumpEvent extends TimeStampedRecord {
+
public ChangeCaptureEventEnablePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Capture Event Ena";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCarbUnitsPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCarbUnitsPumpEvent.java
index ddfda6dc53..97e11fb805 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCarbUnitsPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeCarbUnitsPumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeCarbUnitsPumpEvent extends TimeStampedRecord {
+
public ChangeCarbUnitsPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Carb Units";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeChildBlockEnablePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeChildBlockEnablePumpEvent.java
index 846845e7d6..1e88972777 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeChildBlockEnablePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeChildBlockEnablePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeChildBlockEnablePumpEvent extends TimeStampedRecord {
+
public ChangeChildBlockEnablePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Child Block Ena";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeMaxBolusPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeMaxBolusPumpEvent.java
index 0efd7b7773..15645abed4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeMaxBolusPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeMaxBolusPumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeMaxBolusPumpEvent extends TimeStampedRecord {
+
public ChangeMaxBolusPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Max Bolux";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeOtherDeviceIDPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeOtherDeviceIDPumpEvent.java
index 5162277a7d..c2732106f5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeOtherDeviceIDPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeOtherDeviceIDPumpEvent.java
@@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ChangeOtherDeviceIDPumpEvent extends TimeStampedRecord {
@@ -8,16 +7,19 @@ public class ChangeOtherDeviceIDPumpEvent extends TimeStampedRecord {
public ChangeOtherDeviceIDPumpEvent() {
}
+
@Override
public int getLength() {
return 37;
}
+
@Override
public String getShortTypeName() {
return "Ch Other Dev ID";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeReservoirWarningTimePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeReservoirWarningTimePumpEvent.java
index 90aed32993..d17f6e47d8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeReservoirWarningTimePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeReservoirWarningTimePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeReservoirWarningTimePumpEvent extends TimeStampedRecord {
+
public ChangeReservoirWarningTimePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Res Warn Time";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorRateOfChangeAlertSetupPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorRateOfChangeAlertSetupPumpEvent.java
index 5c9de976f3..0432f9044c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorRateOfChangeAlertSetupPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorRateOfChangeAlertSetupPumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeSensorRateOfChangeAlertSetupPumpEvent extends TimeStampedRecord {
+
public ChangeSensorRateOfChangeAlertSetupPumpEvent() {
}
+
@Override
public int getLength() {
return 12;
}
+
@Override
public String getShortTypeName() {
return "Ch Sensor ROC Alert";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorSetup2PumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorSetup2PumpEvent.java
index 82e6d1b414..edd9b0152c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorSetup2PumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeSensorSetup2PumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeSensorSetup2PumpEvent extends TimeStampedRecord {
+
public ChangeSensorSetup2PumpEvent() {
}
+
@Override
public int getLength() {
return 37;
}
+
@Override
public String getShortTypeName() {
return "Ch Sensor Setup2";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTempBasalTypePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTempBasalTypePumpEvent.java
index c418a8ad5f..72edcd8794 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTempBasalTypePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTempBasalTypePumpEvent.java
@@ -9,6 +9,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType
* Created by geoff on 6/5/16.
*/
public class ChangeTempBasalTypePumpEvent extends TimeStampedRecord {
+
private boolean isPercent = false; // either absolute or percent
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimeFormatPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimeFormatPumpEvent.java
index a971742ceb..cb5f38cc77 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimeFormatPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimeFormatPumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ChangeTimeFormatPumpEvent extends TimeStampedRecord {
+
public ChangeTimeFormatPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Time Format";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimePumpEvent.java
index b330e76198..c18913c0f0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeTimePumpEvent.java
@@ -1,23 +1,26 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ChangeTimePumpEvent extends TimeStampedRecord {
+
public ChangeTimePumpEvent() {
}
+
@Override
public int getLength() {
return 14;
}
+
@Override
public String getShortTypeName() {
return "Change Time";
}
+
@Override
public boolean isAAPSRelevant() {
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeVariableBolusPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeVariableBolusPumpEvent.java
index 4124b1e5ca..008d9fa48c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeVariableBolusPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeVariableBolusPumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeVariableBolusPumpEvent extends TimeStampedRecord {
+
public ChangeVariableBolusPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Var. Bolus";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogEnablePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogEnablePumpEvent.java
index 7d1c952173..d0123e42ab 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogEnablePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogEnablePumpEvent.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeWatchdogEnablePumpEvent extends TimeStampedRecord {
+
public ChangeWatchdogEnablePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Ch Watchdog Enable";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogMarriageProfilePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogMarriageProfilePumpEvent.java
index 6c599f197e..a75e860f3c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogMarriageProfilePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ChangeWatchdogMarriageProfilePumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class ChangeWatchdogMarriageProfilePumpEvent extends TimeStampedRecord {
+
public ChangeWatchdogMarriageProfilePumpEvent() {
}
+
@Override
public int getLength() {
return 12;
}
+
@Override
public String getShortTypeName() {
return "Ch WD Marriage";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ClearAlarmPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ClearAlarmPumpEvent.java
index a936f40563..2f5deea19d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ClearAlarmPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ClearAlarmPumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ClearAlarmPumpEvent extends TimeStampedRecord {
+
public ClearAlarmPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Clear Alarm";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteAlarmClockTimePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteAlarmClockTimePumpEvent.java
index f3df1e89b4..d318167fc1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteAlarmClockTimePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteAlarmClockTimePumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class DeleteAlarmClockTimePumpEvent extends TimeStampedRecord {
+
public DeleteAlarmClockTimePumpEvent() {
}
+
@Override
public int getLength() {
return 14;
}
+
@Override
public String getShortTypeName() {
return "Del Alarm Clock Time";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteBolusReminderTimePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteBolusReminderTimePumpEvent.java
index f874aa54a7..816500bbb6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteBolusReminderTimePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteBolusReminderTimePumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class DeleteBolusReminderTimePumpEvent extends TimeStampedRecord {
+
public DeleteBolusReminderTimePumpEvent() {
}
+
@Override
public int getLength() {
return 9;
}
+
@Override
public String getShortTypeName() {
return "Del Bolus Rmndr Time";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteOtherDeviceIDPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteOtherDeviceIDPumpEvent.java
index 133b48ebdd..c30e85eae3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteOtherDeviceIDPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/DeleteOtherDeviceIDPumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class DeleteOtherDeviceIDPumpEvent extends TimeStampedRecord {
+
public DeleteOtherDeviceIDPumpEvent() {
}
+
@Override
public int getLength() {
return 12;
}
+
@Override
public String getShortTypeName() {
return "Del Other Dev ID";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/EnableDisableRemotePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/EnableDisableRemotePumpEvent.java
index 48e1badb00..0ca04b02f9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/EnableDisableRemotePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/EnableDisableRemotePumpEvent.java
@@ -1,22 +1,25 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class EnableDisableRemotePumpEvent extends TimeStampedRecord {
+
public EnableDisableRemotePumpEvent() {
}
+
@Override
public int getLength() {
return 21;
}
+
@Override
public String getShortTypeName() {
return "Toggle Remote";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/IgnoredHistoryEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/IgnoredHistoryEntry.java
index 182b6d1529..b2228aa05f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/IgnoredHistoryEntry.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/IgnoredHistoryEntry.java
@@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType
public class IgnoredHistoryEntry extends Record {
- //public int lngth = 7;
+ // public int lngth = 7;
private RecordTypeEnum typeEnum = RecordTypeEnum.Null;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/InsulinMarkerEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/InsulinMarkerEvent.java
index fa730bda7e..97b7ac5855 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/InsulinMarkerEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/InsulinMarkerEvent.java
@@ -6,24 +6,29 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 7/16/16.
*/
public class InsulinMarkerEvent extends TimeStampedRecord {
+
public InsulinMarkerEvent() {
}
+
@Override
public int getLength() {
return 8;
}
+
/*
- Darrell Wright:
- it is a manual entry of a bolus that the pump didn't deliver, so opcode, timestamp and at least a number to represent the units of insulin
- */
+ * Darrell Wright:
+ * it is a manual entry of a bolus that the pump didn't deliver, so opcode, timestamp and at least a number to
+ * represent the units of insulin
+ */
@Override
public String getShortTypeName() {
return "UnknownInsulin";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryExerciseMarkerPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryExerciseMarkerPumpEvent.java
index e0a519f66e..1a76a4843e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryExerciseMarkerPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryExerciseMarkerPumpEvent.java
@@ -6,19 +6,23 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 6/5/16.
*/
public class JournalEntryExerciseMarkerPumpEvent extends TimeStampedRecord {
+
public JournalEntryExerciseMarkerPumpEvent() {
}
+
@Override
public int getLength() {
return 8;
}
+
@Override
public String getShortTypeName() {
return "Exercise Marker";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowBatteryPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowBatteryPumpEvent.java
index a681ffe1dd..4a3ee07ec9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowBatteryPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowBatteryPumpEvent.java
@@ -7,11 +7,13 @@ public class JournalEntryPumpLowBatteryPumpEvent extends TimeStampedRecord {
public JournalEntryPumpLowBatteryPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Low Battery";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowReservoirPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowReservoirPumpEvent.java
index 60c08ab348..c2d347aa3e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowReservoirPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/JournalEntryPumpLowReservoirPumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class JournalEntryPumpLowReservoirPumpEvent extends TimeStampedRecord {
+
public JournalEntryPumpLowReservoirPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Low Reservoir";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Model522ResultTotalsPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Model522ResultTotalsPumpEvent.java
index 81b2bf62f3..86d344335d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Model522ResultTotalsPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Model522ResultTotalsPumpEvent.java
@@ -3,24 +3,29 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class Model522ResultTotalsPumpEvent extends TimeStampedRecord {
+
public Model522ResultTotalsPumpEvent() {
}
+
@Override
public int getDatestampOffset() {
return 1;
}
+
@Override
public int getLength() {
return 44;
}
+
@Override
public String getShortTypeName() {
return "M522 Result Totals";
}
+
@Override
public boolean isAAPSRelevant() {
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/NewTimeSet.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/NewTimeSet.java
index 9fd85b67a3..071dc6615a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/NewTimeSet.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/NewTimeSet.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType
// This event existed as 0x18 in Roundtrip and early Decocare,
// but I don't see a corresponding event in RileyLink_ios.
public class NewTimeSet extends TimeStampedRecord {
+
public NewTimeSet() {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PrimePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PrimePumpEvent.java
index 79b4d1b538..50d5cdd590 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PrimePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PrimePumpEvent.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import android.os.Bundle;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class PrimePumpEvent extends TimeStampedRecord {
+
private double amount = 0.0;
private double programmedAmount = 0.0;
private String primeType = "unknown";
@@ -33,8 +33,8 @@ public class PrimePumpEvent extends TimeStampedRecord {
if (!simpleParse(data, 5)) {
return false;
}
- amount = (double) (asUINT8(data[4]) << 2) / 40.0;
- programmedAmount = (double) (asUINT8(data[2]) << 2) / 40.0;
+ amount = (double)(asUINT8(data[4]) << 2) / 40.0;
+ programmedAmount = (double)(asUINT8(data[2]) << 2) / 40.0;
primeType = programmedAmount == 0 ? "manual" : "fixed";
return true;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PumpAlarmPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PumpAlarmPumpEvent.java
index ff9ca9949c..fd962cd445 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PumpAlarmPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/PumpAlarmPumpEvent.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import android.os.Bundle;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class PumpAlarmPumpEvent extends TimeStampedRecord {
+
private int rawtype = 0;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResultDailyTotalPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResultDailyTotalPumpEvent.java
index 97f113a9ce..0ec39d4be6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResultDailyTotalPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResultDailyTotalPumpEvent.java
@@ -5,6 +5,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeFo
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ResultDailyTotalPumpEvent extends TimeStampedRecord {
+
private static final String TAG = "ResultDailyTotalPumpEvent";
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResumePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResumePumpEvent.java
index 32b72097a8..5646e2c829 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResumePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/ResumePumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class ResumePumpEvent extends TimeStampedRecord {
+
public ResumePumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Resume";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/RewindPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/RewindPumpEvent.java
index c307466427..759105c24f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/RewindPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/RewindPumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class RewindPumpEvent extends TimeStampedRecord {
+
public RewindPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Rewind";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Sara6EPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Sara6EPumpEvent.java
index 10a69750d5..3465acd8ef 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Sara6EPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Sara6EPumpEvent.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class Sara6EPumpEvent extends TimeStampedRecord {
+
public Sara6EPumpEvent() {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/SuspendPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/SuspendPumpEvent.java
index 7ddd57a108..bdd9eace7b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/SuspendPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/SuspendPumpEvent.java
@@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.recor
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
public class SuspendPumpEvent extends TimeStampedRecord {
+
public SuspendPumpEvent() {
}
+
@Override
public String getShortTypeName() {
return "Suspend";
}
+
@Override
public boolean isAAPSRelevant() {
return true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalDurationPumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalDurationPumpEvent.java
index 633a60f35e..4625d40bfe 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalDurationPumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalDurationPumpEvent.java
@@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class TempBasalDurationPumpEvent extends TimeStampedRecord {
+
private int durationMinutes = 0;
@@ -53,5 +54,4 @@ public class TempBasalDurationPumpEvent extends TimeStampedRecord {
return true;
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalRatePumpEvent.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalRatePumpEvent.java
index 13440a798f..fa65c77e12 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalRatePumpEvent.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/TempBasalRatePumpEvent.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
-
import android.os.Bundle;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeStampedRecord;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class TempBasalRatePumpEvent extends TimeStampedRecord {
+
private double basalRate = 0.0; // rate in Units/hr
private boolean mIsPercent = false; // The value is either an absolute number or a percentage
@@ -44,7 +44,7 @@ public class TempBasalRatePumpEvent extends TimeStampedRecord {
}
if ((asUINT8(data[7]) >> 3) == 0) {
mIsPercent = false;
- basalRate = (double) (asUINT8(data[1])) / 40.0;
+ basalRate = (double)(asUINT8(data[1])) / 40.0;
} else {
mIsPercent = true;
basalRate = asUINT8(data[1]);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/UnabsorbedInsulin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/UnabsorbedInsulin.java
index 140a938e27..d6b2f7a405 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/UnabsorbedInsulin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/UnabsorbedInsulin.java
@@ -1,20 +1,25 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.record;
+import java.util.ArrayList;
import android.os.Bundle;
import android.util.Log;
-import java.util.ArrayList;
-
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.Record;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
public class UnabsorbedInsulin extends Record {
+
private static final String TAG = "UnabsorbedInsulin";
+ ArrayList records = new ArrayList<>();
private int length = 2;
+ public UnabsorbedInsulin() {
+ }
+
+
@Override
public int getLength() {
return length; /* this is a variable sized record */
@@ -27,24 +32,6 @@ public class UnabsorbedInsulin extends Record {
}
- class UnabsorbedInsulinRecord {
- public double amount = 0.0;
- public int age = 0;
-
-
- public UnabsorbedInsulinRecord(double amount, int age) {
- this.amount = amount;
- this.age = age;
- }
- }
-
- ArrayList records = new ArrayList<>();
-
-
- public UnabsorbedInsulin() {
- }
-
-
@Override
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
if (data.length < 2) {
@@ -59,8 +46,8 @@ public class UnabsorbedInsulin extends Record {
}
int numRecords = (asUINT8(data[1]) - 2) / 3;
- for(int i = 0; i < numRecords; i++) {
- double amount = (double) (asUINT8(data[2 + (i * 3)])) / 40.0;
+ for (int i = 0; i < numRecords; i++) {
+ double amount = (double)(asUINT8(data[2 + (i * 3)])) / 40.0;
int age = asUINT8(data[3 + (i * 3)]) + (((asUINT8(data[4 + (i * 3)])) & 0b110000) << 4);
records.add(new UnabsorbedInsulinRecord(amount, age));
}
@@ -78,7 +65,7 @@ public class UnabsorbedInsulin extends Record {
} else if (storedAges.length != storedAmounts.length) {
Log.e(TAG, "readFromBundle: failed to load from bundle: array size mismatch");
} else {
- for(int i = 0; i < storedAges.length; i++) {
+ for (int i = 0; i < storedAges.length; i++) {
records.add(new UnabsorbedInsulinRecord(storedAmounts[i], storedAges[i]));
}
}
@@ -88,12 +75,12 @@ public class UnabsorbedInsulin extends Record {
@Override
public void writeToBundle(Bundle in) {
- // Use parallel arrays to serialize the data. Note there is a small loss
+ // Use parallel arrays to serialize the data. Note there is a small loss
// of precision when going from double to float.
float[] storedAmounts = new float[records.size()];
int[] storedAges = new int[records.size()];
- for(int i = 0; i < records.size(); i++) {
- storedAmounts[i] = (float) records.get(i).amount;
+ for (int i = 0; i < records.size(); i++) {
+ storedAmounts[i] = (float)records.get(i).amount;
storedAges[i] = records.get(i).age;
}
in.putFloatArray("amounts", storedAmounts);
@@ -108,4 +95,16 @@ public class UnabsorbedInsulin extends Record {
public boolean isAAPSRelevant() {
return true;
}
+
+ class UnabsorbedInsulinRecord {
+
+ public double amount = 0.0;
+ public int age = 0;
+
+
+ public UnabsorbedInsulinRecord(double amount, int age) {
+ this.amount = amount;
+ this.age = age;
+ }
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Unknown7ByteEvent1.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Unknown7ByteEvent1.java
index afb76ec838..6afd675313 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Unknown7ByteEvent1.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history/record/Unknown7ByteEvent1.java
@@ -6,14 +6,17 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history.TimeSt
* Created by geoff on 7/16/16.
*/
public class Unknown7ByteEvent1 extends TimeStampedRecord {
+
public Unknown7ByteEvent1() {
}
+
@Override
public String getShortTypeName() {
return "Unknown7Byte1";
}
+
@Override
public boolean isAAPSRelevant() {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryDecoder.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryDecoder.java
index c6b5e5a61e..7c16ca14af 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryDecoder.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryDecoder.java
@@ -1,42 +1,36 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history2;
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.RawHistoryPage;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
/**
- * Application: GGC - GNU Gluco Control
- * Plug-in: GGC PlugIn Base (base class for all plugins)
+ * Application: GGC - GNU Gluco Control
+ * Plug-in: GGC PlugIn Base (base class for all plugins)
*
* See AUTHORS for copyright information.
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Filename: DeviceIdentification
- * Description: Class for display of Device Identification.
+ * Filename: DeviceIdentification Description: Class for display of Device Identification.
*
* Author: Andy {andy@atech-software.com}
*/
@@ -62,11 +56,10 @@ public abstract class MedtronicHistoryDecoder {
public abstract void postProcess();
- //public abstract void refreshOutputWriter();
-
+ // public abstract void refreshOutputWriter();
public boolean decodePage(RawHistoryPage dataPage) throws Exception {
- //refreshOutputWriter();
+ // refreshOutputWriter();
List extends MedtronicHistoryEntry> minimedHistoryRecords = processPageAndCreateRecords(dataPage);
@@ -88,8 +81,9 @@ public abstract class MedtronicHistoryDecoder {
public List checkPage(RawHistoryPage page) throws RuntimeException {
List byteList = new ArrayList();
- if (page.getData().length != 1024 /*page.commandType.getRecordLength()*/) {
- LOG.error("Page size is not correct. Size should be {}, but it was {} instead.", 1024, page.getData().length);
+ if (page.getData().length != 1024 /* page.commandType.getRecordLength() */) {
+ LOG.error("Page size is not correct. Size should be {}, but it was {} instead.", 1024,
+ page.getData().length);
// throw exception perhaps
return byteList;
}
@@ -107,11 +101,13 @@ public abstract class MedtronicHistoryDecoder {
}
- public abstract List extends MedtronicHistoryEntry> processPageAndCreateRecords(RawHistoryPage page) throws Exception;
+ public abstract List extends MedtronicHistoryEntry> processPageAndCreateRecords(RawHistoryPage page)
+ throws Exception;
protected void prepareStatistics() {
- if (!statisticsEnabled) return;
+ if (!statisticsEnabled)
+ return;
unknownOpCodes = new HashMap();
mapStatistics = new HashMap>();
@@ -123,7 +119,8 @@ public abstract class MedtronicHistoryDecoder {
protected void addToStatistics(MedtronicHistoryEntry pumpHistoryEntry, RecordDecodeStatus status, Integer opCode) {
- if (!statisticsEnabled) return;
+ if (!statisticsEnabled)
+ return;
if (opCode != null) {
if (!unknownOpCodes.containsKey(opCode)) {
@@ -155,7 +152,8 @@ public abstract class MedtronicHistoryDecoder {
sb = new StringBuilder();
if (entry.getKey() != RecordDecodeStatus.OK) {
- if (entry.getValue().size() == 0) continue;
+ if (entry.getValue().size() == 0)
+ continue;
for (Map.Entry entrysub : entry.getValue().entrySet()) {
StringUtil.appendToStringBuilder(sb, entrysub.getKey(), ", ");
@@ -163,7 +161,8 @@ public abstract class MedtronicHistoryDecoder {
String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length());
- LOG.debug(" {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString());
+ LOG.debug(" {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(),
+ sb.toString());
} else {
LOG.debug(" {} - {}", entry.getKey().name(), entry.getValue().size());
}
@@ -172,14 +171,18 @@ public abstract class MedtronicHistoryDecoder {
private int getUnsignedByte(byte value) {
- if (value < 0) return value + 256;
- else return value;
+ if (value < 0)
+ return value + 256;
+ else
+ return value;
}
protected int getUnsignedInt(int value) {
- if (value < 0) return value + 256;
- else return value;
+ if (value < 0)
+ return value + 256;
+ else
+ return value;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryEntry.java
index f5605a6889..a472daf842 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryEntry.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicHistoryEntry.java
@@ -1,36 +1,30 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history2;
+import java.util.List;
import org.joda.time.LocalDateTime;
-import java.util.List;
-
import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.data.dto.PumpTimeStampedRecord;
/**
- * Application: GGC - GNU Gluco Control
- * Plug-in: GGC PlugIn Base (base class for all plugins)
+ * Application: GGC - GNU Gluco Control
+ * Plug-in: GGC PlugIn Base (base class for all plugins)
*
* See AUTHORS for copyright information.
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Filename: MinimedHistoryRecord
- * Description: Minimed History Record.
+ * Filename: MinimedHistoryRecord Description: Minimed History Record.
*
* Author: Andy {andy@atech-software.com}
*/
@@ -59,14 +53,14 @@ public abstract class MedtronicHistoryEntry {
return;
head = new byte[getHeadLength() - 1];
- for(int i = 1; i < (getHeadLength()); i++) {
+ for (int i = 1; i < (getHeadLength()); i++) {
head[i - 1] = listRawData.get(i);
}
if (getDateTimeLength() > 0) {
datetime = new byte[getDateTimeLength()];
- for(int i = getHeadLength(), j = 0; j < getDateTimeLength(); i++, j++) {
+ for (int i = getHeadLength(), j = 0; j < getDateTimeLength(); i++, j++) {
datetime[j] = listRawData.get(i);
}
}
@@ -74,7 +68,7 @@ public abstract class MedtronicHistoryEntry {
if (getBodyLength() > 0) {
body = new byte[getBodyLength()];
- for(int i = (getHeadLength() + getDateTimeLength()), j = 0; j < getBodyLength(); i++, j++) {
+ for (int i = (getHeadLength() + getDateTimeLength()), j = 0; j < getBodyLength(); i++, j++) {
body[j] = listRawData.get(i);
}
@@ -188,13 +182,13 @@ public abstract class MedtronicHistoryEntry {
}
- public void setLocalDateTime(LocalDateTime atdate) {
- this.dateTime = atdate;
+ public LocalDateTime getLocalDateTime() {
+ return this.dateTime;
}
- public LocalDateTime getLocalDateTime() {
- return this.dateTime;
+ public void setLocalDateTime(LocalDateTime atdate) {
+ this.dateTime = atdate;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicPumpHistoryDecoder.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicPumpHistoryDecoder.java
index 598f4b1364..1d55b7a71d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicPumpHistoryDecoder.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/MedtronicPumpHistoryDecoder.java
@@ -1,14 +1,13 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history2;
-
-import android.util.Log;
+import java.util.ArrayList;
+import java.util.List;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
+import android.util.Log;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
@@ -21,27 +20,22 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpBolusType;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
/**
- * Application: GGC - GNU Gluco Control
- * Plug-in: GGC PlugIn Base (base class for all plugins)
+ * Application: GGC - GNU Gluco Control
+ * Plug-in: GGC PlugIn Base (base class for all plugins)
*
* See AUTHORS for copyright information.
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Filename: MedtronicPumpHistoryDecoder
- * Description: Decoder for history data.
+ * Filename: MedtronicPumpHistoryDecoder Description: Decoder for history data.
*
* Author: Andy {andy@atech-software.com}
*/
@@ -51,10 +45,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpHistoryDecoder.class);
private static final String TAG = "MdtPumpHistoryDecoder";
- //PumpValuesWriter pumpValuesWriter = null;
+ // PumpValuesWriter pumpValuesWriter = null;
// DataAccessPlugInBase dataAccess = DataAccessPump.getInstance();
-
+ BolusDTO bolusEntry;
+ PumpHistoryEntry pumpHistoryEntry4BolusEntry;
// Temporary records for processing
private PumpHistoryEntry tbrPreviousRecord;
private PumpHistoryEntry changeTimeRecord;
@@ -87,7 +82,6 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
boolean special = false;
incompletePacket = false;
-
if (opCode == 0) {
counter++;
if (skipped == null)
@@ -115,17 +109,17 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
}
List listRawData = new ArrayList();
- listRawData.add((byte) opCode);
+ listRawData.add((byte)opCode);
if (entryType == PumpHistoryEntryType.UnabsorbedInsulin) {
int elements = dataClear.get(counter);
- listRawData.add((byte) elements);
+ listRawData.add((byte)elements);
counter++;
int els = getUnsignedInt(elements);
for (int k = 0; k < (els - 2); k++) {
- listRawData.add((byte) dataClear.get(counter));
+ listRawData.add((byte)dataClear.get(counter));
counter++;
}
@@ -138,16 +132,15 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
listRawData.add(dataClear.get(counter));
counter++;
} catch (Exception ex) {
- Log.e(TAG, "OpCode: " + HexDump.getCorrectHexValue((byte) opCode) + ", Invalid package: " + HexDump.toHexStringDisplayable(listRawData));
- //throw ex;
+ Log.e(TAG, "OpCode: " + HexDump.getCorrectHexValue((byte)opCode) + ", Invalid package: "
+ + HexDump.toHexStringDisplayable(listRawData));
+ // throw ex;
incompletePacket = true;
break;
}
-
}
-
if (incompletePacket)
break;
@@ -234,7 +227,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
public RecordDecodeStatus decodeRecord(MedtronicHistoryEntry entryIn) {
- PumpHistoryEntry precord = (PumpHistoryEntry) entryIn;
+ PumpHistoryEntry precord = (PumpHistoryEntry)entryIn;
try {
return decodeRecord(entryIn, false);
} catch (Exception ex) {
@@ -244,10 +237,23 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
}
+ // private void decodeCalBGForPH(PumpHistoryEntry entry) {
+ // int high = (entry.getDatetime()[4] & 0x80) >> 7;
+ // int bg = bitUtils.toInt(high, getUnsignedInt(entry.getHead()[0]));
+ //
+ // writeData(PumpBaseType.AdditionalData, PumpAdditionalDataType.BloodGlucose, "" + bg, entry.getATechDate());
+ // }
+
+ // masks = [ ( 0x80, 7), (0x40, 6), (0x20, 5), (0x10, 4) ]
+ // nibbles = [ ]
+ // for mask, shift in masks:
+ // nibbles.append( ( (year & mask) >> shift ) )
+ // return nibbles
+
public RecordDecodeStatus decodeRecord(MedtronicHistoryEntry entryIn, boolean x) {
// FIXME
// TODO
- PumpHistoryEntry entry = (PumpHistoryEntry) entryIn;
+ PumpHistoryEntry entry = (PumpHistoryEntry)entryIn;
if (entry.getDateTimeLength() > 0) {
decodeDateTime(entry);
@@ -257,40 +263,35 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
decodeDateTime(entry);
switch (entry.getEntryType()) {
- // not implemented
+ // not implemented
case ChangeBasalProfile_NewProfile:
case ChangeBasalProfile_OldProfile:
case SelectBasalProfile:
case DailyTotals522:
- //case IanA8:
+ // case IanA8:
case DailyTotals523:
case DailyTotals512:
return RecordDecodeStatus.NotSupported;
+ // WORK IN PROGRESS
- // WORK IN PROGRESS
-
- // POSSIBLY READY
+ // POSSIBLY READY
case BasalProfileStart:
return decodeBasalProfileStart(entry);
+ // AAPS Implementation - Not yet done
- // AAPS Implementation - Not yet done
+ // AAPS Implementation - OK entries
+ // AAPS events (Tbr, Bolus)
- // AAPS Implementation - OK entries
+ // AAPS alerts
- // AAPS events (Tbr, Bolus)
+ // AAPS TDDs
- // AAPS alerts
-
-
- // AAPS TDDs
-
-
- // AAPS Implementation - Ignored entries
+ // AAPS Implementation - Ignored entries
case CalBGForPH:
case ChangeRemoteId:
case ClearAlarm:
@@ -298,7 +299,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
case ToggleRemote:
case UnabsorbedInsulin:
case BGReceived: // Ian3F: CGMS
- case SensorAlert: // Ian08 CGMS
+ case SensorAlert: // Ian08 CGMS
case ChangeTempBasalType:
case ChangeTimeFormat:
case ChangeReservoirWarningTime:
@@ -367,8 +368,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// LOG.debug(" -- ignored Pump Entry: " + entry.getEntryType().name());
return RecordDecodeStatus.Ignored;
-
- // **** Implemented records ****
+ // **** Implemented records ****
case ChangeTime:
changeTimeRecord = entry;
@@ -378,7 +378,6 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
decodeChangeTime(entry);
return RecordDecodeStatus.OK;
-
case TempBasalDuration:
decodeTempBasal(entry);
return RecordDecodeStatus.OK;
@@ -404,26 +403,25 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
return RecordDecodeStatus.OK;
case LowBattery:
- //this.writeData(PumpBaseType.Event, PumpEventType.BatteryLow, entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.BatteryLow, entry.getATechDate());
return RecordDecodeStatus.OK;
case PumpSuspend:
- //this.writeData(PumpBaseType.Event, PumpEventType.BasalStop, entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.BasalStop, entry.getATechDate());
return RecordDecodeStatus.OK;
case PumpResume:
- //this.writeData(PumpBaseType.Event, PumpEventType.BasalRun, entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.BasalRun, entry.getATechDate());
return RecordDecodeStatus.OK;
case Rewind:
- //this.writeData(PumpBaseType.Event, PumpEventType.CartridgeRewind, entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.CartridgeRewind, entry.getATechDate());
return RecordDecodeStatus.OK;
-
case EventUnknown_MM522_0x05:
break;
case NoDeliveryAlarm:
- //this.writeData(PumpBaseType.Alarm, PumpAlarms.NoDelivery, entry.getATechDate());
+ // this.writeData(PumpBaseType.Alarm, PumpAlarms.NoDelivery, entry.getATechDate());
return RecordDecodeStatus.OK;
case BolusWizardBolusEstimate:
@@ -438,11 +436,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
case UnknownBasePacket:
return RecordDecodeStatus.Error;
- //case Andy0d:
+ // case Andy0d:
- //case Andy58:
+ // case Andy58:
- //case Andy90:
+ // case Andy90:
default: {
LOG.debug("Not supported: " + entry.getEntryType());
@@ -451,10 +449,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
}
-
return RecordDecodeStatus.Error;
-
}
@@ -463,32 +459,19 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
if (changeTimeRecord == null)
return;
- //String timeChange = String.format(PumpEventType.DateTimeChanged.getValueTemplate(), this.changeTimeRecord.getATechDate().getDateTimeString(), entry.getATechDate().getDateTimeString());
+ // String timeChange = String.format(PumpEventType.DateTimeChanged.getValueTemplate(),
+ // this.changeTimeRecord.getATechDate().getDateTimeString(), entry.getATechDate().getDateTimeString());
- //writeData(PumpBaseType.Event, PumpEventType.DateTimeChanged, timeChange, entry.getATechDate());
+ // writeData(PumpBaseType.Event, PumpEventType.DateTimeChanged, timeChange, entry.getATechDate());
this.changeTimeRecord = null;
}
- // private void decodeCalBGForPH(PumpHistoryEntry entry) {
- // int high = (entry.getDatetime()[4] & 0x80) >> 7;
- // int bg = bitUtils.toInt(high, getUnsignedInt(entry.getHead()[0]));
- //
- // writeData(PumpBaseType.AdditionalData, PumpAdditionalDataType.BloodGlucose, "" + bg, entry.getATechDate());
- // }
-
-
- // masks = [ ( 0x80, 7), (0x40, 6), (0x20, 5), (0x10, 4) ]
- // nibbles = [ ]
- // for mask, shift in masks:
- // nibbles.append( ( (year & mask) >> shift ) )
- // return nibbles
-
-
// FIXME
private void decodeBatteryActivity(PumpHistoryEntry entry) {
- //this.writeData(PumpBaseType.Event, entry.getHead()[0] == 0 ? PumpEventType.BatteryRemoved : PumpEventType.BatteryReplaced, entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, entry.getHead()[0] == 0 ? PumpEventType.BatteryRemoved :
+ // PumpEventType.BatteryReplaced, entry.getATechDate());
}
@@ -496,7 +479,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
private void decodeEndResultTotals(PumpHistoryEntry entry) {
float totals = bitUtils.toInt(entry.getHead()[2], entry.getHead()[3]) * 0.025f;
- //this.writeData(PumpBaseType.Report, PumpReport.InsulinTotalDay, getFormattedFloat(totals, 2), entry.getATechDate());
+ // this.writeData(PumpBaseType.Report, PumpReport.InsulinTotalDay, getFormattedFloat(totals, 2),
+ // entry.getATechDate());
}
@@ -508,15 +492,18 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
Float rate = null;
int index = body[2];
- if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
+ if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
+ MedtronicDeviceType.Medtronic_523andHigher)) {
rate = body[1] * 0.025f;
}
if (rate == null) {
- LOG.warn("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index, body);
+ LOG.warn("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index,
+ body);
return RecordDecodeStatus.Error;
} else {
- //writeData(PumpBaseType.Basal, PumpBasalType.ValueChange, getFormattedFloat(rate, 3), entry.getATechDate());
+ // writeData(PumpBaseType.Basal, PumpBasalType.ValueChange, getFormattedFloat(rate, 3),
+ // entry.getATechDate());
return RecordDecodeStatus.OK;
}
@@ -530,7 +517,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
float bolus_strokes = 10.0f;
- if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
+ if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
+ MedtronicDeviceType.Medtronic_523andHigher)) {
// https://github.com/ps2/minimed_rf/blob/master/lib/minimed_rf/log_entries/bolus_wizard.rb#L102
bolus_strokes = 40.0f;
@@ -541,19 +529,19 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// carb_ratio (?) = (((self.body[2] & 0x07) << 8) + self.body[3]) /
// 10.0s
dto.insulinSensitivity = new Float(body[4]);
- dto.bgTargetLow = (int) body[5];
- dto.bgTargetHigh = (int) body[14];
+ dto.bgTargetLow = (int)body[5];
+ dto.bgTargetHigh = (int)body[14];
dto.correctionEstimate = (((body[9] & 0x38) << 5) + body[6]) / bolus_strokes;
dto.foodEstimate = ((body[7] << 8) + body[8]) / bolus_strokes;
dto.unabsorbedInsulin = ((body[10] << 8) + body[11]) / bolus_strokes;
dto.bolusTotal = ((body[12] << 8) + body[13]) / bolus_strokes;
} else {
dto.bloodGlucose = (((body[1] & 0x0F) << 8) | entry.getHead()[0]);
- dto.carbs = (int) body[0];
+ dto.carbs = (int)body[0];
dto.carbRatio = new Float(body[2]);
dto.insulinSensitivity = new Float(body[3]);
- dto.bgTargetLow = (int) body[4];
- dto.bgTargetHigh = (int) body[12];
+ dto.bgTargetLow = (int)body[4];
+ dto.bgTargetHigh = (int)body[12];
dto.bolusTotal = body[11] / 10.0f;
dto.foodEstimate = body[6] / 10.0f;
dto.unabsorbedInsulin = body[9] / 10.0f;
@@ -563,7 +551,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
entry.setHistoryEntryDetails(dto);
- //this.writeData(PumpBaseType.Event, PumpEventType.BolusWizard, dto.getValue(), entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.BolusWizard, dto.getValue(), entry.getATechDate());
}
@@ -571,7 +559,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// FIXME
private void decodeLowReservoir(PumpHistoryEntry entry) {
float amount = (getUnsignedInt(entry.getHead()[0]) * 1.0f / 10.0f);
- //this.writeData(PumpBaseType.Event, PumpEventType.ReservoirLowDesc, getFormattedFloat(amount, 1), entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.ReservoirLowDesc, getFormattedFloat(amount, 1),
+ // entry.getATechDate());
}
@@ -580,7 +569,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
float amount = bitUtils.toInt(entry.getHead()[2], entry.getHead()[3]) / 10.0f;
float fixed = bitUtils.toInt(entry.getHead()[0], entry.getHead()[1]) / 10.0f;
- //this.writeData(PumpBaseType.Event, PumpEventType.PrimeInfusionSet, fixed > 0 ? getFormattedFloat(fixed, 1) : getFormattedFloat(amount, 1), entry.getATechDate());
+ // this.writeData(PumpBaseType.Event, PumpEventType.PrimeInfusionSet, fixed > 0 ? getFormattedFloat(fixed, 1) :
+ // getFormattedFloat(amount, 1), entry.getATechDate());
}
@@ -598,16 +588,13 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
}
- BolusDTO bolusEntry;
- PumpHistoryEntry pumpHistoryEntry4BolusEntry;
-
-
private void decodeBolus(PumpHistoryEntry entry) {
BolusDTO bolus = new BolusDTO();
byte[] data = entry.getHead();
- if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(), MedtronicDeviceType.Medtronic_523andHigher)) {
+ if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
+ MedtronicDeviceType.Medtronic_523andHigher)) {
bolus.setRequestedAmount(bitUtils.toInt(data[0], data[1]) / 40.0f);
bolus.setDeliveredAmount(bitUtils.toInt(data[2], data[3]) / 10.0f);
bolus.setInsulinOnBoard(bitUtils.toInt(data[4], data[5]) / 40.0f);
@@ -618,7 +605,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
bolus.setDuration(data[2] * 30);
}
- bolus.setBolusType((bolus.getDuration() != null && (bolus.getDuration() > 0)) ? PumpBolusType.Extended : PumpBolusType.Normal);
+ bolus.setBolusType((bolus.getDuration() != null && (bolus.getDuration() > 0)) ? PumpBolusType.Extended
+ : PumpBolusType.Normal);
bolus.setLocalDateTime(entry.getLocalDateTime());
if (bolusEntry != null) {
@@ -649,7 +637,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
private void writeBolus(PumpHistoryEntry pumpHistoryEntry, BolusDTO bolus) {
- //writeData(PumpBaseType.Bolus, bolus.getBolusType(), bolus.getValue(), bolus.getATechDate());
+ // writeData(PumpBaseType.Bolus, bolus.getBolusType(), bolus.getValue(), bolus.getATechDate());
pumpHistoryEntry.setHistoryEntryDetails(bolus);
resetBolusEntry();
}
@@ -682,7 +670,6 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
BasalProfileEntry basalProfileEntry = new BasalProfileEntry(tbrRate.getHead()[0], tbrDuration.getHead()[0]);
-
// System.out.println(
// "TBR: amount=" + tbr.getAmount() + ", duration=" + tbr.getDuration()
// + " min. Packed: " + tbr.getValue());
@@ -690,11 +677,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// FIXME set Unit
// FIXME AAPS
- // if (tbr.getDuration() > 0) {
- // writeData(PumpBaseType.Basal, PumpBasalType.TemporaryBasalRate, tbr.getValue(), entry.getATechDate());
- // } else {
- // writeData(PumpBaseType.Basal, PumpBasalType.TemporaryBasalRateCanceled, "", entry.getATechDate());
- // }
+ // if (tbr.getDuration() > 0) {
+ // writeData(PumpBaseType.Basal, PumpBasalType.TemporaryBasalRate, tbr.getValue(), entry.getATechDate());
+ // } else {
+ // writeData(PumpBaseType.Basal, PumpBasalType.TemporaryBasalRateCanceled, "", entry.getATechDate());
+ // }
tbrPreviousRecord = null;
}
@@ -716,9 +703,9 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
int month = ((dt[0] >> 4) & 0x0c) + ((dt[1] >> 6) & 0x03);
// ((dt[0] & 0xC0) >> 6) | ((dt[1] & 0xC0) >> 4);
-
int dayOfMonth = dt[3] & 0x1F;
- int year = fix2DigitYear(dt[4] & 0x3F); // Assuming this is correct, need to verify. Otherwise this will be a problem in 2016.
+ int year = fix2DigitYear(dt[4] & 0x3F); // Assuming this is correct, need to verify. Otherwise this will be
+ // a problem in 2016.
LocalDateTime atdate = new LocalDateTime(year, month, dayOfMonth, hour, minutes, seconds);
@@ -731,11 +718,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
int dayOfMonth = low + 1;
int year = 2000 + (ByteUtil.asUINT8(dt[1]) & 0x7F);
- //LocalDate rval = new LocalDate(year, month, dayOfMonth);
+ // LocalDate rval = new LocalDate(year, month, dayOfMonth);
- // int dayOfMonth = dt[0] & 0x1F;
- // int month = (((dt[0] & 0xE0) >> 4) + ((dt[1] & 0x80) >> 7));
- // int year = fix2DigitYear(dt[1] & 0x3F);
+ // int dayOfMonth = dt[0] & 0x1F;
+ // int month = (((dt[0] & 0xE0) >> 4) + ((dt[1] & 0x80) >> 7));
+ // int year = fix2DigitYear(dt[1] & 0x3F);
LocalDateTime atdate = new LocalDateTime(year, month, dayOfMonth, 0, 0);
@@ -759,17 +746,16 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
return year;
}
-
// WRITE DATA
-
- // private void writeData(PumpBaseType baseType, CodeEnumWithTranslation subType, ATechDate aTechDate) {
- // this.pumpValuesWriter.writeObject(baseType.name() + "_" + subType.getName(), aTechDate);
- // }
+ // private void writeData(PumpBaseType baseType, CodeEnumWithTranslation subType, ATechDate aTechDate) {
+ // this.pumpValuesWriter.writeObject(baseType.name() + "_" + subType.getName(), aTechDate);
+ // }
//
//
- // private void writeData(PumpBaseType baseType, CodeEnumWithTranslation subType, String value, ATechDate aTechDate) {
- // this.pumpValuesWriter.writeObject(baseType.name() + "_" + subType.getName(), aTechDate, value);
- // }
+ // private void writeData(PumpBaseType baseType, CodeEnumWithTranslation subType, String value, ATechDate aTechDate)
+ // {
+ // this.pumpValuesWriter.writeObject(baseType.name() + "_" + subType.getName(), aTechDate, value);
+ // }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntry.java
index 399502c830..d88cf32f1c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntry.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntry.java
@@ -4,27 +4,22 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
import info.nightscout.androidaps.plugins.PumpMedtronic.data.dto.PumpTimeStampedRecord;
/**
- * Application: GGC - GNU Gluco Control
- * Plug-in: GGC PlugIn Base (base class for all plugins)
+ * Application: GGC - GNU Gluco Control
+ * Plug-in: GGC PlugIn Base (base class for all plugins)
*
* See AUTHORS for copyright information.
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Filename: PumpHistoryEntry
- * Description: Pump History Entry.
+ * Filename: PumpHistoryEntry Description: Pump History Entry.
*
* Author: Andy {andy@atech-software.com}
*/
@@ -33,7 +28,7 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
private PumpHistoryEntryType entryType;
private Integer opCode; // this is set only when we have unknown entry...
- //private LocalDateTime timeOfEntry;
+ // private LocalDateTime timeOfEntry;
private int offset;
@@ -60,14 +55,15 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
}
- @Override
- public String getToStringStart() {
- return "PumpHistoryRecord [type=" + entryType.name() + " [" + getOpCode() + ", 0x" + HexDump.getCorrectHexValue((byte) getOpCode()) + "]";
+ public void setOpCode(Integer opCode) {
+ this.opCode = opCode;
}
- public void setOpCode(Integer opCode) {
- this.opCode = opCode;
+ @Override
+ public String getToStringStart() {
+ return "PumpHistoryRecord [type=" + entryType.name() + " [" + getOpCode() + ", 0x"
+ + HexDump.getCorrectHexValue((byte)getOpCode()) + "]";
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntryType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntryType.java
index 2149f75d52..769b957031 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntryType.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/data/history2/PumpHistoryEntryType.java
@@ -1,51 +1,40 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.data.history2;
-
-import org.apache.commons.collections.CollectionUtils;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
/**
- * Application: GGC - GNU Gluco Control
- * Plug-in: GGC PlugIn Base (base class for all plugins)
+ * Application: GGC - GNU Gluco Control
+ * Plug-in: GGC PlugIn Base (base class for all plugins)
*
* See AUTHORS for copyright information.
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Data is from several sources, so in comments there are "versions".
- * Version:
- * v1 - default doc from decoding-carelink
- * v2 - nightscout code
- * v3 - testing
- * v4 - Andy testing (?)
- * v5 - Loop code and another batch of testing with 512
+ * Data is from several sources, so in comments there are "versions". Version: v1 - default doc from decoding-carelink
+ * v2 - nightscout code v3 - testing v4 - Andy testing (?) v5 - Loop code and another batch of testing with 512
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Filename: Record Decode Status
- * Description: Record Decode Status shows if entry was decoded. Used mostly for statistics.
+ * Filename: Record Decode Status Description: Record Decode Status shows if entry was decoded. Used mostly for
+ * statistics.
*
* Author: Andy {andy@atech-software.com}
*/
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/ButtonPressCarelinkMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/ButtonPressCarelinkMessageBody.java
index c29941c36e..1cc1b31225 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/ButtonPressCarelinkMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/ButtonPressCarelinkMessageBody.java
@@ -5,20 +5,22 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
*/
@Deprecated
public class ButtonPressCarelinkMessageBody extends CarelinkLongMessageBody {
+
public static final byte BUTTON_EASY = 0x00;
public static final byte BUTTON_ESC = 0x01;
public static final byte BUTTON_ACT = 0x02;
public static final byte BUTTON_UP = 0x03;
public static final byte BUTTON_DOWN = 0x04;
+
public ButtonPressCarelinkMessageBody(int which) {
init(which);
}
+
public void init(int buttonType) {
int numArgs = 1;
- super.init(new byte[]{(byte) numArgs, (byte) buttonType});
+ super.init(new byte[] { (byte)numArgs, (byte)buttonType });
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkLongMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkLongMessageBody.java
index 69bc6c4ac3..54757c5bfc 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkLongMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkLongMessageBody.java
@@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
* Created by geoff on 6/2/16.
*/
public class CarelinkLongMessageBody extends MessageBody {
+
public static final int LONG_MESSAGE_BODY_LENGTH = 65;
protected byte[] data;
@@ -11,7 +12,7 @@ public class CarelinkLongMessageBody extends MessageBody {
public CarelinkLongMessageBody() {
init(new byte[0]);
}
-
+
public CarelinkLongMessageBody(byte[] payload) {
init(payload);
@@ -23,7 +24,7 @@ public class CarelinkLongMessageBody extends MessageBody {
data = new byte[LONG_MESSAGE_BODY_LENGTH];
if (rxData != null) {
int size = rxData.length < LONG_MESSAGE_BODY_LENGTH ? rxData.length : LONG_MESSAGE_BODY_LENGTH;
- for(int i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
data[i] = rxData[i];
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkShortMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkShortMessageBody.java
index 8b564451ae..efdd8f7b16 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkShortMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/CarelinkShortMessageBody.java
@@ -5,17 +5,12 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
*/
// Andy: See comments in message body
public class CarelinkShortMessageBody extends MessageBody {
+
byte[] body;
- @Override
- public int getLength() {
- return body.length;
- }
-
-
public CarelinkShortMessageBody() {
- init(new byte[]{0});
+ init(new byte[] { 0 });
}
@@ -24,6 +19,12 @@ public class CarelinkShortMessageBody extends MessageBody {
}
+ @Override
+ public int getLength() {
+ return body.length;
+ }
+
+
@Override
public void init(byte[] rxData) {
body = rxData;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetHistoryPageCarelinkMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetHistoryPageCarelinkMessageBody.java
index 9ddf596662..68ab5ea6ed 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetHistoryPageCarelinkMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetHistoryPageCarelinkMessageBody.java
@@ -1,39 +1,44 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
-
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
/**
* Created by geoff on 6/2/16.
*/
public class GetHistoryPageCarelinkMessageBody extends CarelinkLongMessageBody {
- //public boolean wasLastFrame = false;
- //public int frameNumber = 0;
- //public byte[] frame = new byte[] {};
+
+ // public boolean wasLastFrame = false;
+ // public int frameNumber = 0;
+ // public byte[] frame = new byte[] {};
public GetHistoryPageCarelinkMessageBody(byte[] frameData) {
init(frameData);
}
+
public GetHistoryPageCarelinkMessageBody(int pageNum) {
init(pageNum);
}
+
@Override
public int getLength() {
return data.length;
}
+
@Override
public void init(byte[] rxData) {
super.init(rxData);
}
+
public void init(int pageNum) {
byte numArgs = 1;
- super.init(new byte[]{numArgs, (byte) pageNum});
+ super.init(new byte[] { numArgs, (byte)pageNum });
}
+
public int getFrameNumber() {
if (data.length > 0) {
return data[0] & 0x7f;
@@ -41,10 +46,12 @@ public class GetHistoryPageCarelinkMessageBody extends CarelinkLongMessageBody {
return 255;
}
+
public boolean wasLastFrame() {
return (data[0] & 0x80) != 0;
}
+
public byte[] getFrameData() {
return ByteUtil.substring(data, 1, data.length - 1);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetPumpModelCarelinkMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetPumpModelCarelinkMessageBody.java
index cc5c03b3a2..f8cbcd45f8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetPumpModelCarelinkMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/GetPumpModelCarelinkMessageBody.java
@@ -11,24 +11,29 @@ public class GetPumpModelCarelinkMessageBody extends MessageBody {
return 1;
}
+
@Override
public void init(byte[] rxData) {
}
+
public byte[] getRxData() {
- return new byte[]{0};
+ return new byte[] { 0 };
}
+
public void setRxData(byte[] rxData) {
}
+
@Override
public byte[] getTxData() {
- return new byte[]{0};
+ return new byte[] { 0 };
}
+
public void setTxData(byte[] txData) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MedtronicConverter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MedtronicConverter.java
index f301ac7a5d..d297e93619 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MedtronicConverter.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MedtronicConverter.java
@@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
+import java.util.HashMap;
+import java.util.Map;
import org.joda.time.IllegalFieldValueException;
import org.joda.time.LocalDateTime;
@@ -7,9 +9,6 @@ import org.joda.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.Map;
-
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
@@ -77,19 +76,17 @@ public class MedtronicConverter {
return rawContent;
}
-
default: {
throw new RuntimeException("Unsupported command Type: " + commandType);
}
}
-
}
protected BasalProfile decodeProfile2(byte[] rep) {
- //byte rep[] = minimedReply.getRawData();
+ // byte rep[] = minimedReply.getRawData();
// String profile = getProfileName(minimedReply);
@@ -98,8 +95,8 @@ public class MedtronicConverter {
// 0x12 0x00 0x00 0x16 0x00 0x11 0x00
if ((rep.length >= 3) && (rep[2] == 0x3F)) {
- //String i18value = i18nControl.getMessage("NOT_SET");
- //writeSetting(key, i18value, i18value, PumpConfigurationGroup.Basal);
+ // String i18value = i18nControl.getMessage("NOT_SET");
+ // writeSetting(key, i18value, i18value, PumpConfigurationGroup.Basal);
return null;
}
@@ -108,7 +105,6 @@ public class MedtronicConverter {
for (int i = 0; i < rep.length; i += 3) {
-
vald = MedtronicUtil.decodeBasalInsulin(rep[i + 1], rep[i]);
time_x = rep[i + 2];
@@ -119,11 +115,10 @@ public class MedtronicConverter {
break;
}
- //String value = i18nControl.getMessage("CFG_BASE_FROM") + "=" + atd.getTimeString() + ", "
- // + i18nControl.getMessage("CFG_BASE_AMOUNT") + "=" + vald;
-
- //writeSetting(key, value, value, PumpConfigurationGroup.Basal);
+ // String value = i18nControl.getMessage("CFG_BASE_FROM") + "=" + atd.getTimeString() + ", "
+ // + i18nControl.getMessage("CFG_BASE_AMOUNT") + "=" + vald;
+ // writeSetting(key, value, value, PumpConfigurationGroup.Basal);
}
@@ -149,21 +144,22 @@ public class MedtronicConverter {
if (rawData.length > 1) {
// if response in 3 bytes then we add additional information
- //double d = MedtronicUtil.makeUnsignedShort(rawData[2], rawData[1]) / 100.0d;
+ // double d = MedtronicUtil.makeUnsignedShort(rawData[2], rawData[1]) / 100.0d;
double d = ByteUtil.toInt(rawData[1], rawData[2]) / 100.0d;
batteryStatus.voltage = d;
-// double perc = (d - BatteryType.Alkaline.lowVoltage) / (BatteryType.Alkaline.highVoltage - BatteryType.Alkaline.lowVoltage);
-//
-// LOG.warn("Percent status: " + perc);
-// LOG.warn("Unknown status: " + rawData[0]);
-// LOG.warn("Full result: " + d);
-//
-// int percent = (int) (perc * 100.0d);
+ // double perc = (d - BatteryType.Alkaline.lowVoltage) / (BatteryType.Alkaline.highVoltage -
+ // BatteryType.Alkaline.lowVoltage);
+ //
+ // LOG.warn("Percent status: " + perc);
+ // LOG.warn("Unknown status: " + rawData[0]);
+ // LOG.warn("Full result: " + d);
+ //
+ // int percent = (int) (perc * 100.0d);
- //return percent;
+ // return percent;
}
return batteryStatus;
@@ -198,7 +194,9 @@ public class MedtronicConverter {
LocalDateTime pumpTime = new LocalDateTime(year, month, day, hours, minutes, seconds);
return pumpTime;
} catch (IllegalFieldValueException e) {
- LOG.error("decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d", year, month, day, hours, minutes, seconds);
+ LOG.error(
+ "decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
+ year, month, day, hours, minutes, seconds);
return null;
}
@@ -208,11 +206,10 @@ public class MedtronicConverter {
public Map decodeSettings512(byte[] rd) {
Map map = new HashMap<>();
- //List outList = new ArrayList<>();
+ // List outList = new ArrayList<>();
addSettingToMap("PCFG_AUTOOFF_TIMEOUT", "" + rd[0], PumpConfigurationGroup.General, map);
-
if (rd[1] == 4) {
addSettingToMap("PCFG_ALARM_MODE", "Silent", PumpConfigurationGroup.Sound, map);
} else {
@@ -223,13 +220,19 @@ public class MedtronicConverter {
addSettingToMap("PCFG_AUDIO_BOLUS_ENABLED", parseResultEnable(rd[2]), PumpConfigurationGroup.Bolus, map);
if (rd[2] == 1) {
- addSettingToMap("PCFG_AUDIO_BOLUS_STEP_SIZE", "" + decodeBolusInsulin(ByteUtil.asUINT8(rd[3])), PumpConfigurationGroup.Bolus, map);
+ addSettingToMap("PCFG_AUDIO_BOLUS_STEP_SIZE", "" + decodeBolusInsulin(ByteUtil.asUINT8(rd[3])),
+ PumpConfigurationGroup.Bolus, map);
}
addSettingToMap("PCFG_VARIABLE_BOLUS_ENABLED", parseResultEnable(rd[4]), PumpConfigurationGroup.Bolus, map);
addSettingToMap("PCFG_MAX_BOLUS", "" + decodeMaxBolus(rd), PumpConfigurationGroup.Bolus, map);
- addSettingToMap("PCFG_MAX_BASAL", "" + decodeBasalInsulin(ByteUtil.makeUnsignedShort(rd[getSettingIndexMaxBasal()], rd[getSettingIndexMaxBasal() + 1])), PumpConfigurationGroup.Basal, map);
- addSettingToMap("CFG_BASE_CLOCK_MODE", rd[getSettingIndexTimeDisplayFormat()] == 0 ? "12h" : "24h", PumpConfigurationGroup.General, map);
+ addSettingToMap(
+ "PCFG_MAX_BASAL",
+ ""
+ + decodeBasalInsulin(ByteUtil.makeUnsignedShort(rd[getSettingIndexMaxBasal()],
+ rd[getSettingIndexMaxBasal() + 1])), PumpConfigurationGroup.Basal, map);
+ addSettingToMap("CFG_BASE_CLOCK_MODE", rd[getSettingIndexTimeDisplayFormat()] == 0 ? "12h" : "24h",
+ PumpConfigurationGroup.General, map);
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] != 0 ? 50 : 100), PumpConfigurationGroup.Insulin, map);
addSettingToMap("PCFG_BASAL_PROFILES_ENABLED", parseResultEnable(rd[10]), PumpConfigurationGroup.Basal, map);
@@ -282,19 +285,21 @@ public class MedtronicConverter {
public Map decodeSettings(byte[] rd) {
Map map = decodeSettings512(rd);
- addSettingToMap("PCFG_MM_RESERVOIR_WARNING_TYPE_TIME", rd[18] != 0 ? "PCFG_MM_RESERVOIR_WARNING_TYPE_TIME" : "PCFG_MM_RESERVOIR_WARNING_TYPE_UNITS", PumpConfigurationGroup.Other, map);
+ addSettingToMap("PCFG_MM_RESERVOIR_WARNING_TYPE_TIME", rd[18] != 0 ? "PCFG_MM_RESERVOIR_WARNING_TYPE_TIME"
+ : "PCFG_MM_RESERVOIR_WARNING_TYPE_UNITS", PumpConfigurationGroup.Other, map);
- addSettingToMap("PCFG_MM_SRESERVOIR_WARNING_POINT", "" + ByteUtil.asUINT8(rd[19]), PumpConfigurationGroup.Other, map);
+ addSettingToMap("PCFG_MM_SRESERVOIR_WARNING_POINT", "" + ByteUtil.asUINT8(rd[19]),
+ PumpConfigurationGroup.Other, map);
addSettingToMap("CFG_MM_KEYPAD_LOCKED", parseResultEnable(rd[20]), PumpConfigurationGroup.Other, map);
-
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_523andHigher)) {
addSettingToMap("PCFG_BOLUS_SCROLL_STEP_SIZE", "" + rd[21], PumpConfigurationGroup.Bolus, map);
addSettingToMap("PCFG_CAPTURE_EVENT_ENABLE", parseResultEnable(rd[22]), PumpConfigurationGroup.Other, map);
addSettingToMap("PCFG_OTHER_DEVICE_ENABLE", parseResultEnable(rd[23]), PumpConfigurationGroup.Other, map);
- addSettingToMap("PCFG_OTHER_DEVICE_PAIRED_STATE", parseResultEnable(rd[24]), PumpConfigurationGroup.Other, map);
+ addSettingToMap("PCFG_OTHER_DEVICE_PAIRED_STATE", parseResultEnable(rd[24]), PumpConfigurationGroup.Other,
+ map);
}
return map;
@@ -321,7 +326,8 @@ public class MedtronicConverter {
// 512
public void decodeInsulinActionSetting(byte[] ai, Map map) {
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_512_712)) {
- addSettingToMap("PCFG_INSULIN_ACTION_TYPE", (ai[17] != 0 ? "Regular" : "Fast"), PumpConfigurationGroup.Insulin, map);
+ addSettingToMap("PCFG_INSULIN_ACTION_TYPE", (ai[17] != 0 ? "Regular" : "Fast"),
+ PumpConfigurationGroup.Insulin, map);
} else {
int i = ai[17];
String s = "";
@@ -341,13 +347,13 @@ public class MedtronicConverter {
public double decodeBasalInsulin(int i) {
- return (double) i / (double) getStrokesPerUnit(true);
+ return (double)i / (double)getStrokesPerUnit(true);
}
public double decodeBolusInsulin(int i) {
- return (double) i / (double) getStrokesPerUnit(false);
+ return (double)i / (double)getStrokesPerUnit(false);
}
@@ -362,7 +368,8 @@ public class MedtronicConverter {
public double decodeMaxBolus(byte ai[]) {
- return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil.asUINT8(ai[5]));
+ return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil
+ .asUINT8(ai[5]));
}
@@ -370,5 +377,4 @@ public class MedtronicConverter {
return (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_523andHigher));
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageBody.java
index f4698be922..da50ceee5b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageBody.java
@@ -6,10 +6,13 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
* Created by geoff on 5/29/16.
*/
-// Andy (4.6.2018): We probably need rewrite of this message body code. If there is no data sent, body is 00, which denotes,
-// no parameters. If we have 3 parameters sent (1 2 3), the body would actually be length of 4, first byte beeing the length
+// Andy (4.6.2018): We probably need rewrite of this message body code. If there is no data sent, body is 00, which
+// denotes,
+// no parameters. If we have 3 parameters sent (1 2 3), the body would actually be length of 4, first byte beeing the
+// length
// of the message, so the body would be 3 1 2 3. This is not done that way now.
public class MessageBody {
+
public int getLength() {
return 0;
}
@@ -20,7 +23,7 @@ public class MessageBody {
public byte[] getTxData() {
- return new byte[]{};
+ return new byte[] {};
}
@@ -34,5 +37,4 @@ public class MessageBody {
return sb.toString();
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageType.java
index 2b7da8949d..e1b6489818 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageType.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/MessageType.java
@@ -1,108 +1,108 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashMap;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Created by geoff on 5/29/16.
*/
-// changed to Enum, since this is now enum, I had to remove duplicate entries, so if entry is on first list, it was removed
+// changed to Enum, since this is now enum, I had to remove duplicate entries, so if entry is on first list, it was
+// removed
// from second (commented out)
@Deprecated
public enum MessageType {
- Invalid((byte) 0x00), Alert((byte) 0x01), //
- AlertCleared((byte) 0x02), //
- DeviceTest((byte) 0x03), //
- PumpStatus((byte) 0x04), //
- PumpAck((byte) 0x06), //
- PumpBackfill((byte) 0x08), //
- FindDevice((byte) 0x09), //
- DeviceLink((byte) 0x0a), //
- ChangeTime((byte) 0x40), //
- Bolus((byte) 0x42), //
- ChangeTempBasal((byte) 0x4c), //
- ButtonPress((byte) 0x5b), //
- PowerOn((byte) 0x5d), //
- ReadTime((byte) 0x70), //
- GetBattery((byte) 0x72), //
- GetHistoryPage((byte) 0x80), //
- GetISFProfile((byte) 0x8b), //
- GetPumpModel((byte) 0x8d), //
- ReadTempBasal((byte) 0x98), //
- ReadSettings((byte) 0xc0), //
- SetBasalProfileSTD((byte) 0x6f), //
- ReadBasalProfileSTD((byte) 0x92),
-
+ Invalid((byte)0x00),
+ Alert((byte)0x01), //
+ AlertCleared((byte)0x02), //
+ DeviceTest((byte)0x03), //
+ PumpStatus((byte)0x04), //
+ PumpAck((byte)0x06), //
+ PumpBackfill((byte)0x08), //
+ FindDevice((byte)0x09), //
+ DeviceLink((byte)0x0a), //
+ ChangeTime((byte)0x40), //
+ Bolus((byte)0x42), //
+ ChangeTempBasal((byte)0x4c), //
+ ButtonPress((byte)0x5b), //
+ PowerOn((byte)0x5d), //
+ ReadTime((byte)0x70), //
+ GetBattery((byte)0x72), //
+ GetHistoryPage((byte)0x80), //
+ GetISFProfile((byte)0x8b), //
+ GetPumpModel((byte)0x8d), //
+ ReadTempBasal((byte)0x98), //
+ ReadSettings((byte)0xc0), //
+ SetBasalProfileSTD((byte)0x6f), //
+ ReadBasalProfileSTD((byte)0x92),
// The above codes include codes that are not 522/722 specific.
-
// The codes below here are Medtronic pump specific.
// from Roundtrip.Carelink:
- CMD_M_PACKET_LENGTH((byte) 7), // 0x07
- CMD_M_BEGIN_PARAMETER_SETTING((byte) 38), // 0x26
- CMD_M_END_PARAMETER_SETTING((byte) 39), // 0x27
- CMD_M_SET_A_PROFILE((byte) 48), // 0x30
- CMD_M_SET_B_PROFILE((byte) 49), // 0x31
- CMD_M_SET_LOGIC_LINK_ID((byte) 50), // 0x32
- CMD_M_SET_LOGIC_LINK_ENABLE((byte) 51), // 0x33
- // CMD_M_SET_RTC ((byte)64), // 0x40 - ChangeTime
- CMD_M_SET_MAX_BOLUS((byte) 65), // 0x41
- // CMD_M_BOLUS ((byte)66), // 0x42 - Bolus
- CMD_M_SET_VAR_BOLUS_ENABLE((byte) 69), // 0x45
- CMD_M_SET_CURRENT_PATTERN((byte) 74), // 0x4a
- // CMD_M_TEMP_BASAL_RATE ((byte)76), // 0x4c - ChangeTempBasal
- CMD_M_SUSPEND_RESUME((byte) 77), // 0x4d
- CMD_M_SET_AUTO_OFF((byte) 78), // 0x4e
- CMD_M_SET_EASY_BOLUS_ENABLE((byte) 79), // 0x4f
- CMD_M_SET_RF_REMOTE_ID((byte) 81), // 0x51
- CMD_M_SET_BLOCK_ENABLE((byte) 82), // 0x52
- CMD_M_SET_ALERT_TYPE((byte) 84), // 0x54
- CMD_M_SET_PATTERNS_ENABLE((byte) 85), // 0x55
- CMD_M_SET_RF_ENABLE((byte) 87), // 0x57
- CMD_M_SET_INSULIN_ACTION_TYPE((byte) 88), // 0x58
- // CMD_M_KEYPAD_PUSH ((byte)91), // 0x5b - ButtonPress
- CMD_M_SET_TIME_FORMAT((byte) 92), // 0x5c
- // CMD_M_POWER_CTRL ((byte)93), // 0x5d - PowerOn
- CMD_M_SET_BOLUS_WIZARD_SETUP((byte) 94), // 0x5e
- CMD_M_SET_BG_ALARM_ENABLE((byte) 103), // 0x67
- CMD_M_SET_TEMP_BASAL_TYPE((byte) 104), // 0x68
- CMD_M_SET_RESERVOIR_WARNING((byte) 106), // 0x6a
- CMD_M_SET_BG_ALARM_CLOCKS((byte) 107), // 0x6b
- CMD_M_SET_BG_REMINDER_ENABLE((byte) 108), // 0x6c
- CMD_M_SET_MAX_BASAL((byte) 110), // 0x6e
- // CMD_M_SET_STD_PROFILE ((byte)111), // 0x6f - SetBasalProfileSTD
- // CMD_M_READ_RTC ((byte)112), // 0x70 - ReadTime
- CMD_M_READ_PUMP_ID((byte) 113), // 0x71
- CMD_M_READ_INSULIN_REMAINING((byte) 115), // 0x73
- CMD_M_READ_FIRMWARE_VER((byte) 116), // 0x74
- CMD_M_READ_ERROR_STATUS((byte) 117), // 0x75
- CMD_M_READ_REMOTE_CTRL_IDS((byte) 118), // 0x76
- // CMD_M_READ_HISTORY ((byte)128), // 0x80 - GetHistoryPage
- CMD_M_READ_PUMP_STATE((byte) 131), // 0x83
- CMD_M_READ_BOLUS_WIZARD_SETUP_STATUS((byte) 135), // 0x87
- CMD_M_READ_CARB_UNITS((byte) 136), // 0x88
- CMD_M_READ_BG_UNITS((byte) 137), // 0x89
- CMD_M_READ_CARB_RATIOS((byte) 138), // 0x8a
- // CMD_M_READ_INSULIN_SENSITIVITIES ((byte)139), // 0x8b - GetISFProfile
- CMD_M_READ_BG_TARGETS((byte) 140), // 0x8c
- // CMD_M_READ_PUMP_MODEL_NUMBER ((byte)141), // 0x8d - GetPumpModel
- CMD_M_READ_BG_ALARM_CLOCKS((byte) 142), // 0x8e
- CMD_M_READ_RESERVOIR_WARNING((byte) 143), // 0x8f
- CMD_M_READ_BG_REMINDER_ENABLE((byte) 144), // 0x90
- CMD_M_READ_SETTINGS((byte) 145), // 0x91
+ CMD_M_PACKET_LENGTH((byte)7), // 0x07
+ CMD_M_BEGIN_PARAMETER_SETTING((byte)38), // 0x26
+ CMD_M_END_PARAMETER_SETTING((byte)39), // 0x27
+ CMD_M_SET_A_PROFILE((byte)48), // 0x30
+ CMD_M_SET_B_PROFILE((byte)49), // 0x31
+ CMD_M_SET_LOGIC_LINK_ID((byte)50), // 0x32
+ CMD_M_SET_LOGIC_LINK_ENABLE((byte)51), // 0x33
+ // CMD_M_SET_RTC ((byte)64), // 0x40 - ChangeTime
+ CMD_M_SET_MAX_BOLUS((byte)65), // 0x41
+ // CMD_M_BOLUS ((byte)66), // 0x42 - Bolus
+ CMD_M_SET_VAR_BOLUS_ENABLE((byte)69), // 0x45
+ CMD_M_SET_CURRENT_PATTERN((byte)74), // 0x4a
+ // CMD_M_TEMP_BASAL_RATE ((byte)76), // 0x4c - ChangeTempBasal
+ CMD_M_SUSPEND_RESUME((byte)77), // 0x4d
+ CMD_M_SET_AUTO_OFF((byte)78), // 0x4e
+ CMD_M_SET_EASY_BOLUS_ENABLE((byte)79), // 0x4f
+ CMD_M_SET_RF_REMOTE_ID((byte)81), // 0x51
+ CMD_M_SET_BLOCK_ENABLE((byte)82), // 0x52
+ CMD_M_SET_ALERT_TYPE((byte)84), // 0x54
+ CMD_M_SET_PATTERNS_ENABLE((byte)85), // 0x55
+ CMD_M_SET_RF_ENABLE((byte)87), // 0x57
+ CMD_M_SET_INSULIN_ACTION_TYPE((byte)88), // 0x58
+ // CMD_M_KEYPAD_PUSH ((byte)91), // 0x5b - ButtonPress
+ CMD_M_SET_TIME_FORMAT((byte)92), // 0x5c
+ // CMD_M_POWER_CTRL ((byte)93), // 0x5d - PowerOn
+ CMD_M_SET_BOLUS_WIZARD_SETUP((byte)94), // 0x5e
+ CMD_M_SET_BG_ALARM_ENABLE((byte)103), // 0x67
+ CMD_M_SET_TEMP_BASAL_TYPE((byte)104), // 0x68
+ CMD_M_SET_RESERVOIR_WARNING((byte)106), // 0x6a
+ CMD_M_SET_BG_ALARM_CLOCKS((byte)107), // 0x6b
+ CMD_M_SET_BG_REMINDER_ENABLE((byte)108), // 0x6c
+ CMD_M_SET_MAX_BASAL((byte)110), // 0x6e
+ // CMD_M_SET_STD_PROFILE ((byte)111), // 0x6f - SetBasalProfileSTD
+ // CMD_M_READ_RTC ((byte)112), // 0x70 - ReadTime
+ CMD_M_READ_PUMP_ID((byte)113), // 0x71
+ CMD_M_READ_INSULIN_REMAINING((byte)115), // 0x73
+ CMD_M_READ_FIRMWARE_VER((byte)116), // 0x74
+ CMD_M_READ_ERROR_STATUS((byte)117), // 0x75
+ CMD_M_READ_REMOTE_CTRL_IDS((byte)118), // 0x76
+ // CMD_M_READ_HISTORY ((byte)128), // 0x80 - GetHistoryPage
+ CMD_M_READ_PUMP_STATE((byte)131), // 0x83
+ CMD_M_READ_BOLUS_WIZARD_SETUP_STATUS((byte)135), // 0x87
+ CMD_M_READ_CARB_UNITS((byte)136), // 0x88
+ CMD_M_READ_BG_UNITS((byte)137), // 0x89
+ CMD_M_READ_CARB_RATIOS((byte)138), // 0x8a
+ // CMD_M_READ_INSULIN_SENSITIVITIES ((byte)139), // 0x8b - GetISFProfile
+ CMD_M_READ_BG_TARGETS((byte)140), // 0x8c
+ // CMD_M_READ_PUMP_MODEL_NUMBER ((byte)141), // 0x8d - GetPumpModel
+ CMD_M_READ_BG_ALARM_CLOCKS((byte)142), // 0x8e
+ CMD_M_READ_RESERVOIR_WARNING((byte)143), // 0x8f
+ CMD_M_READ_BG_REMINDER_ENABLE((byte)144), // 0x90
+ CMD_M_READ_SETTINGS((byte)145), // 0x91
// CMD_M_READ_STD_PROFILES((byte) 146), // 0x92 - ReadBasalProfileSTD
- CMD_M_READ_A_PROFILES((byte) 147), // 0x93
- CMD_M_READ_B_PROFILES((byte) 148), // 0x94
- CMD_M_READ_LOGIC_LINK_IDS((byte) 149), // 0x95
- CMD_M_READ_BG_ALARM_ENABLE((byte) 151), // 0x97
- // CMD_M_READ_TEMP_BASAL ((byte)152), // 0x98 - ReadTempBasal
- // CMD_M_READ_PUMP_SETTINGS ((byte)192), // 0xc0 - ReadSettings
- CMD_M_READ_PUMP_STATUS((byte) 206), // 0xce
+ CMD_M_READ_A_PROFILES((byte)147), // 0x93
+ CMD_M_READ_B_PROFILES((byte)148), // 0x94
+ CMD_M_READ_LOGIC_LINK_IDS((byte)149), // 0x95
+ CMD_M_READ_BG_ALARM_ENABLE((byte)151), // 0x97
+ // CMD_M_READ_TEMP_BASAL ((byte)152), // 0x98 - ReadTempBasal
+ // CMD_M_READ_PUMP_SETTINGS ((byte)192), // 0xc0 - ReadSettings
+ CMD_M_READ_PUMP_STATUS((byte)206), // 0xce
;
@@ -115,7 +115,7 @@ public enum MessageType {
boolean foundErrors = false;
- for(MessageType messageType : values()) {
+ for (MessageType messageType : values()) {
if (mapByValue.containsKey(messageType.getValue())) {
// leave this check in case someone adds any new commands
@@ -127,14 +127,14 @@ public enum MessageType {
}
if (foundErrors) {
- LOG.error("MessageType has duplicate entries. Each items needs to have unique value associated with it. " + "If this is not the case, application might not work correctly. Fix this and restart application.");
+ LOG.error("MessageType has duplicate entries. Each items needs to have unique value associated with it. "
+ + "If this is not the case, application might not work correctly. Fix this and restart application.");
System.exit(0);
}
}
-
byte mtype;
@@ -153,11 +153,6 @@ public enum MessageType {
}
- public byte getValue() {
- return this.mtype;
- }
-
-
public static MessageType getByValue(byte msgType) {
if (mapByValue.containsKey(msgType)) {
@@ -166,4 +161,9 @@ public enum MessageType {
return MessageType.Invalid;
}
}
+
+
+ public byte getValue() {
+ return this.mtype;
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PacketType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PacketType.java
index 650edba836..3155d51683 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PacketType.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PacketType.java
@@ -15,30 +15,33 @@ public enum PacketType {
Sensor(0xa8) //
;
- private byte value = 0;
public static Map mapByValue;
static {
mapByValue = new HashMap<>();
- for(PacketType packetType : values()) {
+ for (PacketType packetType : values()) {
mapByValue.put(packetType.value, packetType);
}
}
+ private byte value = 0;
+
PacketType(int value) {
- this.value = (byte) value;
+ this.value = (byte)value;
+ }
+
+
+ public static PacketType getByValue(short value) {
+ if (mapByValue.containsKey(value))
+ return mapByValue.get(value);
+ else
+ return PacketType.Invalid;
}
public byte getValue() {
return value;
}
-
-
- public static PacketType getByValue(short value) {
- if (mapByValue.containsKey(value)) return mapByValue.get(value);
- else return PacketType.Invalid;
- }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpAckMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpAckMessageBody.java
index f66d9c14a1..23feedeb6e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpAckMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpAckMessageBody.java
@@ -4,10 +4,12 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
* Created by geoff on 5/29/16.
*/
public class PumpAckMessageBody extends CarelinkShortMessageBody {
+
public PumpAckMessageBody() {
- init(new byte[]{0});
+ init(new byte[] { 0 });
}
+
public PumpAckMessageBody(byte[] bodyData) {
init(bodyData);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpMessage.java
index 660209195f..64e9a2f9c6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpMessage.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/PumpMessage.java
@@ -14,7 +14,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicCommandTyp
public class PumpMessage implements RLMessage {
public PacketType packetType = PacketType.Carelink;
- public byte[] address = new byte[]{0, 0, 0};
+ public byte[] address = new byte[] { 0, 0, 0 };
public MedtronicCommandType commandType;
public Byte invalidCommandType;
public MessageBody messageBody = new MessageBody();
@@ -41,13 +41,12 @@ public class PumpMessage implements RLMessage {
}
- // public void init(PacketType packetType, byte[] address, MessageType messageType, MessageBody messageBody) {
- // this.packetType = packetType;
- // this.address = address;
- // this.messageType = messageType;
- // this.messageBody = messageBody;
- // }
-
+ // public void init(PacketType packetType, byte[] address, MessageType messageType, MessageBody messageBody) {
+ // this.packetType = packetType;
+ // this.address = address;
+ // this.messageType = messageType;
+ // this.messageBody = messageBody;
+ // }
public void init(PacketType packetType, byte[] address, MedtronicCommandType commandType, MessageBody messageBody) {
this.packetType = packetType;
@@ -74,14 +73,15 @@ public class PumpMessage implements RLMessage {
}
}
if (rxData.length > 5) {
- this.messageBody = MedtronicCommandType.constructMessageBody(commandType, ByteUtil.substring(rxData, 5, rxData.length - 5));
+ this.messageBody = MedtronicCommandType.constructMessageBody(commandType,
+ ByteUtil.substring(rxData, 5, rxData.length - 5));
}
}
@Override
public byte[] getTxData() {
- byte[] rval = ByteUtil.concat(new byte[]{(byte) packetType.getValue()}, address);
+ byte[] rval = ByteUtil.concat(new byte[] { (byte)packetType.getValue() }, address);
rval = ByteUtil.concat(rval, commandType.getCommandCode());
rval = ByteUtil.concat(rval, messageBody.getTxData());
return rval;
@@ -89,7 +89,7 @@ public class PumpMessage implements RLMessage {
public byte[] getContents() {
- return ByteUtil.concat(new byte[]{commandType.getCommandCode()}, messageBody.getTxData());
+ return ByteUtil.concat(new byte[] { commandType.getCommandCode() }, messageBody.getTxData());
}
@@ -101,7 +101,8 @@ public class PumpMessage implements RLMessage {
byte[] data = messageBody.getTxData();
- int length = ByteUtil.asUINT8(data[0]); // length is not always correct so, we check whole array if we have data, after length
+ int length = ByteUtil.asUINT8(data[0]); // length is not always correct so, we check whole array if we have
+ // data, after length
int originalLength = length;
// check if displayed length is invalid
@@ -125,7 +126,8 @@ public class PumpMessage implements RLMessage {
System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length);
- Log.d("PumpMessage", "Length: " + length + ", Original Length: " + originalLength + ", CommandType: " + commandType);
+ Log.d("PumpMessage", "Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
+ + commandType);
return arrayOut;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/UnknownMessageBody.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/UnknownMessageBody.java
index 7722108f0d..fa93b32a03 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/UnknownMessageBody.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/message/UnknownMessageBody.java
@@ -4,34 +4,42 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.message;
* Created by geoff on 5/29/16.
*/
public class UnknownMessageBody extends MessageBody {
+
public byte[] rxData;
+
+ public UnknownMessageBody(byte[] data) {
+ this.rxData = data;
+ }
+
+
@Override
public int getLength() {
return 0;
}
- public UnknownMessageBody(byte[] data) {
- this.rxData = data;
- }
@Override
public void init(byte[] rxData) {
}
+
public byte[] getRxData() {
return rxData;
}
+
public void setRxData(byte[] rxData) {
this.rxData = rxData;
}
+
@Override
public byte[] getTxData() {
return rxData;
}
+
public void setTxData(byte[] txData) {
this.rxData = txData;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIComm.java
index 22764f0b9e..6ced916eac 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIComm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIComm.java
@@ -38,33 +38,33 @@ public class MedtronicUIComm {
MedtronicUtil.setCurrentCommand(commandType);
-// new Thread(() -> {
-// LOG.warn("@@@ Start Thread");
-//
-// task.execute(getCommunicationManager());
-//
-// LOG.warn("@@@ End Thread");
-// });
+ // new Thread(() -> {
+ // LOG.warn("@@@ Start Thread");
+ //
+ // task.execute(getCommunicationManager());
+ //
+ // LOG.warn("@@@ End Thread");
+ // });
task.execute(getCommunicationManager());
-// for (int i = 0; i < getMaxWaitTime(commandType); i++) {
-// synchronized (task) {
-//// try {
-////
-//// //task.wait(1000);
-//// } catch (InterruptedException e) {
-//// LOG.error("executeCommand InterruptedException", e);
-//// }
-//
-//
-// SystemClock.sleep(1000);
-// }
-//
-// if (task.isReceived()) {
-// break;
-// }
-// }
+ // for (int i = 0; i < getMaxWaitTime(commandType); i++) {
+ // synchronized (task) {
+ // // try {
+ // //
+ // // //task.wait(1000);
+ // // } catch (InterruptedException e) {
+ // // LOG.error("executeCommand InterruptedException", e);
+ // // }
+ //
+ //
+ // SystemClock.sleep(1000);
+ // }
+ //
+ // if (task.isReceived()) {
+ // break;
+ // }
+ // }
if (!task.isReceived()) {
LOG.warn("Reply not received for " + commandType);
@@ -77,6 +77,7 @@ public class MedtronicUIComm {
}
+
/**
* We return 25s as waitTime (17 for wakeUp, and addtional 8 for data retrieval) for normal commands and
* 120s for History. Real time for returning data would be arround 5s, but lets be sure.
@@ -96,6 +97,7 @@ public class MedtronicUIComm {
return getCommunicationManager().getNotConnectedCount();
}
+
public void startTunning() {
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIPostprocessor.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIPostprocessor.java
index e62987021f..2122d9114e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIPostprocessor.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUIPostprocessor.java
@@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.comm.ui;
+import java.util.Date;
+import java.util.Map;
+
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Date;
-import java.util.Map;
-
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@@ -17,7 +17,6 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.data.dto.PumpSettingDTO;
import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
-
/**
* Created by andy on 6/15/18.
*/
@@ -28,6 +27,7 @@ public class MedtronicUIPostprocessor {
MedtronicPumpStatus pumpStatus;
+
public MedtronicUIPostprocessor() {
pumpStatus = MedtronicUtil.getPumpStatus();
}
@@ -40,44 +40,43 @@ public class MedtronicUIPostprocessor {
switch (uiTask.commandType) {
case GetBasalProfileSTD: {
- BasalProfile basalProfile = (BasalProfile) uiTask.returnData;
+ BasalProfile basalProfile = (BasalProfile)uiTask.returnData;
pumpStatus.basalsByHour = basalProfile.getProfilesByHour();
}
- break;
+ break;
case SetBolus: {
pumpStatus.lastBolusAmount = uiTask.getDoubleFromParameters(0);
pumpStatus.lastBolusTime = new Date();
}
- break;
+ break;
case GetRemainingInsulin: {
- pumpStatus.reservoirRemainingUnits = (Float) uiTask.returnData;
+ pumpStatus.reservoirRemainingUnits = (Float)uiTask.returnData;
}
- break;
+ break;
case CancelTBR: {
pumpStatus.tempBasalStart = null;
pumpStatus.tempBasalAmount = null;
pumpStatus.tempBasalLength = null;
}
- break;
+ break;
case RealTimeClock: {
processTime(uiTask);
}
- break;
-
+ break;
case GetBatteryStatus: {
- BatteryStatusDTO batteryStatusDTO = (BatteryStatusDTO) uiTask.returnData;
+ BatteryStatusDTO batteryStatusDTO = (BatteryStatusDTO)uiTask.returnData;
if (batteryStatusDTO.batteryStatusType == BatteryStatusDTO.BatteryStatusType.Low)
pumpStatus.batteryRemaining = 18;
else
pumpStatus.batteryRemaining = 70;
}
- break;
+ break;
case PumpModel: {
if (pumpStatus.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
@@ -85,15 +84,13 @@ public class MedtronicUIPostprocessor {
sendNotification(R.string.medtronic_error_pump_type_set_differs_from_detected, Notification.NORMAL);
}
}
- break;
-
+ break;
case Settings_512:
case Settings: {
postProcessSettings(uiTask);
}
- break;
-
+ break;
// no postprocessing
@@ -102,12 +99,12 @@ public class MedtronicUIPostprocessor {
}
-
}
+
private void processTime(MedtronicUITask uiTask) {
- LocalDateTime ldt = (LocalDateTime) uiTask.returnData;
+ LocalDateTime ldt = (LocalDateTime)uiTask.returnData;
Date d1 = ldt.toDate();
@@ -115,8 +112,8 @@ public class MedtronicUIPostprocessor {
long diff = Math.abs(d1.getTime() - currentTimeMillis);
LOG.warn("Pump Time: " + ldt + ", DeviceTime=" + d1 + //
- //", epoch: " + d1.getTime() + ", current: " + currentTimeMillis + //
- ", diff: " + diff / 1000 + " s");
+ // ", epoch: " + d1.getTime() + ", current: " + currentTimeMillis + //
+ ", diff: " + diff / 1000 + " s");
if (diff >= 10 * 60 * 1000) {
LOG.debug("Pump clock needs update, pump time: " + ldt + " (" + ldt + ")");
@@ -130,13 +127,21 @@ public class MedtronicUIPostprocessor {
private void sendNotification(int resourceId, int notificationUrgencyType) {
- Notification notification = new Notification(Notification.MEDTRONIC_PUMP_ALARM, MainApp.gs(resourceId), notificationUrgencyType);
+ Notification notification = new Notification(Notification.MEDTRONIC_PUMP_ALARM, MainApp.gs(resourceId),
+ notificationUrgencyType);
+ MainApp.bus().post(new EventNewNotification(notification));
+ }
+
+
+ private void sendNotification(int resourceId, int notificationUrgencyType, Object... parameters) {
+ Notification notification = new Notification(Notification.MEDTRONIC_PUMP_ALARM, MainApp.gs(resourceId,
+ parameters), notificationUrgencyType);
MainApp.bus().post(new EventNewNotification(notification));
}
private void postProcessSettings(MedtronicUITask uiTask) {
- Map settings = (Map) uiTask.returnData;
+ Map settings = (Map)uiTask.returnData;
MedtronicUtil.setSettings(settings);
@@ -171,17 +176,18 @@ public class MedtronicUIPostprocessor {
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), pumpStatus.maxBolus)) {
LOG.error("Wrong Max Bolus set on Pump (must be {}).", pumpStatus.maxBolus);
- sendNotification(R.string.medtronic_error_pump_wrong_max_bolus_set, Notification.NORMAL);
+ sendNotification(R.string.medtronic_error_pump_wrong_max_bolus_set, Notification.NORMAL,
+ pumpStatus.maxBolus);
}
checkValue = settings.get("PCFG_MAX_BASAL");
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), pumpStatus.maxBasal)) {
LOG.error("Wrong Max Basal set on Pump (must be {}).", pumpStatus.maxBasal);
- sendNotification(R.string.medtronic_error_pump_wrong_max_basal_set, Notification.NORMAL);
+ sendNotification(R.string.medtronic_error_pump_wrong_max_basal_set, Notification.NORMAL,
+ pumpStatus.maxBasal);
}
}
-
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUITask.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUITask.java
index 113910eba5..9db4d3294c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUITask.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/comm/ui/MedtronicUITask.java
@@ -20,21 +20,24 @@ public class MedtronicUITask {
private static final Logger LOG = LoggerFactory.getLogger(MedtronicUITask.class);
public MedtronicCommandType commandType;
- private Object[] parameters;
- private boolean received;
public Object returnData;
String errorDescription;
boolean invalid = false;
+ private Object[] parameters;
+ private boolean received;
+
public MedtronicUITask(MedtronicCommandType commandType) {
this.commandType = commandType;
}
+
public MedtronicUITask(MedtronicCommandType commandType, Object... parameters) {
this.commandType = commandType;
this.parameters = parameters;
}
+
public void execute(MedtronicCommunicationManager communicationManager) {
LOG.warn("@@@ In execute. {}", commandType);
@@ -43,27 +46,27 @@ public class MedtronicUITask {
case PumpModel: {
returnData = communicationManager.getPumpModel();
}
- break;
+ break;
case GetBasalProfileSTD: {
returnData = communicationManager.getBasalProfile();
}
- break;
+ break;
case GetRemainingInsulin: {
returnData = communicationManager.getRemainingInsulin();
}
- break;
+ break;
case RealTimeClock: {
returnData = communicationManager.getPumpTime();
}
- break;
+ break;
case GetBatteryStatus: {
returnData = communicationManager.getRemainingBattery();
}
- break;
+ break;
case SetTemporaryBasal: {
TempBasalPair tbr = getTBRSettings();
@@ -71,29 +74,29 @@ public class MedtronicUITask {
returnData = communicationManager.setTBR(tbr);
}
}
- break;
+ break;
case ReadTemporaryBasal: {
returnData = communicationManager.getTemporaryBasal();
}
- break;
+ break;
case PumpState: {
// TODO maybe remove this, data returned is almost useless
returnData = communicationManager.getPumpState();
}
- break;
+ break;
-// case "RefreshData.GetBolus": {
-// returnData = communicationManager.getBolusStatus();
-// }
-// break;
+ // case "RefreshData.GetBolus": {
+ // returnData = communicationManager.getBolusStatus();
+ // }
+ // break;
case Settings:
case Settings_512: {
returnData = communicationManager.getPumpSettings();
}
- break;
+ break;
case SetBolus: {
Double amount = getDoubleFromParameters(0);
@@ -101,35 +104,35 @@ public class MedtronicUITask {
if (amount != null)
returnData = communicationManager.setBolus(amount);
}
- break;
+ break;
case CancelTBR: {
// FIXME check if TBR is actually running
returnData = communicationManager.cancelTBR();
}
- break;
+ break;
case SetBasalProfileSTD:
case SetBasalProfileA: {
-// Float amount = getAmount();
-//
-// if (amount != null) {
-//
-// BasalProfile profile = new BasalProfile();
-//
-// int basalStrokes1 = MedtronicUtil.getBasalStrokesInt(amount);
-// int basalStrokes2 = MedtronicUtil.getBasalStrokesInt(amount * 2);
-//
-// for (int i = 0; i < 24; i++) {
-// profile.addEntry(new BasalProfileEntry(i % 2 == 0 ? basalStrokes1 : basalStrokes2, i * 2));
-// }
-//
-// returnData = communicationManager.setBasalProfile(profile);
-// }
+ // Float amount = getAmount();
+ //
+ // if (amount != null) {
+ //
+ // BasalProfile profile = new BasalProfile();
+ //
+ // int basalStrokes1 = MedtronicUtil.getBasalStrokesInt(amount);
+ // int basalStrokes2 = MedtronicUtil.getBasalStrokesInt(amount * 2);
+ //
+ // for (int i = 0; i < 24; i++) {
+ // profile.addEntry(new BasalProfileEntry(i % 2 == 0 ? basalStrokes1 : basalStrokes2, i * 2));
+ // }
+ //
+ // returnData = communicationManager.setBasalProfile(profile);
+ // }
}
- break;
+ break;
default: {
LOG.warn("This commandType is not supported (yet) - {}.", commandType);
@@ -138,7 +141,6 @@ public class MedtronicUITask {
}
-
if (returnData == null) {
if (!invalid)
errorDescription = communicationManager.getErrorResponse();
@@ -147,30 +149,30 @@ public class MedtronicUITask {
received = true;
}
-
}
+
private TempBasalPair getTBRSettings() {
- TempBasalPair tempBasalPair = new TempBasalPair(
- getDoubleFromParameters(0), //
- false, //
- getIntegerFromParameters(1));
+ TempBasalPair tempBasalPair = new TempBasalPair(getDoubleFromParameters(0), //
+ false, //
+ getIntegerFromParameters(1));
return tempBasalPair;
}
+
private Float getFloatFromParameters(int index) {
- return (Float) parameters[index];
+ return (Float)parameters[index];
}
public Double getDoubleFromParameters(int index) {
- return (Double) parameters[index];
+ return (Double)parameters[index];
}
public Integer getIntegerFromParameters(int index) {
- return (Integer) parameters[index];
+ return (Integer)parameters[index];
}
@@ -196,12 +198,14 @@ public class MedtronicUITask {
// should never happen
if (invalid) {
- statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating, "Unsupported command in MedtronicUITask");
+ statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
+ "Unsupported command in MedtronicUITask");
MainApp.bus().post(statusChange);
}
if (errorDescription != null) {
- statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating, errorDescription);
+ statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
+ errorDescription);
MainApp.bus().post(statusChange);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfile.java
index 35707cbc9a..540e3618a2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfile.java
@@ -1,40 +1,37 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.data.dto;
+import java.util.ArrayList;
+import java.util.List;
+
import org.joda.time.Instant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
/**
* Created by geoff on 6/1/15.
*
- * There are three basal profiles stored on the pump. (722 only?)
- * They are all parsed the same, the user just has 3 to choose from:
- * Standard, A, and B
+ * There are three basal profiles stored on the pump. (722 only?) They are all parsed the same, the user just has 3 to
+ * choose from: Standard, A, and B
*
- * The byte array seems to be 21 three byte entries long, plus a zero?
- * If the profile is completely empty, it should have one entry: [0,0,0x3F] (?)
- * The first entry of [0,0,0] marks the end of the used entries.
+ * The byte array seems to be 21 three byte entries long, plus a zero? If the profile is completely empty, it should
+ * have one entry: [0,0,0x3F] (?) The first entry of [0,0,0] marks the end of the used entries.
*
- * Each entry is assumed to span from the specified start time to the start time of the
- * next entry, or to midnight if there are no more entries.
+ * Each entry is assumed to span from the specified start time to the start time of the next entry, or to midnight if
+ * there are no more entries.
*
- * Individual entries are of the form [r,z,m] where
- * r is the rate (in 0.025 U increments)
- * z is zero (?)
- * m is the start time-of-day for the basal rate period (in 30 minute increments?)
+ * Individual entries are of the form [r,z,m] where r is the rate (in 0.025 U increments) z is zero (?) m is the start
+ * time-of-day for the basal rate period (in 30 minute increments?)
*/
public class BasalProfile {
- //private static final String TAG = "BasalProfile";
- private static final Logger LOG = LoggerFactory.getLogger(BasalProfile.class);
- private static final boolean DEBUG_BASALPROFILE = false;
protected static final int MAX_RAW_DATA_SIZE = (48 * 3) + 1;
+ // private static final String TAG = "BasalProfile";
+ private static final Logger LOG = LoggerFactory.getLogger(BasalProfile.class);
+ private static final boolean DEBUG_BASALPROFILE = false;
protected byte[] mRawData; // store as byte array to make transport (via parcel) easier
+ List listEntries;
public BasalProfile() {
@@ -47,6 +44,41 @@ public class BasalProfile {
}
+ // this asUINT8 should be combined with Record.asUINT8, and placed in a new util class.
+ protected static int readUnsignedByte(byte b) {
+ return (b < 0) ? b + 256 : b;
+ }
+
+
+ public static void testParser() {
+ byte[] testData = new byte[] {
+ 32, 0, 0, 38, 0, 13, 44, 0, 19, 38, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ /*
+ * from decocare:
+ * _test_schedule = {'total': 22.50, 'schedule': [
+ * { 'start': '12:00A', 'rate': 0.80 },
+ * { 'start': '6:30A', 'rate': 0.95 },
+ * { 'start': '9:30A', 'rate': 1.10 },
+ * { 'start': '2:00P', 'rate': 0.95 },
+ * ]}
+ */
+ BasalProfile profile = new BasalProfile();
+ profile.setRawData(testData);
+ List entries = profile.getEntries();
+ if (entries.isEmpty()) {
+ LOG.error("testParser: failed");
+ } else {
+ for (int i = 0; i < entries.size(); i++) {
+ BasalProfileEntry e = entries.get(i);
+ LOG.debug(String.format("testParser entry #%d: rate: %.2f, start %d:%d", i, e.rate,
+ e.startTime.getHourOfDay(), e.startTime.getMinuteOfHour()));
+ }
+ }
+
+ }
+
+
public void init() {
mRawData = new byte[MAX_RAW_DATA_SIZE];
mRawData[0] = 0;
@@ -55,20 +87,14 @@ public class BasalProfile {
}
- // this asUINT8 should be combined with Record.asUINT8, and placed in a new util class.
- protected static int readUnsignedByte(byte b) {
- return (b < 0) ? b + 256 : b;
- }
-
-
public boolean setRawData(byte[] data) {
if (data == null) {
LOG.error("setRawData: buffer is null!");
return false;
}
- //int len = Math.min(MAX_RAW_DATA_SIZE, data.length);
+ // int len = Math.min(MAX_RAW_DATA_SIZE, data.length);
mRawData = data;
- //System.arraycopy(data, 0, mRawData, 0, len);
+ // System.arraycopy(data, 0, mRawData, 0, len);
if (DEBUG_BASALPROFILE) {
LOG.debug(String.format("setRawData: copied raw data buffer of %d bytes.", data.length));
}
@@ -82,7 +108,8 @@ public class BasalProfile {
for (int i = 0; i < entries.size(); i++) {
BasalProfileEntry entry = entries.get(i);
String startString = entry.startTime.toString("HH:mm");
- LOG.debug(String.format("Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)", i + 1, entry.rate, entry.rate_raw, startString, entry.startTime_raw));
+ LOG.debug(String.format("Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)", i + 1, entry.rate,
+ entry.rate_raw, startString, entry.startTime_raw));
}
}
@@ -95,7 +122,8 @@ public class BasalProfile {
BasalProfileEntry entry = entries.get(i);
String startString = entry.startTime.toString("HH:mm");
- sb.append(String.format("Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)\n", i + 1, entry.rate, entry.rate_raw, startString, entry.startTime_raw));
+ sb.append(String.format("Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)\n", i + 1, entry.rate,
+ entry.rate_raw, startString, entry.startTime_raw));
}
return sb.toString();
@@ -108,10 +136,11 @@ public class BasalProfile {
BasalProfileEntry rval = new BasalProfileEntry();
List entries = getEntries();
if (entries.size() == 0) {
- LOG.warn(String.format("getEntryForTime(%s): table is empty", when.toDateTime().toLocalTime().toString("HH:mm")));
+ LOG.warn(String.format("getEntryForTime(%s): table is empty",
+ when.toDateTime().toLocalTime().toString("HH:mm")));
return rval;
}
- //Log.w(TAG,"Assuming first entry");
+ // Log.w(TAG,"Assuming first entry");
rval = entries.get(0);
if (entries.size() == 1) {
LOG.debug("getEntryForTime: Only one entry in profile");
@@ -124,7 +153,8 @@ public class BasalProfile {
while (!done) {
BasalProfileEntry entry = entries.get(i);
if (DEBUG_BASALPROFILE) {
- LOG.debug(String.format("Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime().toString("HH:mm"), entry.startTime.toString("HH:mm")));
+ LOG.debug(String.format("Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime()
+ .toString("HH:mm"), entry.startTime.toString("HH:mm")));
}
if (localMillis >= entry.startTime.getMillisOfDay()) {
rval = entry;
@@ -142,7 +172,9 @@ public class BasalProfile {
}
}
if (DEBUG_BASALPROFILE) {
- LOG.debug(String.format("getEntryForTime(%s): Returning entry: rate=%.3f (%d), start=%s (%d)", when.toDateTime().toLocalTime().toString("HH:mm"), rval.rate, rval.rate_raw, rval.startTime.toString("HH:mm"), rval.startTime_raw));
+ LOG.debug(String.format("getEntryForTime(%s): Returning entry: rate=%.3f (%d), start=%s (%d)", when
+ .toDateTime().toLocalTime().toString("HH:mm"), rval.rate, rval.rate_raw,
+ rval.startTime.toString("HH:mm"), rval.startTime_raw));
}
return rval;
}
@@ -160,7 +192,7 @@ public class BasalProfile {
int r, st;
while (!done) {
- r = MedtronicUtil.makeUnsignedShort(mRawData[i + 1], mRawData[i]); //readUnsignedByte(mRawData[i]);
+ r = MedtronicUtil.makeUnsignedShort(mRawData[i + 1], mRawData[i]); // readUnsignedByte(mRawData[i]);
// What is mRawData[i+1]? Not used in decocare.
st = readUnsignedByte(mRawData[i + 2]);
entries.add(new BasalProfileEntry(r, st));
@@ -175,9 +207,6 @@ public class BasalProfile {
}
- List listEntries;
-
-
/**
* This is used to prepare new profile
*
@@ -203,11 +232,11 @@ public class BasalProfile {
outData.add(profileEntry.rate_raw[0]);
outData.add(profileEntry.rate_raw[1]);
- //int time = profileEntry.startTime.getHourOfDay();
+ // int time = profileEntry.startTime.getHourOfDay();
- //if (profileEntry.startTime.getMinuteOfHour() == 30) {
- // time++;
- //}
+ // if (profileEntry.startTime.getMinuteOfHour() == 30) {
+ // time++;
+ // }
outData.add(profileEntry.startTime_raw);
}
@@ -218,31 +247,7 @@ public class BasalProfile {
}
- public static void testParser() {
- byte[] testData = new byte[]{32, 0, 0, 38, 0, 13, 44, 0, 19, 38, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- /* from decocare:
- _test_schedule = {'total': 22.50, 'schedule': [
- { 'start': '12:00A', 'rate': 0.80 },
- { 'start': '6:30A', 'rate': 0.95 },
- { 'start': '9:30A', 'rate': 1.10 },
- { 'start': '2:00P', 'rate': 0.95 },
- ]}
- */
- BasalProfile profile = new BasalProfile();
- profile.setRawData(testData);
- List entries = profile.getEntries();
- if (entries.isEmpty()) {
- LOG.error("testParser: failed");
- } else {
- for (int i = 0; i < entries.size(); i++) {
- BasalProfileEntry e = entries.get(i);
- LOG.debug(String.format("testParser entry #%d: rate: %.2f, start %d:%d", i, e.rate, e.startTime.getHourOfDay(), e.startTime.getMinuteOfHour()));
- }
- }
-
- }
-
-
+ // TODO extend to be done by half hour
public Double[] getProfilesByHour() {
List entries = getEntries();
@@ -252,8 +257,7 @@ public class BasalProfile {
for (int i = 0; i < entries.size(); i++) {
BasalProfileEntry current = entries.get(i);
- int currentTime = (current.startTime_raw % 2 == 0) ?
- current.startTime_raw : current.startTime_raw - 1;
+ int currentTime = (current.startTime_raw % 2 == 0) ? current.startTime_raw : current.startTime_raw - 1;
currentTime = (currentTime * 30) / 60;
@@ -263,27 +267,27 @@ public class BasalProfile {
} else {
BasalProfileEntry basalProfileEntry = entries.get(i + 1);
- int rawTime = (basalProfileEntry.startTime_raw % 2 == 0) ?
- basalProfileEntry.startTime_raw : basalProfileEntry.startTime_raw - 1;
+ int rawTime = (basalProfileEntry.startTime_raw % 2 == 0) ? basalProfileEntry.startTime_raw
+ : basalProfileEntry.startTime_raw - 1;
lastHour = (rawTime * 30) / 60;
}
- //System.out.println("Current time: " + currentTime + " Next Time: " + lastHour);
+ // System.out.println("Current time: " + currentTime + " Next Time: " + lastHour);
for (int j = currentTime; j < lastHour; j++) {
basalByHour[j] = current.rate;
}
}
-// StringBuilder sb = new StringBuilder();
-//
-// for (int i = 0; i < 24; i++) {
-// sb.append("" + i + "=" + basalByHour[i]);
-// sb.append("\n");
-// }
-//
-// System.out.println("Basal Profile: \n" + sb.toString());
+ // StringBuilder sb = new StringBuilder();
+ //
+ // for (int i = 0; i < 24; i++) {
+ // sb.append("" + i + "=" + basalByHour[i]);
+ // sb.append("\n");
+ // }
+ //
+ // System.out.println("Basal Profile: \n" + sb.toString());
return basalByHour;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfileEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfileEntry.java
index 44b982c360..09453480fb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfileEntry.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BasalProfileEntry.java
@@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
* - fixed rate is not one bit but two
*/
public class BasalProfileEntry {
+
public byte[] rate_raw;
public double rate;
public byte startTime_raw;
@@ -20,7 +21,7 @@ public class BasalProfileEntry {
rate = -9.999E6;
rate_raw = MedtronicUtil.getByteArrayFromUnsignedShort(0xFF, true);
startTime = new LocalTime(0);
- startTime_raw = (byte) 0xFF;
+ startTime_raw = (byte)0xFF;
}
@@ -29,7 +30,7 @@ public class BasalProfileEntry {
// startTimeByte is time-of-day, in 30 minute increments
rate_raw = MedtronicUtil.getByteArrayFromUnsignedShort(rateStrokes, true);
rate = rateStrokes * 0.025;
- startTime_raw = (byte) startTimeInterval;
+ startTime_raw = (byte)startTimeInterval;
startTime = new LocalTime(startTimeInterval / 2, (startTimeInterval % 2) * 30);
}
@@ -39,7 +40,7 @@ public class BasalProfileEntry {
// startTimeByte is time-of-day, in 30 minute increments
rate_raw = MedtronicUtil.getByteArrayFromUnsignedShort(rateByte, true);
rate = rateByte * 0.025;
- startTime_raw = (byte) startTimeByte;
+ startTime_raw = (byte)startTimeByte;
startTime = new LocalTime(startTimeByte / 2, (startTimeByte % 2) * 30);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BatteryStatusDTO.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BatteryStatusDTO.java
index cf51736712..0aa3423570 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BatteryStatusDTO.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BatteryStatusDTO.java
@@ -15,10 +15,9 @@ public class BatteryStatusDTO {
public int getCalculatedPercent(BatteryType batteryType) {
double percent = (voltage - batteryType.lowVoltage) / (batteryType.highVoltage - batteryType.lowVoltage);
- return (int) (percent * 100.0d);
+ return (int)(percent * 100.0d);
}
-
public enum BatteryStatusType {
Normal,
Low,
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BolusDTO.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BolusDTO.java
index 0fe2c2f817..3add8d5c74 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BolusDTO.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMedtronic/data/dto/BolusDTO.java
@@ -4,27 +4,22 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpBolusType;
/**
- * Application: GGC - GNU Gluco Control
- * Plug-in: Pump Tool (support for Pump devices)
+ * Application: GGC - GNU Gluco Control
+ * Plug-in: Pump Tool (support for Pump devices)
*
* See AUTHORS for copyright information.
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
* version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*