fix logging
This commit is contained in:
parent
7b773ae800
commit
bb39dd994a
13 changed files with 146 additions and 148 deletions
|
@ -26,7 +26,7 @@ class AAPSLoggerProduction : AAPSLogger {
|
||||||
|
|
||||||
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
|
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
|
||||||
if (L.isEnabled(tag.tag))
|
if (L.isEnabled(tag.tag))
|
||||||
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + String.format(format, arguments))
|
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + format, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun warn(tag: LTag, message: String) {
|
override fun warn(tag: LTag, message: String) {
|
||||||
|
@ -36,7 +36,7 @@ class AAPSLoggerProduction : AAPSLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
|
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
|
||||||
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + String.format(format, arguments))
|
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + format, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun info(tag: LTag, message: String) {
|
override fun info(tag: LTag, message: String) {
|
||||||
|
@ -47,7 +47,7 @@ class AAPSLoggerProduction : AAPSLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
|
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
|
||||||
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + String.format(format, arguments))
|
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + format, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun error(tag: LTag, message: String) {
|
override fun error(tag: LTag, message: String) {
|
||||||
|
@ -65,7 +65,7 @@ class AAPSLoggerProduction : AAPSLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun error(format: String, vararg arguments: Any?) {
|
override fun error(format: String, vararg arguments: Any?) {
|
||||||
LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + String.format(format, arguments))
|
LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + format, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun error(tag: LTag, message: String, throwable: Throwable) {
|
override fun error(tag: LTag, message: String, throwable: Throwable) {
|
||||||
|
@ -76,7 +76,7 @@ class AAPSLoggerProduction : AAPSLogger {
|
||||||
|
|
||||||
override fun error(tag: LTag, format: String, vararg arguments: Any?) {
|
override fun error(tag: LTag, format: String, vararg arguments: Any?) {
|
||||||
if (L.isEnabled(tag.tag)) {
|
if (L.isEnabled(tag.tag)) {
|
||||||
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + String.format(format, arguments))
|
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + format, arguments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ import info.nightscout.androidaps.logging.L;
|
||||||
|
|
||||||
public class TempBasalPair {
|
public class TempBasalPair {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
protected double insulinRate = 0.0d;
|
protected double insulinRate = 0.0d;
|
||||||
@Expose
|
@Expose
|
||||||
|
|
|
@ -83,7 +83,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
// internal flag
|
// internal flag
|
||||||
boolean showPumpMessages = true;
|
boolean showPumpMessages = true;
|
||||||
if (showPumpMessages) {
|
if (showPumpMessages) {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Sent:" + ByteUtil.shortHexString(msg.getTxData()));
|
aapsLogger.info(LTag.PUMPCOMM, "Sent:" + ByteUtil.shortHexString(msg.getTxData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(injector, msg.getTxData()),
|
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(injector, msg.getTxData()),
|
||||||
|
@ -96,7 +96,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
// Mark this as the last time we heard from the pump.
|
// Mark this as the last time we heard from the pump.
|
||||||
rememberLastGoodDeviceCommunicationTime();
|
rememberLastGoodDeviceCommunicationTime();
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Response is invalid ! [interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", rfSpyResponse.wasInterrupted(),
|
aapsLogger.warn(LTag.PUMPCOMM, "isDeviceReachable. Response is invalid ! [interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", rfSpyResponse.wasInterrupted(),
|
||||||
rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam());
|
rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam());
|
||||||
|
|
||||||
if (rfSpyResponse.wasTimeout()) {
|
if (rfSpyResponse.wasTimeout()) {
|
||||||
|
@ -106,7 +106,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
long diff = System.currentTimeMillis() - getPumpStatus().lastConnection;
|
long diff = System.currentTimeMillis() - getPumpStatus().lastConnection;
|
||||||
|
|
||||||
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "We reached max time that Pump can be unreachable. Starting Tuning.");
|
aapsLogger.warn(LTag.PUMPCOMM, "We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||||
serviceTaskExecutor.startTask(new WakeAndTuneTask(injector));
|
serviceTaskExecutor.startTask(new WakeAndTuneTask(injector));
|
||||||
timeoutCount = 0;
|
timeoutCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showPumpMessages) {
|
if (showPumpMessages) {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Received:" + ByteUtil.shortHexString(rfSpyResponse.getRadioResponse(injector).getPayload()));
|
aapsLogger.info(LTag.PUMPCOMM, "Received:" + ByteUtil.shortHexString(rfSpyResponse.getRadioResponse(injector).getPayload()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -156,18 +156,18 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
nextWakeUpRequired = 0L;
|
nextWakeUpRequired = 0L;
|
||||||
|
|
||||||
if (System.currentTimeMillis() > nextWakeUpRequired) {
|
if (System.currentTimeMillis() > nextWakeUpRequired) {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Waking pump...");
|
aapsLogger.info(LTag.PUMPCOMM, "Waking pump...");
|
||||||
|
|
||||||
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
||||||
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 200,
|
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 200,
|
||||||
(byte) 0, (byte) 0, 25000, (byte) 0);
|
(byte) 0, (byte) 0, 25000, (byte) 0);
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
aapsLogger.info(LTag.PUMPCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
||||||
|
|
||||||
// FIXME wakeUp successful !!!!!!!!!!!!!!!!!!
|
// FIXME wakeUp successful !!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
nextWakeUpRequired = System.currentTimeMillis() + (receiverDeviceAwakeForMinutes * 60 * 1000);
|
nextWakeUpRequired = System.currentTimeMillis() + (receiverDeviceAwakeForMinutes * 60 * 1000);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Last pump communication was recent, not waking pump.");
|
aapsLogger.debug(LTag.PUMPCOMM, "Last pump communication was recent, not waking pump.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// long lastGoodPlus = getLastGoodReceiverCommunicationTime() + (receiverDeviceAwakeForMinutes * 60 * 1000);
|
// long lastGoodPlus = getLastGoodReceiverCommunicationTime() + (receiverDeviceAwakeForMinutes * 60 * 1000);
|
||||||
|
@ -224,7 +224,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
|
|
||||||
|
|
||||||
private double scanForDevice(double[] frequencies) {
|
private double scanForDevice(double[] frequencies) {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Scanning for receiver ({})", receiverDeviceID);
|
aapsLogger.info(LTag.PUMPCOMM, "Scanning for receiver ({})", receiverDeviceID);
|
||||||
wakeUp(receiverDeviceAwakeForMinutes, false);
|
wakeUp(receiverDeviceAwakeForMinutes, false);
|
||||||
FrequencyScanResults results = new FrequencyScanResults();
|
FrequencyScanResults results = new FrequencyScanResults();
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 0,
|
RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 0,
|
||||||
(byte) 0, (byte) 0, 1250, (byte) 0);
|
(byte) 0, (byte) 0, 1250, (byte) 0);
|
||||||
if (resp.wasTimeout()) {
|
if (resp.wasTimeout()) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: Failed to find pump at frequency {}", frequencies[i]);
|
aapsLogger.error(LTag.PUMPCOMM, "scanForPump: Failed to find pump at frequency {}", frequencies[i]);
|
||||||
} else if (resp.looksLikeRadioPacket()) {
|
} else if (resp.looksLikeRadioPacket()) {
|
||||||
RadioResponse radioResponse = new RadioResponse(injector);
|
RadioResponse radioResponse = new RadioResponse(injector);
|
||||||
|
|
||||||
|
@ -255,17 +255,17 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
trial.rssiList.add(rssi);
|
trial.rssiList.add(rssi);
|
||||||
trial.successes++;
|
trial.successes++;
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
aapsLogger.warn(LTag.PUMPCOMM, "Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||||
trial.rssiList.add(-99);
|
trial.rssiList.add(-99);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException rle) {
|
} catch (RileyLinkCommunicationException rle) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
aapsLogger.warn(LTag.PUMPCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||||
trial.rssiList.add(-99);
|
trial.rssiList.add(-99);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
aapsLogger.error(LTag.PUMPCOMM, "scanForPump: raw response is " + ByteUtil.shortHexString(resp.getRaw()));
|
||||||
trial.rssiList.add(-99);
|
trial.rssiList.add(-99);
|
||||||
}
|
}
|
||||||
trial.tries++;
|
trial.tries++;
|
||||||
|
@ -297,10 +297,10 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
results.bestFrequencyMHz = bestTrial.frequencyMHz;
|
results.bestFrequencyMHz = bestTrial.frequencyMHz;
|
||||||
if (bestTrial.successes > 0) {
|
if (bestTrial.successes > 0) {
|
||||||
rfspy.setBaseFrequency(results.bestFrequencyMHz);
|
rfspy.setBaseFrequency(results.bestFrequencyMHz);
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Best frequency found: " + results.bestFrequencyMHz);
|
aapsLogger.debug(LTag.PUMPCOMM, "Best frequency found: " + results.bestFrequencyMHz);
|
||||||
return results.bestFrequencyMHz;
|
return results.bestFrequencyMHz;
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "No pump response during scan.");
|
aapsLogger.error(LTag.PUMPCOMM, "No pump response during scan.");
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,22 +329,22 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
RadioPacket pkt = new RadioPacket(injector, pumpMsgContent);
|
RadioPacket pkt = new RadioPacket(injector, pumpMsgContent);
|
||||||
RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0);
|
RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0);
|
||||||
if (resp.wasTimeout()) {
|
if (resp.wasTimeout()) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: no pump response at frequency {}", freqMHz);
|
aapsLogger.warn(LTag.PUMPCOMM, "tune_tryFrequency: no pump response at frequency {}", freqMHz);
|
||||||
} else if (resp.looksLikeRadioPacket()) {
|
} else if (resp.looksLikeRadioPacket()) {
|
||||||
RadioResponse radioResponse = new RadioResponse(injector);
|
RadioResponse radioResponse = new RadioResponse(injector);
|
||||||
try {
|
try {
|
||||||
radioResponse.init(resp.getRaw());
|
radioResponse.init(resp.getRaw());
|
||||||
|
|
||||||
if (radioResponse.isValid()) {
|
if (radioResponse.isValid()) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz);
|
aapsLogger.warn(LTag.PUMPCOMM, "tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz);
|
||||||
return calculateRssi(radioResponse.rssi);
|
return calculateRssi(radioResponse.rssi);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: invalid radio response:"
|
aapsLogger.warn(LTag.PUMPCOMM, "tune_tryFrequency: invalid radio response:"
|
||||||
+ ByteUtil.shortHexString(radioResponse.getPayload()));
|
+ ByteUtil.shortHexString(radioResponse.getPayload()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
aapsLogger.warn(LTag.PUMPCOMM, "Failed to decode radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,13 +371,13 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
}
|
}
|
||||||
if (betterFrequency == 0.0) {
|
if (betterFrequency == 0.0) {
|
||||||
// we've failed... caller should try a full scan for pump
|
// we've failed... caller should try a full scan for pump
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "quickTuneForPump: failed to find pump");
|
aapsLogger.error(LTag.PUMPCOMM, "quickTuneForPump: failed to find pump");
|
||||||
} else {
|
} else {
|
||||||
rfspy.setBaseFrequency(betterFrequency);
|
rfspy.setBaseFrequency(betterFrequency);
|
||||||
if (betterFrequency != startFrequencyMHz) {
|
if (betterFrequency != startFrequencyMHz) {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: new frequency is {}MHz", betterFrequency);
|
aapsLogger.info(LTag.PUMPCOMM, "quickTuneForPump: new frequency is {}MHz", betterFrequency);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz);
|
aapsLogger.info(LTag.PUMPCOMM, "quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return betterFrequency;
|
return betterFrequency;
|
||||||
|
@ -385,7 +385,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
|
|
||||||
|
|
||||||
private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) {
|
private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) {
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Doing quick radio tune for receiver ({})", receiverDeviceID);
|
aapsLogger.info(LTag.PUMPCOMM, "Doing quick radio tune for receiver ({})", receiverDeviceID);
|
||||||
wakeUp(false);
|
wakeUp(false);
|
||||||
int startRssi = tune_tryFrequency(startFrequencyMHz);
|
int startRssi = tune_tryFrequency(startFrequencyMHz);
|
||||||
double lowerFrequency = startFrequencyMHz - stepSizeMHz;
|
double lowerFrequency = startFrequencyMHz - stepSizeMHz;
|
||||||
|
@ -423,7 +423,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
// Might still be zero, but that's fine.
|
// Might still be zero, but that's fine.
|
||||||
}
|
}
|
||||||
double minutesAgo = (System.currentTimeMillis() - lastGoodReceiverCommunicationTime) / (1000.0 * 60.0);
|
double minutesAgo = (System.currentTimeMillis() - lastGoodReceiverCommunicationTime) / (1000.0 * 60.0);
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Last good pump communication was " + minutesAgo + " minutes ago.");
|
aapsLogger.debug(LTag.PUMPCOMM, "Last good pump communication was " + minutesAgo + " minutes ago.");
|
||||||
return lastGoodReceiverCommunicationTime;
|
return lastGoodReceiverCommunicationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,13 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
super.onReceive(context, intent);
|
super.onReceive(context, intent);
|
||||||
|
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
aapsLogger.error("onReceive: received null intent");
|
aapsLogger.error(LTag.PUMPCOMM, "onReceive: received null intent");
|
||||||
} else {
|
} else {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
aapsLogger.error("onReceive: null action");
|
aapsLogger.error("onReceive: null action");
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Received Broadcast: " + action);
|
aapsLogger.debug(LTag.PUMPCOMM, "Received Broadcast: " + action);
|
||||||
|
|
||||||
if (!processBluetoothBroadcasts(action) && //
|
if (!processBluetoothBroadcasts(action) && //
|
||||||
!processRileyLinkBroadcasts(action, context) && //
|
!processRileyLinkBroadcasts(action, context) && //
|
||||||
|
@ -106,7 +106,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
!processDeviceSpecificBroadcasts(action, intent) && //
|
!processDeviceSpecificBroadcasts(action, intent) && //
|
||||||
!processApplicationSpecificBroadcasts(action, intent) //
|
!processApplicationSpecificBroadcasts(action, intent) //
|
||||||
) {
|
) {
|
||||||
aapsLogger.error("Unhandled broadcast: action=" + action);
|
aapsLogger.error(LTag.PUMPCOMM, "Unhandled broadcast: action=" + action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
return true;
|
return true;
|
||||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
|
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "MedtronicConst.Intents.RileyLinkReady");
|
aapsLogger.warn(LTag.PUMPCOMM, "MedtronicConst.Intents.RileyLinkReady");
|
||||||
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
||||||
|
|
||||||
serviceInstance.rileyLinkBLE.enableNotifications();
|
serviceInstance.rileyLinkBLE.enableNotifications();
|
||||||
|
@ -155,16 +155,16 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion;
|
RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion;
|
||||||
|
|
||||||
// if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): " + bleVersion);
|
aapsLogger.debug(LTag.PUMPCOMM, "RfSpy version (BLE113): " + bleVersion);
|
||||||
serviceInstance.rileyLinkServiceData.versionBLE113 = bleVersion;
|
serviceInstance.rileyLinkServiceData.versionBLE113 = bleVersion;
|
||||||
|
|
||||||
// if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name());
|
aapsLogger.debug(LTag.PUMPCOMM, "RfSpy Radio version (CC110): " + rlVersion.name());
|
||||||
serviceInstance.rileyLinkServiceData.versionCC110 = rlVersion;
|
serviceInstance.rileyLinkServiceData.versionCC110 = rlVersion;
|
||||||
|
|
||||||
ServiceTask task = new InitializePumpManagerTask(injector, context);
|
ServiceTask task = new InitializePumpManagerTask(injector, context);
|
||||||
serviceTaskExecutor.startTask(task);
|
serviceTaskExecutor.startTask(task);
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Announcing RileyLink open For business");
|
aapsLogger.info(LTag.PUMPCOMM, "Announcing RileyLink open For business");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkNewAddressSet)) {
|
} else if (action.equals(RileyLinkConst.Intents.RileyLinkNewAddressSet)) {
|
||||||
|
@ -193,13 +193,13 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
public boolean processBluetoothBroadcasts(String action) {
|
public boolean processBluetoothBroadcasts(String action) {
|
||||||
|
|
||||||
if (action.equals(RileyLinkConst.Intents.BluetoothConnected)) {
|
if (action.equals(RileyLinkConst.Intents.BluetoothConnected)) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Bluetooth - Connected");
|
aapsLogger.debug(LTag.PUMPCOMM, "Bluetooth - Connected");
|
||||||
serviceTaskExecutor.startTask(new DiscoverGattServicesTask(injector));
|
serviceTaskExecutor.startTask(new DiscoverGattServicesTask(injector));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (action.equals(RileyLinkConst.Intents.BluetoothReconnected)) {
|
} else if (action.equals(RileyLinkConst.Intents.BluetoothReconnected)) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Bluetooth - Reconnecting");
|
aapsLogger.debug(LTag.PUMPCOMM, "Bluetooth - Reconnecting");
|
||||||
|
|
||||||
serviceInstance.bluetoothInit();
|
serviceInstance.bluetoothInit();
|
||||||
serviceTaskExecutor.startTask(new DiscoverGattServicesTask(injector, true));
|
serviceTaskExecutor.startTask(new DiscoverGattServicesTask(injector, true));
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class InitializePumpManagerTask extends ServiceTask {
|
||||||
|
|
||||||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency);
|
aapsLogger.info(LTag.PUMPCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency);
|
||||||
|
|
||||||
rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
|
rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
for (int retry = 0; retry < 5; retry++) {
|
for (int retry = 0; retry < 5; retry++) {
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "isDeviceReachable. Waking pump... " + (retry != 0 ? " (retry " + retry + ")" : ""));
|
aapsLogger.debug(LTag.PUMPCOMM, "isDeviceReachable. Waking pump... " + (retry != 0 ? " (retry " + retry + ")" : ""));
|
||||||
|
|
||||||
boolean connected = connectToDevice();
|
boolean connected = connectToDevice();
|
||||||
|
|
||||||
|
@ -152,10 +152,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
||||||
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 200,
|
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 200,
|
||||||
(byte) 0, (byte) 0, 25000, (byte) 0);
|
(byte) 0, (byte) 0, 25000, (byte) 0);
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
aapsLogger.info(LTag.PUMPCOMM, "wakeup: raw response is " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
|
|
||||||
if (rfSpyResponse.wasTimeout()) {
|
if (rfSpyResponse.wasTimeout()) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "isDeviceReachable. Failed to find pump (timeout).");
|
aapsLogger.error(LTag.PUMPCOMM, "isDeviceReachable. Failed to find pump (timeout).");
|
||||||
} else if (rfSpyResponse.looksLikeRadioPacket()) {
|
} else if (rfSpyResponse.looksLikeRadioPacket()) {
|
||||||
RadioResponse radioResponse = new RadioResponse(injector);
|
RadioResponse radioResponse = new RadioResponse(injector);
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
PumpMessage pumpResponse = createResponseMessage(radioResponse.getPayload(), PumpMessage.class);
|
PumpMessage pumpResponse = createResponseMessage(radioResponse.getPayload(), PumpMessage.class);
|
||||||
|
|
||||||
if (!pumpResponse.isValid()) {
|
if (!pumpResponse.isValid()) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(),
|
aapsLogger.warn(LTag.PUMPCOMM, "Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(),
|
||||||
rfSpyResponse.wasTimeout());
|
rfSpyResponse.wasTimeout());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
medtronicUtil.setMedtronicPumpModel(pumpModel);
|
medtronicUtil.setMedtronicPumpModel(pumpModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid,
|
aapsLogger.debug(LTag.PUMPCOMM, "isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid,
|
||||||
radioResponse.rssi);
|
radioResponse.rssi);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
@ -204,17 +204,17 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Failed to parse radio response: "
|
aapsLogger.warn(LTag.PUMPCOMM, "isDeviceReachable. Failed to parse radio response: "
|
||||||
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Failed to decode radio response: "
|
aapsLogger.warn(LTag.PUMPCOMM, "isDeviceReachable. Failed to decode radio response: "
|
||||||
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Unknown response: " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
aapsLogger.warn(LTag.PUMPCOMM, "isDeviceReachable. Unknown response: " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -230,7 +230,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
private PumpMessage runCommandWithArgs(PumpMessage msg) throws RileyLinkCommunicationException {
|
private PumpMessage runCommandWithArgs(PumpMessage msg) throws RileyLinkCommunicationException {
|
||||||
|
|
||||||
if (debugSetCommands)
|
if (debugSetCommands)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Args: ");
|
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: ");
|
||||||
|
|
||||||
PumpMessage rval;
|
PumpMessage rval;
|
||||||
PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[]{0}));
|
PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[]{0}));
|
||||||
|
@ -238,15 +238,15 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
PumpMessage shortResponse = sendAndListen(shortMessage);
|
PumpMessage shortResponse = sendAndListen(shortMessage);
|
||||||
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
|
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
|
||||||
if (debugSetCommands)
|
if (debugSetCommands)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Args: Got ACK response");
|
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Args: Got ACK response");
|
||||||
|
|
||||||
rval = sendAndListen(msg);
|
rval = sendAndListen(msg);
|
||||||
if (debugSetCommands)
|
if (debugSetCommands)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "2nd Response: {}", rval);
|
aapsLogger.debug(LTag.PUMPCOMM, "2nd Response: {}", rval);
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "runCommandWithArgs: Pump did not ack Attention packet");
|
aapsLogger.error(LTag.PUMPCOMM, "runCommandWithArgs: Pump did not ack Attention packet");
|
||||||
return new PumpMessage(aapsLogger, "No ACK after Attention packet.");
|
return new PumpMessage(aapsLogger, "No ACK after Attention packet.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
|
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
|
||||||
throws RileyLinkCommunicationException {
|
throws RileyLinkCommunicationException {
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Frames: {}", commandType.name());
|
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: {}", commandType.name());
|
||||||
|
|
||||||
PumpMessage rval = null;
|
PumpMessage rval = null;
|
||||||
PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0}));
|
PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0}));
|
||||||
|
@ -263,11 +263,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
PumpMessage shortResponse = sendAndListen(shortMessage);
|
PumpMessage shortResponse = sendAndListen(shortMessage);
|
||||||
|
|
||||||
if (shortResponse.commandType != MedtronicCommandType.CommandACK) {
|
if (shortResponse.commandType != MedtronicCommandType.CommandACK) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "runCommandWithFrames: Pump did not ack Attention packet");
|
aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ack Attention packet");
|
||||||
|
|
||||||
return new PumpMessage(aapsLogger, "No ACK after start message.");
|
return new PumpMessage(aapsLogger, "No ACK after start message.");
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Frames: Got ACK response for Attention packet");
|
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: Got ACK response for Attention packet");
|
||||||
}
|
}
|
||||||
|
|
||||||
int frameNr = 1;
|
int frameNr = 1;
|
||||||
|
@ -276,23 +276,23 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
byte[] frameData = medtronicUtil.createByteArray(frame);
|
byte[] frameData = medtronicUtil.createByteArray(frame);
|
||||||
|
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"Frame {} data:\n{}", frameNr, ByteUtil.getCompactString(frameData));
|
// aapsLogger.debug(LTag.PUMPCOMM,"Frame {} data:\n{}", frameNr, ByteUtil.getCompactString(frameData));
|
||||||
|
|
||||||
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(frameData));
|
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(frameData));
|
||||||
|
|
||||||
rval = sendAndListen(msg);
|
rval = sendAndListen(msg);
|
||||||
|
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"PumpResponse: " + rval);
|
// aapsLogger.debug(LTag.PUMPCOMM,"PumpResponse: " + rval);
|
||||||
|
|
||||||
if (rval.commandType != MedtronicCommandType.CommandACK) {
|
if (rval.commandType != MedtronicCommandType.CommandACK) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "runCommandWithFrames: Pump did not ACK frame #{}", frameNr);
|
aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #{}", frameNr);
|
||||||
|
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "Run command with Frames FAILED (command={}, response={})", commandType.name(),
|
aapsLogger.error(LTag.PUMPCOMM, "Run command with Frames FAILED (command={}, response={})", commandType.name(),
|
||||||
rval.toString());
|
rval.toString());
|
||||||
|
|
||||||
return new PumpMessage(aapsLogger, "No ACK after frame #" + frameNr);
|
return new PumpMessage(aapsLogger, "No ACK after frame #" + frameNr);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Run command with Frames: Got ACK response for frame #{}", (frameNr));
|
aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: Got ACK response for frame #{}", (frameNr));
|
||||||
}
|
}
|
||||||
|
|
||||||
frameNr++;
|
frameNr++;
|
||||||
|
@ -311,7 +311,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
if (doWakeUpBeforeCommand)
|
if (doWakeUpBeforeCommand)
|
||||||
wakeUp(receiverDeviceAwakeForMinutes, false);
|
wakeUp(receiverDeviceAwakeForMinutes, false);
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Current command: " + medtronicUtil.getCurrentCommand());
|
aapsLogger.debug(LTag.PUMPCOMM, "Current command: " + medtronicUtil.getCurrentCommand());
|
||||||
|
|
||||||
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Active);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Active);
|
||||||
boolean doneWithError = false;
|
boolean doneWithError = false;
|
||||||
|
@ -323,8 +323,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
|
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
|
||||||
new GetHistoryPageCarelinkMessageBody(pageNumber));
|
new GetHistoryPageCarelinkMessageBody(pageNumber));
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "getPumpHistory: Page {}", pageNumber);
|
aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Page {}", pageNumber);
|
||||||
// aapsLogger.info(LTag.PUMPBTCOMM,"getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData()));
|
// aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData()));
|
||||||
// Ask the pump to transfer history (we get first frame?)
|
// Ask the pump to transfer history (we get first frame?)
|
||||||
|
|
||||||
PumpMessage firstResponse = null;
|
PumpMessage firstResponse = null;
|
||||||
|
@ -339,7 +339,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
failed = false;
|
failed = false;
|
||||||
break;
|
break;
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "First call for PumpHistory failed (retry={})", retries);
|
aapsLogger.error(LTag.PUMPCOMM, "First call for PumpHistory failed (retry={})", retries);
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// aapsLogger.info(LTag.PUMPBTCOMM,"getPumpHistoryPage("+pageNumber+"): " + ByteUtil.shortHexString(firstResponse.getContents()));
|
// aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): " + ByteUtil.shortHexString(firstResponse.getContents()));
|
||||||
|
|
||||||
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
|
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
|
||||||
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
|
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
|
||||||
|
@ -366,7 +366,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
&& currentResponse.getFrameNumber() == expectedFrameNum) {
|
&& currentResponse.getFrameNumber() == expectedFrameNum) {
|
||||||
// success! got a frame.
|
// success! got a frame.
|
||||||
if (frameData.length != 64) {
|
if (frameData.length != 64) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Expected frame of length 64, got frame of length " + frameData.length);
|
aapsLogger.warn(LTag.PUMPCOMM, "Expected frame of length 64, got frame of length " + frameData.length);
|
||||||
// but append it anyway?
|
// but append it anyway?
|
||||||
}
|
}
|
||||||
// handle successful frame data
|
// handle successful frame data
|
||||||
|
@ -376,7 +376,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
medtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber,
|
medtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber,
|
||||||
currentResponse.getFrameNumber());
|
currentResponse.getFrameNumber());
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "getPumpHistory: Got frame {} of Page {}", currentResponse.getFrameNumber(), pageNumber);
|
aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Got frame {} of Page {}", currentResponse.getFrameNumber(), pageNumber);
|
||||||
// Do we need to ask for the next frame?
|
// Do we need to ask for the next frame?
|
||||||
if (expectedFrameNum < 16) { // This number may not be correct for pumps other than 522/722
|
if (expectedFrameNum < 16) { // This number may not be correct for pumps other than 522/722
|
||||||
expectedFrameNum++;
|
expectedFrameNum++;
|
||||||
|
@ -385,16 +385,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (frameData == null) {
|
if (frameData == null) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "null frame data, retrying");
|
aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying");
|
||||||
} else if (currentResponse.getFrameNumber() != expectedFrameNum) {
|
} else if (currentResponse.getFrameNumber() != expectedFrameNum) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Expected frame number {}, received {} (retrying)", expectedFrameNum,
|
aapsLogger.warn(LTag.PUMPCOMM, "Expected frame number {}, received {} (retrying)", expectedFrameNum,
|
||||||
currentResponse.getFrameNumber());
|
currentResponse.getFrameNumber());
|
||||||
} else if (frameData.length == 0) {
|
} else if (frameData.length == 0) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Frame has zero length, retrying");
|
aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying");
|
||||||
}
|
}
|
||||||
failures++;
|
failures++;
|
||||||
if (failures == 6) {
|
if (failures == 6) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,
|
aapsLogger.error(LTag.PUMPCOMM,
|
||||||
"getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.",
|
"getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.",
|
||||||
expectedFrameNum, pageNumber);
|
expectedFrameNum, pageNumber);
|
||||||
done = true; // failure completion.
|
done = true; // failure completion.
|
||||||
|
@ -412,26 +412,26 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
nextMsg = sendAndListen(ackMsg);
|
nextMsg = sendAndListen(ackMsg);
|
||||||
break;
|
break;
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "Problem acknowledging frame response. (retry={})", retries);
|
aapsLogger.error(LTag.PUMPCOMM, "Problem acknowledging frame response. (retry={})", retries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextMsg != null)
|
if (nextMsg != null)
|
||||||
currentResponse = new GetHistoryPageCarelinkMessageBody(nextMsg.getMessageBody().getTxData());
|
currentResponse = new GetHistoryPageCarelinkMessageBody(nextMsg.getMessageBody().getTxData());
|
||||||
else {
|
else {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "We couldn't acknowledge frame from pump, aborting operation.");
|
aapsLogger.error(LTag.PUMPCOMM, "We couldn't acknowledge frame from pump, aborting operation.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawHistoryPage.getLength() != 1024) {
|
if (rawHistoryPage.getLength() != 1024) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "getPumpHistory: short page. Expected length of 1024, found length of "
|
aapsLogger.warn(LTag.PUMPCOMM, "getPumpHistory: short page. Expected length of 1024, found length of "
|
||||||
+ rawHistoryPage.getLength());
|
+ rawHistoryPage.getLength());
|
||||||
doneWithError = true;
|
doneWithError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rawHistoryPage.isChecksumOK()) {
|
if (!rawHistoryPage.isChecksumOK()) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "getPumpHistory: checksum is wrong");
|
aapsLogger.error(LTag.PUMPCOMM, "getPumpHistory: checksum is wrong");
|
||||||
doneWithError = true;
|
doneWithError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,11 +444,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
List<PumpHistoryEntry> medtronicHistoryEntries = medtronicPumpHistoryDecoder.processPageAndCreateRecords(rawHistoryPage);
|
List<PumpHistoryEntry> medtronicHistoryEntries = medtronicPumpHistoryDecoder.processPageAndCreateRecords(rawHistoryPage);
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());
|
aapsLogger.debug(LTag.PUMPCOMM, "getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());
|
||||||
|
|
||||||
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries, pageNumber);
|
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries, pageNumber);
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "getPumpHistory: Search status: Search finished: {}", pumpTotalResult.isSearchFinished());
|
aapsLogger.debug(LTag.PUMPCOMM, "getPumpHistory: Search status: Search finished: {}", pumpTotalResult.isSearchFinished());
|
||||||
|
|
||||||
if (pumpTotalResult.isSearchFinished()) {
|
if (pumpTotalResult.isSearchFinished()) {
|
||||||
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
@ -559,7 +559,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
private Object sendAndGetResponseWithCheck(MedtronicCommandType commandType, byte[] bodyData) {
|
private Object sendAndGetResponseWithCheck(MedtronicCommandType commandType, byte[] bodyData) {
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "getDataFromPump: {}", commandType);
|
aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: {}", commandType);
|
||||||
|
|
||||||
for (int retries = 0; retries < MAX_COMMAND_TRIES; retries++) {
|
for (int retries = 0; retries < MAX_COMMAND_TRIES; retries++) {
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
if (dataResponse != null) {
|
if (dataResponse != null) {
|
||||||
this.errorMessage = null;
|
this.errorMessage = null;
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Converted response for {} is {}.", commandType.name(), dataResponse);
|
aapsLogger.debug(LTag.PUMPCOMM, "Converted response for {} is {}.", commandType.name(), dataResponse);
|
||||||
|
|
||||||
return dataResponse;
|
return dataResponse;
|
||||||
} else {
|
} else {
|
||||||
|
@ -586,7 +586,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -599,7 +599,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
if (!response.isValid()) {
|
if (!response.isValid()) {
|
||||||
String responseData = String.format("%s: Invalid response.", method);
|
String responseData = String.format("%s: Invalid response.", method);
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, responseData);
|
aapsLogger.warn(LTag.PUMPCOMM, responseData);
|
||||||
return responseData;
|
return responseData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
if (contents != null) {
|
if (contents != null) {
|
||||||
if (contents.length >= expectedLength) {
|
if (contents.length >= expectedLength) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "{}: Content: {}", method, ByteUtil.shortHexString(contents));
|
aapsLogger.debug(LTag.PUMPCOMM, "{}: Content: {}", method, ByteUtil.shortHexString(contents));
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -615,12 +615,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
"%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
|
"%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
|
||||||
+ expectedLength, "" + contents.length);
|
+ expectedLength, "" + contents.length);
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, responseData);
|
aapsLogger.warn(LTag.PUMPCOMM, responseData);
|
||||||
return responseData;
|
return responseData;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String responseData = String.format("%s: Cannot return data. Null response.", method);
|
String responseData = String.format("%s: Cannot return data. Null response.", method);
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, responseData);
|
aapsLogger.warn(LTag.PUMPCOMM, responseData);
|
||||||
return responseData;
|
return responseData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
MedtronicCommandType commandType = MedtronicCommandType.GetBasalProfileSTD;
|
MedtronicCommandType commandType = MedtronicCommandType.GetBasalProfileSTD;
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "getDataFromPump: {}", commandType);
|
aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: {}", commandType);
|
||||||
|
|
||||||
medtronicUtil.setCurrentCommand(commandType);
|
medtronicUtil.setCurrentCommand(commandType);
|
||||||
|
|
||||||
|
@ -670,8 +670,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
PumpMessage response = sendAndListen(msg, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
|
PumpMessage response = sendAndListen(msg, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
|
||||||
|
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"1st Response: " + HexDump.toHexStringDisplayable(response.getRawContent()));
|
// aapsLogger.debug(LTag.PUMPCOMM,"1st Response: " + HexDump.toHexStringDisplayable(response.getRawContent()));
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"1st Response: " + HexDump.toHexStringDisplayable(response.getMessageBody().getTxData()));
|
// aapsLogger.debug(LTag.PUMPCOMM,"1st Response: " + HexDump.toHexStringDisplayable(response.getMessageBody().getTxData()));
|
||||||
|
|
||||||
String check = checkResponseContent(response, commandType.commandDescription, 1);
|
String check = checkResponseContent(response, commandType.commandDescription, 1);
|
||||||
|
|
||||||
|
@ -687,8 +687,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
response = sendAndListen(ackMsg, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
|
response = sendAndListen(ackMsg, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
|
||||||
|
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"{} Response: {}", runs, HexDump.toHexStringDisplayable(response2.getRawContent()));
|
// aapsLogger.debug(LTag.PUMPCOMM,"{} Response: {}", runs, HexDump.toHexStringDisplayable(response2.getRawContent()));
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"{} Response: {}", runs,
|
// aapsLogger.debug(LTag.PUMPCOMM,"{} Response: {}", runs,
|
||||||
// HexDump.toHexStringDisplayable(response2.getMessageBody().getTxData()));
|
// HexDump.toHexStringDisplayable(response2.getMessageBody().getTxData()));
|
||||||
|
|
||||||
String check2 = checkResponseContent(response, commandType.commandDescription, 1);
|
String check2 = checkResponseContent(response, commandType.commandDescription, 1);
|
||||||
|
@ -699,7 +699,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.errorMessage = check2;
|
this.errorMessage = check2;
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "Error with response got GetProfile: " + check2);
|
aapsLogger.error(LTag.PUMPCOMM, "Error with response got GetProfile: " + check2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().pumpType, commandType, data);
|
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().pumpType, commandType, data);
|
||||||
|
|
||||||
if (basalProfile != null) {
|
if (basalProfile != null) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Converted response for {} is {}.", commandType.name(), basalProfile);
|
aapsLogger.debug(LTag.PUMPCOMM, "Converted response for {} is {}.", commandType.name(), basalProfile);
|
||||||
|
|
||||||
medtronicUtil.setCurrentCommand(null);
|
medtronicUtil.setCurrentCommand(null);
|
||||||
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
@ -719,11 +719,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
aapsLogger.error(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading profile in max retries.");
|
aapsLogger.warn(LTag.PUMPCOMM, "Error reading profile in max retries.");
|
||||||
medtronicUtil.setCurrentCommand(null);
|
medtronicUtil.setCurrentCommand(null);
|
||||||
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
int last = responseRaw.length - 1;
|
int last = responseRaw.length - 1;
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Length: " + data.length);
|
aapsLogger.debug(LTag.PUMPCOMM, "Length: " + data.length);
|
||||||
|
|
||||||
if (data.length >= BasalProfile.MAX_RAW_DATA_SIZE) {
|
if (data.length >= BasalProfile.MAX_RAW_DATA_SIZE) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -793,7 +793,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
public Boolean setBolus(double units) {
|
public Boolean setBolus(double units) {
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "setBolus: " + units);
|
aapsLogger.info(LTag.PUMPCOMM, "setBolus: " + units);
|
||||||
|
|
||||||
return setCommand(MedtronicCommandType.SetBolus, medtronicUtil.getBolusStrokes(units));
|
return setCommand(MedtronicCommandType.SetBolus, medtronicUtil.getBolusStrokes(units));
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
public boolean setTBR(TempBasalPair tbr) {
|
public boolean setTBR(TempBasalPair tbr) {
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "setTBR: " + tbr.getDescription());
|
aapsLogger.info(LTag.PUMPCOMM, "setTBR: " + tbr.getDescription());
|
||||||
|
|
||||||
return setCommand(MedtronicCommandType.SetTemporaryBasal, tbr.getAsRawData());
|
return setCommand(MedtronicCommandType.SetTemporaryBasal, tbr.getAsRawData());
|
||||||
}
|
}
|
||||||
|
@ -813,7 +813,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
GregorianCalendar gc = new GregorianCalendar();
|
GregorianCalendar gc = new GregorianCalendar();
|
||||||
gc.add(Calendar.SECOND, 5);
|
gc.add(Calendar.SECOND, 5);
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMPBTCOMM, "setPumpTime: " + DateTimeUtil.toString(gc));
|
aapsLogger.info(LTag.PUMPCOMM, "setPumpTime: " + DateTimeUtil.toString(gc));
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
byte[] data = new byte[8];
|
byte[] data = new byte[8];
|
||||||
|
@ -830,7 +830,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
data[i + 5] = (byte) (gc.get(Calendar.MONTH) + 1);
|
data[i + 5] = (byte) (gc.get(Calendar.MONTH) + 1);
|
||||||
data[i + 6] = (byte) gc.get(Calendar.DAY_OF_MONTH);
|
data[i + 6] = (byte) gc.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
//aapsLogger.info(LTag.PUMPBTCOMM,"setPumpTime: Body: " + ByteUtil.getHex(data));
|
//aapsLogger.info(LTag.PUMPCOMM,"setPumpTime: Body: " + ByteUtil.getHex(data));
|
||||||
|
|
||||||
return setCommand(MedtronicCommandType.SetRealTimeClock, data);
|
return setCommand(MedtronicCommandType.SetRealTimeClock, data);
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
wakeUp(false);
|
wakeUp(false);
|
||||||
|
|
||||||
if (debugSetCommands)
|
if (debugSetCommands)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "{}: Body - {}", commandType.getCommandDescription(),
|
aapsLogger.debug(LTag.PUMPCOMM, "{}: Body - {}", commandType.getCommandDescription(),
|
||||||
ByteUtil.getHex(body));
|
ByteUtil.getHex(body));
|
||||||
|
|
||||||
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body));
|
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body));
|
||||||
|
@ -854,16 +854,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
PumpMessage pumpMessage = runCommandWithArgs(msg);
|
PumpMessage pumpMessage = runCommandWithArgs(msg);
|
||||||
|
|
||||||
if (debugSetCommands)
|
if (debugSetCommands)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "{}: {}", commandType.getCommandDescription(), pumpMessage.getResponseContent());
|
aapsLogger.debug(LTag.PUMPCOMM, "{}: {}", commandType.getCommandDescription(), pumpMessage.getResponseContent());
|
||||||
|
|
||||||
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) {
|
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "We received non-ACK response from pump: {}", pumpMessage.getResponseContent());
|
aapsLogger.warn(LTag.PUMPCOMM, "We received non-ACK response from pump: {}", pumpMessage.getResponseContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,13 +899,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseMessage != null)
|
if (responseMessage != null)
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Set Basal Profile: Invalid response: commandType={},rawData={}", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent()));
|
aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Invalid response: commandType={},rawData={}", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent()));
|
||||||
else
|
else
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Set Basal Profile: Null response.");
|
aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -46,12 +46,12 @@ public class MedtronicConverter {
|
||||||
Object convertResponse(PumpType pumpType, MedtronicCommandType commandType, byte[] rawContent) {
|
Object convertResponse(PumpType pumpType, MedtronicCommandType commandType, byte[] rawContent) {
|
||||||
|
|
||||||
if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) {
|
if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Content is empty or too short, no data to convert (type={},isNull={},length={})",
|
aapsLogger.warn(LTag.PUMPCOMM, "Content is empty or too short, no data to convert (type={},isNull={},length={})",
|
||||||
commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length);
|
commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Raw response before convert: " + ByteUtil.shortHexString(rawContent));
|
aapsLogger.debug(LTag.PUMPCOMM, "Raw response before convert: " + ByteUtil.shortHexString(rawContent));
|
||||||
|
|
||||||
switch (commandType) {
|
switch (commandType) {
|
||||||
|
|
||||||
|
@ -114,13 +114,13 @@ public class MedtronicConverter {
|
||||||
private MedtronicDeviceType decodeModel(byte[] rawContent) {
|
private MedtronicDeviceType decodeModel(byte[] rawContent) {
|
||||||
|
|
||||||
if ((rawContent == null || rawContent.length < 4)) {
|
if ((rawContent == null || rawContent.length < 4)) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading PumpModel, returning Unknown_Device");
|
aapsLogger.warn(LTag.PUMPCOMM, "Error reading PumpModel, returning Unknown_Device");
|
||||||
return MedtronicDeviceType.Unknown_Device;
|
return MedtronicDeviceType.Unknown_Device;
|
||||||
}
|
}
|
||||||
|
|
||||||
String rawModel = StringUtil.fromBytes(ByteUtil.substring(rawContent, 1, 3));
|
String rawModel = StringUtil.fromBytes(ByteUtil.substring(rawContent, 1, 3));
|
||||||
MedtronicDeviceType pumpModel = MedtronicDeviceType.getByDescription(rawModel);
|
MedtronicDeviceType pumpModel = MedtronicDeviceType.getByDescription(rawModel);
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PumpModel: [raw={}, resolved={}]", rawModel, pumpModel.name());
|
aapsLogger.debug(LTag.PUMPCOMM, "PumpModel: [raw={}, resolved={}]", rawModel, pumpModel.name());
|
||||||
|
|
||||||
if (pumpModel != MedtronicDeviceType.Unknown_Device) {
|
if (pumpModel != MedtronicDeviceType.Unknown_Device) {
|
||||||
if (!medtronicUtil.isModelSet()) {
|
if (!medtronicUtil.isModelSet()) {
|
||||||
|
@ -173,7 +173,7 @@ public class MedtronicConverter {
|
||||||
|
|
||||||
float value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
|
float value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Remaining insulin: " + value);
|
aapsLogger.debug(LTag.PUMPCOMM, "Remaining insulin: " + value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class MedtronicConverter {
|
||||||
LocalDateTime pumpTime = new LocalDateTime(year, month, day, hours, minutes, seconds);
|
LocalDateTime pumpTime = new LocalDateTime(year, month, day, hours, minutes, seconds);
|
||||||
return pumpTime;
|
return pumpTime;
|
||||||
} catch (IllegalFieldValueException e) {
|
} catch (IllegalFieldValueException e) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,
|
aapsLogger.error(LTag.PUMPCOMM,
|
||||||
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
|
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
|
||||||
year, month, day, hours, minutes, seconds);
|
year, month, day, hours, minutes, seconds);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (medtronicUtil.getMedtronicPumpModel() == null) {
|
if (medtronicUtil.getMedtronicPumpModel() == null) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "Device Type is not defined.");
|
aapsLogger.error(LTag.PUMPCOMM, "Device Type is not defined.");
|
||||||
return byteList;
|
return byteList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
|
||||||
StringUtil.appendToStringBuilder(sb, "" + unknownEntry.getKey(), ", ");
|
StringUtil.appendToStringBuilder(sb, "" + unknownEntry.getKey(), ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "STATISTICS OF PUMP DECODE");
|
aapsLogger.error(LTag.PUMPCOMM, "STATISTICS OF PUMP DECODE");
|
||||||
|
|
||||||
if (unknownOpCodes.size() > 0) {
|
if (unknownOpCodes.size() > 0) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Unknown Op Codes: {}", sb.toString());
|
aapsLogger.warn(LTag.PUMPCOMM, "Unknown Op Codes: {}", sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<RecordDecodeStatus, Map<String, String>> entry : mapStatistics.entrySet()) {
|
for (Map.Entry<RecordDecodeStatus, Map<String, String>> entry : mapStatistics.entrySet()) {
|
||||||
|
@ -137,9 +137,9 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
|
||||||
|
|
||||||
String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length());
|
String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length());
|
||||||
|
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, " {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString());
|
aapsLogger.error(LTag.PUMPCOMM, " {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString());
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, " {} - {}", entry.getKey().name(), entry.getValue().size());
|
aapsLogger.error(LTag.PUMPCOMM, " {} - {}", entry.getKey().name(), entry.getValue().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,16 @@ public class PumpHistoryResult {
|
||||||
/*
|
/*
|
||||||
* this.searchEntry = searchEntry;
|
* this.searchEntry = searchEntry;
|
||||||
* this.searchType = SearchType.LastEntry;
|
* this.searchType = SearchType.LastEntry;
|
||||||
* aapsLogger.debug(LTag.PUMPBTCOMM,"PumpHistoryResult. Search parameters: Last Entry: " + searchEntry.atechDateTime + " type="
|
* aapsLogger.debug(LTag.PUMPCOMM,"PumpHistoryResult. Search parameters: Last Entry: " + searchEntry.atechDateTime + " type="
|
||||||
* + searchEntry.getEntryType().name());
|
* + searchEntry.getEntryType().name());
|
||||||
*/
|
*/
|
||||||
this.searchDate = searchEntry.atechDateTime;
|
this.searchDate = searchEntry.atechDateTime;
|
||||||
this.searchType = SearchType.Date;
|
this.searchType = SearchType.Date;
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PumpHistoryResult. Search parameters: Date(with searchEntry): " + targetDate);
|
aapsLogger.debug(LTag.PUMPCOMM, "PumpHistoryResult. Search parameters: Date(with searchEntry): " + targetDate);
|
||||||
} else if (targetDate != null) {
|
} else if (targetDate != null) {
|
||||||
this.searchDate = targetDate;
|
this.searchDate = targetDate;
|
||||||
this.searchType = SearchType.Date;
|
this.searchType = SearchType.Date;
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PumpHistoryResult. Search parameters: Date: " + targetDate);
|
aapsLogger.debug(LTag.PUMPCOMM, "PumpHistoryResult. Search parameters: Date: " + targetDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.unprocessedEntries = new ArrayList<>();
|
// this.unprocessedEntries = new ArrayList<>();
|
||||||
|
@ -50,7 +50,7 @@ public class PumpHistoryResult {
|
||||||
|
|
||||||
public void addHistoryEntries(List<PumpHistoryEntry> entries, int page) {
|
public void addHistoryEntries(List<PumpHistoryEntry> entries, int page) {
|
||||||
this.unprocessedEntries = entries;
|
this.unprocessedEntries = entries;
|
||||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PumpHistoryResult. Unprocessed entries: {}", MedtronicUtil.getGsonInstance().toJson(entries));
|
//aapsLogger.debug(LTag.PUMPCOMM,"PumpHistoryResult. Unprocessed entries: {}", MedtronicUtil.getGsonInstance().toJson(entries));
|
||||||
processEntries();
|
processEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,47 +62,47 @@ public class PumpHistoryResult {
|
||||||
|
|
||||||
switch (searchType) {
|
switch (searchType) {
|
||||||
case None:
|
case None:
|
||||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. None search");
|
//aapsLogger.debug(LTag.PUMPCOMM,"PE. None search");
|
||||||
this.validEntries.addAll(this.unprocessedEntries);
|
this.validEntries.addAll(this.unprocessedEntries);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LastEntry: {
|
case LastEntry: {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. Last entry search");
|
aapsLogger.debug(LTag.PUMPCOMM, "PE. Last entry search");
|
||||||
|
|
||||||
//Collections.sort(this.unprocessedEntries, new PumpHistoryEntry.Comparator());
|
//Collections.sort(this.unprocessedEntries, new PumpHistoryEntry.Comparator());
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. PumpHistoryResult. Search entry date: " + searchEntry.atechDateTime);
|
aapsLogger.debug(LTag.PUMPCOMM, "PE. PumpHistoryResult. Search entry date: " + searchEntry.atechDateTime);
|
||||||
|
|
||||||
Long date = searchEntry.atechDateTime;
|
Long date = searchEntry.atechDateTime;
|
||||||
|
|
||||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||||
|
|
||||||
if (unprocessedEntry.equals(searchEntry)) {
|
if (unprocessedEntry.equals(searchEntry)) {
|
||||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. Item found {}.", unprocessedEntry);
|
//aapsLogger.debug(LTag.PUMPCOMM,"PE. Item found {}.", unprocessedEntry);
|
||||||
searchFinished = true;
|
searchFinished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. Entry {} added.", unprocessedEntry);
|
//aapsLogger.debug(LTag.PUMPCOMM,"PE. Entry {} added.", unprocessedEntry);
|
||||||
this.validEntries.add(unprocessedEntry);
|
this.validEntries.add(unprocessedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Date: {
|
case Date: {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. Date search: Search date: {}", this.searchDate);
|
aapsLogger.debug(LTag.PUMPCOMM, "PE. Date search: Search date: {}", this.searchDate);
|
||||||
|
|
||||||
|
|
||||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||||
|
|
||||||
if (unprocessedEntry.atechDateTime == null || unprocessedEntry.atechDateTime == 0) {
|
if (unprocessedEntry.atechDateTime == null || unprocessedEntry.atechDateTime == 0) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "PE. PumpHistoryResult. Search entry date: Entry with no date: {}", unprocessedEntry);
|
aapsLogger.debug(LTag.PUMPCOMM, "PE. PumpHistoryResult. Search entry date: Entry with no date: {}", unprocessedEntry);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unprocessedEntry.isAfter(this.searchDate)) {
|
if (unprocessedEntry.isAfter(this.searchDate)) {
|
||||||
this.validEntries.add(unprocessedEntry);
|
this.validEntries.add(unprocessedEntry);
|
||||||
} else {
|
} else {
|
||||||
// aapsLogger.debug(LTag.PUMPBTCOMM,"PE. PumpHistoryResult. Not after.. Unprocessed Entry [year={},entry={}]",
|
// aapsLogger.debug(LTag.PUMPCOMM,"PE. PumpHistoryResult. Not after.. Unprocessed Entry [year={},entry={}]",
|
||||||
// DateTimeUtil.getYear(unprocessedEntry.atechDateTime), unprocessedEntry);
|
// DateTimeUtil.getYear(unprocessedEntry.atechDateTime), unprocessedEntry);
|
||||||
if (DateTimeUtil.getYear(unprocessedEntry.atechDateTime) > 2015)
|
if (DateTimeUtil.getYear(unprocessedEntry.atechDateTime) > 2015)
|
||||||
olderEntries++;
|
olderEntries++;
|
||||||
|
@ -119,7 +119,7 @@ public class PumpHistoryResult {
|
||||||
|
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
//aapsLogger.debug(LTag.PUMPBTCOMM,"PE. Valid Entries: {}", validEntries);
|
//aapsLogger.debug(LTag.PUMPCOMM,"PE. Valid Entries: {}", validEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class PumpMessage implements RLMessage {
|
||||||
if (rxData.length > 4) {
|
if (rxData.length > 4) {
|
||||||
this.commandType = MedtronicCommandType.getByCode(rxData[4]);
|
this.commandType = MedtronicCommandType.getByCode(rxData[4]);
|
||||||
if (this.commandType == MedtronicCommandType.InvalidCommand) {
|
if (this.commandType == MedtronicCommandType.InvalidCommand) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "PumpMessage - Unknown commandType " + rxData[4]);
|
aapsLogger.error(LTag.PUMPCOMM, "PumpMessage - Unknown commandType " + rxData[4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rxData.length > 5) {
|
if (rxData.length > 5) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class BasalProfile {
|
||||||
|
|
||||||
private boolean setRawData(byte[] data) {
|
private boolean setRawData(byte[] data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,"setRawData: buffer is null!");
|
aapsLogger.error(LTag.PUMPCOMM,"setRawData: buffer is null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class BasalProfile {
|
||||||
|
|
||||||
public boolean setRawDataFromHistory(byte[] data) {
|
public boolean setRawDataFromHistory(byte[] data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,"setRawData: buffer is null!");
|
aapsLogger.error(LTag.PUMPCOMM,"setRawData: buffer is null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,13 +116,13 @@ public class BasalProfile {
|
||||||
|
|
||||||
|
|
||||||
public void dumpBasalProfile() {
|
public void dumpBasalProfile() {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,"Basal Profile entries:");
|
aapsLogger.debug(LTag.PUMPCOMM,"Basal Profile entries:");
|
||||||
List<BasalProfileEntry> entries = getEntries();
|
List<BasalProfileEntry> entries = getEntries();
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
BasalProfileEntry entry = entries.get(i);
|
BasalProfileEntry entry = entries.get(i);
|
||||||
String startString = entry.startTime.toString("HH:mm");
|
String startString = entry.startTime.toString("HH:mm");
|
||||||
// this doesn't work
|
// this doesn't work
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,String.format("Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)", i + 1, entry.rate,
|
aapsLogger.debug(LTag.PUMPCOMM,String.format("Entry %d, rate=%.3f (0x%02X), start=%s (0x%02X)", i + 1, entry.rate,
|
||||||
entry.rate_raw, startString, entry.startTime_raw));
|
entry.rate_raw, startString, entry.startTime_raw));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,14 +169,14 @@ public class BasalProfile {
|
||||||
BasalProfileEntry rval = new BasalProfileEntry();
|
BasalProfileEntry rval = new BasalProfileEntry();
|
||||||
List<BasalProfileEntry> entries = getEntries();
|
List<BasalProfileEntry> entries = getEntries();
|
||||||
if (entries.size() == 0) {
|
if (entries.size() == 0) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM,String.format("getEntryForTime(%s): table is empty",
|
aapsLogger.warn(LTag.PUMPCOMM,String.format("getEntryForTime(%s): table is empty",
|
||||||
when.toDateTime().toLocalTime().toString("HH:mm")));
|
when.toDateTime().toLocalTime().toString("HH:mm")));
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
// Log.w(TAG,"Assuming first entry");
|
// Log.w(TAG,"Assuming first entry");
|
||||||
rval = entries.get(0);
|
rval = entries.get(0);
|
||||||
if (entries.size() == 1) {
|
if (entries.size() == 1) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,"getEntryForTime: Only one entry in profile");
|
aapsLogger.debug(LTag.PUMPCOMM,"getEntryForTime: Only one entry in profile");
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,17 +186,17 @@ public class BasalProfile {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
BasalProfileEntry entry = entries.get(i);
|
BasalProfileEntry entry = entries.get(i);
|
||||||
if (DEBUG_BASALPROFILE) {
|
if (DEBUG_BASALPROFILE) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,String.format("Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime()
|
aapsLogger.debug(LTag.PUMPCOMM,String.format("Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime()
|
||||||
.toString("HH:mm"), entry.startTime.toString("HH:mm")));
|
.toString("HH:mm"), entry.startTime.toString("HH:mm")));
|
||||||
}
|
}
|
||||||
if (localMillis >= entry.startTime.getMillisOfDay()) {
|
if (localMillis >= entry.startTime.getMillisOfDay()) {
|
||||||
rval = entry;
|
rval = entry;
|
||||||
if (DEBUG_BASALPROFILE)
|
if (DEBUG_BASALPROFILE)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,"Accepted Entry");
|
aapsLogger.debug(LTag.PUMPCOMM,"Accepted Entry");
|
||||||
} else {
|
} else {
|
||||||
// entry at i has later start time, keep older entry
|
// entry at i has later start time, keep older entry
|
||||||
if (DEBUG_BASALPROFILE)
|
if (DEBUG_BASALPROFILE)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,"Rejected Entry");
|
aapsLogger.debug(LTag.PUMPCOMM,"Rejected Entry");
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -205,7 +205,7 @@ public class BasalProfile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG_BASALPROFILE) {
|
if (DEBUG_BASALPROFILE) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM,String.format("getEntryForTime(%s): Returning entry: rate=%.3f (%d), start=%s (%d)", when
|
aapsLogger.debug(LTag.PUMPCOMM,String.format("getEntryForTime(%s): Returning entry: rate=%.3f (%d), start=%s (%d)", when
|
||||||
.toDateTime().toLocalTime().toString("HH:mm"), rval.rate, rval.rate_raw,
|
.toDateTime().toLocalTime().toString("HH:mm"), rval.rate, rval.rate_raw,
|
||||||
rval.startTime.toString("HH:mm"), rval.startTime_raw));
|
rval.startTime.toString("HH:mm"), rval.startTime_raw));
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ public class BasalProfile {
|
||||||
List<BasalProfileEntry> entries = new ArrayList<>();
|
List<BasalProfileEntry> entries = new ArrayList<>();
|
||||||
|
|
||||||
if (mRawData == null || mRawData[2] == 0x3f) {
|
if (mRawData == null || mRawData[2] == 0x3f) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM,"Raw Data is empty.");
|
aapsLogger.warn(LTag.PUMPCOMM,"Raw Data is empty.");
|
||||||
return entries; // an empty list
|
return entries; // an empty list
|
||||||
}
|
}
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
@ -237,7 +237,7 @@ public class BasalProfile {
|
||||||
try {
|
try {
|
||||||
entries.add(new BasalProfileEntry(aapsLogger, r, st));
|
entries.add(new BasalProfileEntry(aapsLogger, r, st));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,"Error decoding basal profile from bytes: {}", ByteUtil.shortHexString(mRawData));
|
aapsLogger.error(LTag.PUMPCOMM,"Error decoding basal profile from bytes: {}", ByteUtil.shortHexString(mRawData));
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,10 +286,10 @@ public class BasalProfile {
|
||||||
try {
|
try {
|
||||||
entries = getEntries();
|
entries = getEntries();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,"=============================================================================");
|
aapsLogger.error(LTag.PUMPCOMM,"=============================================================================");
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM," Error generating entries. Ex.: " + ex, ex);
|
aapsLogger.error(LTag.PUMPCOMM," Error generating entries. Ex.: " + ex, ex);
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM," rawBasalValues: " + ByteUtil.shortHexString(this.getRawData()));
|
aapsLogger.error(LTag.PUMPCOMM," rawBasalValues: " + ByteUtil.shortHexString(this.getRawData()));
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,"=============================================================================");
|
aapsLogger.error(LTag.PUMPCOMM,"=============================================================================");
|
||||||
|
|
||||||
//FabricUtil.createEvent("MedtronicBasalProfileGetByHourError", null);
|
//FabricUtil.createEvent("MedtronicBasalProfileGetByHourError", null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class BasalProfileEntry {
|
||||||
try {
|
try {
|
||||||
startTime = new LocalTime(startTimeInterval / 2, (startTimeInterval % 2) * 30);
|
startTime = new LocalTime(startTimeInterval / 2, (startTimeInterval % 2) * 30);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM,
|
aapsLogger.error(LTag.PUMPCOMM,
|
||||||
"Error creating BasalProfileEntry: startTimeInterval={}, startTime_raw={}, hours={}, rateStrokes={}",
|
"Error creating BasalProfileEntry: startTimeInterval={}, startTime_raw={}, hours={}, rateStrokes={}",
|
||||||
startTimeInterval, startTime_raw, startTimeInterval / 2, rateStrokes);
|
startTimeInterval, startTime_raw, startTimeInterval / 2, rateStrokes);
|
||||||
throw ex;
|
throw ex;
|
||||||
|
|
|
@ -275,7 +275,7 @@ public class MedtronicUtil {
|
||||||
|
|
||||||
byte[] payload = sendPayloadBuffer.array();
|
byte[] payload = sendPayloadBuffer.array();
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "buildCommandPayload [{}]", ByteUtil.shortHexString(payload));
|
aapsLogger.debug(LTag.PUMPCOMM, "buildCommandPayload [{}]", ByteUtil.shortHexString(payload));
|
||||||
|
|
||||||
// int crc = computeCRC8WithPolynomial(payload, 0, payload.length - 1);
|
// int crc = computeCRC8WithPolynomial(payload, 0, payload.length - 1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue