diff --git a/app/build.gradle b/app/build.gradle index ce1a6d29a9..46c7d30633 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,7 +105,7 @@ android { multiDexEnabled true versionCode 1500 // dev_version: 2.3.1-dev - version "medtronic-0.11.5-SNAPSHOT" + version "medtronic-0.11.6-SNAPSHOT" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index b04019190d..ef82c3791e 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -156,7 +156,7 @@ public class MainApp extends Application { File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode"); engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile(); - devBranch = BuildConfig.VERSION.contains("dev") || BuildConfig.DEV_VERSION.contains("dev"); + devBranch = BuildConfig.VERSION.contains("dev"); sBus = L.isEnabled(L.EVENTS) && devBranch ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index a412b44ee3..2911d97d67 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -129,7 +129,7 @@ public class RFSpy { byte[] response = writeToDataRaw(getVersionRaw, 5000); if (isLogEnabled()) - LOG.debug("Firmware Version. GetVersion [response={}]", ByteUtil.getHex(response)); + LOG.debug("Firmware Version. GetVersion [response={}]", ByteUtil.shortHexString(response)); if (response != null) { // && response[0] == (byte) 0xDD) { @@ -172,7 +172,7 @@ public class RFSpy { // prepend length, and send it. byte[] prepended = ByteUtil.concat(new byte[]{(byte) (bytes.length)}, bytes); - LOG.debug("writeToData (raw={})", ByteUtil.getHex(prepended)); + LOG.debug("writeToData (raw={})", ByteUtil.shortHexString(prepended)); BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID, prepended); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java index e75d79a79d..a96dcb6e11 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java @@ -71,7 +71,7 @@ public class RileyLinkBLE { + GattAttributes.lookup(characteristic.getUuid()) + " " + ByteUtil.getHex(characteristic.getValue())); if (characteristic.getUuid().equals(UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT))) { - LOG.debug("Response Count is " + ByteUtil.getHex(characteristic.getValue())); + LOG.debug("Response Count is " + ByteUtil.shortHexString(characteristic.getValue())); } } if (radioResponseCountNotified != null) { @@ -103,7 +103,7 @@ public class RileyLinkBLE { final String uuidString = GattAttributes.lookup(characteristic.getUuid()); if (gattDebugEnabled && isLogEnabled()) { LOG.trace(ThreadUtil.sig() + "onCharacteristicWrite " + getGattStatusMessage(status) + " " - + uuidString + " " + ByteUtil.getHex(characteristic.getValue())); + + uuidString + " " + ByteUtil.shortHexString(characteristic.getValue())); } mCurrentOperation.gattOperationCompletionCallback(characteristic.getUuid(), characteristic.getValue()); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java index ab61510c14..40f24cf135 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding; -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 info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; @@ -40,7 +40,7 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { 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)); @@ -51,13 +51,13 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { 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; } } @@ -81,13 +81,13 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { StringBuilder errorMessageBuilder = new StringBuilder(); - errorMessageBuilder.append("Input data: " + ByteUtil.getHex(raw) + "\n"); + errorMessageBuilder.append("Input data: " + ByteUtil.shortHexString(raw) + "\n"); if ((raw.length % 2) != 0) { errorMessageBuilder.append("Warn: odd number of bytes.\n"); } - byte[] rval = new byte[] {}; + byte[] rval = new byte[]{}; int availableBits = 0; int codingErrors = 0; int x = 0; @@ -103,13 +103,13 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { if (availableBits >= 12) { // take top six int highcode = (x >> (availableBits - 6)) & 0x3F; - int highIndex = encode4b6bListIndex((byte)(highcode)); + int highIndex = encode4b6bListIndex((byte) (highcode)); // take bottom six int lowcode = (x >> (availableBits - 12)) & 0x3F; - int lowIndex = encode4b6bListIndex((byte)(lowcode)); + int lowIndex = encode4b6bListIndex((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( @@ -122,8 +122,8 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { } 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)); errorMessageBuilder.append(String.format( - "decode4b6b: i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining.\n", - i, x, highcode, lowcode, availableBits)); + "decode4b6b: i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining.\n", + i, x, highcode, lowcode, availableBits)); codingErrors++; } @@ -139,7 +139,7 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { // LOG.error("decode4b6b: failed clean decode -- extra bits available (not marker)(" + availableBits + // ")"); errorMessageBuilder.append("decode4b6b: failed clean decode -- extra bits available (not marker)(" - + availableBits + ")\n"); + + availableBits + ")\n"); codingErrors++; } } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java index d310378e9b..3ba4ce7669 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java @@ -107,6 +107,17 @@ public class ByteUtil { return rval; } + public static String shortHexString(List list) { + + byte[] abyte0 = getByteArrayFromList(list); + + return shortHexString(abyte0); + } + + public static String shortHexString(byte val) { + return getHexCompact(val); + } + public static String showPrintable(byte[] ra) { String s = new String(); @@ -323,7 +334,7 @@ public class ByteUtil { if (abyte0 != null) { i = Math.min(i, abyte0.length); for (int j = 0; j < i; j++) { - stringbuffer.append(getHex(abyte0[j])); + stringbuffer.append(shortHexString(abyte0[j])); if (j < i - 1) { stringbuffer.append(" "); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index 7578deb872..d53d59197e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -644,7 +644,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (contents != null) { if (contents.length >= expectedLength) { - LOG.trace("{}: Content: {}", method, ByteUtil.getHex(contents)); + LOG.trace("{}: Content: {}", method, ByteUtil.shortHexString(contents)); return null; } else { @@ -722,7 +722,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (check == null) { - data = response.getRawContent(); + data = response.getRawContentOfFrame(); PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody()); @@ -740,7 +740,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (check2 == null) { - data = ByteUtil.concat(data, ByteUtil.substring(response2.getMessageBody().getTxData(), 1)); + data = ByteUtil.concat(data, response2.getRawContentOfFrame()); } else { this.errorMessage = check2; @@ -755,13 +755,15 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(commandType, data); - if (isLogEnabled()) - LOG.debug("Converted response for {} is {}.", commandType.name(), basalProfile); + if (basalProfile != null) { + if (isLogEnabled()) + LOG.debug("Converted response for {} is {}.", commandType.name(), basalProfile); - MedtronicUtil.setCurrentCommand(null); - MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping); + MedtronicUtil.setCurrentCommand(null); + MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping); - return basalProfile; + return basalProfile; + } } catch (RileyLinkCommunicationException e) { LOG.error("Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1); @@ -953,7 +955,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager LOG.warn("Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1); } - LOG.warn("Set Basal Profile: Invalid response: commandType={},rawData={}", responseMessage.commandType, ByteUtil.getHex(responseMessage.getRawContent())); + LOG.warn("Set Basal Profile: Invalid response: commandType={},rawData={}", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent())); } return false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java index 3243076b01..8bdd55db8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java @@ -41,7 +41,7 @@ public class MedtronicConverter { } if (isLogEnabled()) - LOG.debug("Raw response before convert: " + ByteUtil.getHex(rawContent)); + LOG.debug("Raw response before convert: " + ByteUtil.shortHexString(rawContent)); this.pumpModel = MedtronicUtil.getMedtronicPumpModel(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java index 3f9ce19a6e..b376d5a98e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java @@ -135,7 +135,7 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte public Object getDecodedDataEntry(String key) { - return this.decodedData.get(key); + return this.decodedData != null ? this.decodedData.get(key) : null; } @@ -197,21 +197,21 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte if (head != null) { sb.append(", head="); - sb.append(ByteUtil.getHex(this.head)); + sb.append(ByteUtil.shortHexString(this.head)); } if (datetime != null) { sb.append(", datetime="); - sb.append(ByteUtil.getHex(this.datetime)); + sb.append(ByteUtil.shortHexString(this.datetime)); } if (body != null) { sb.append(", body="); - sb.append(ByteUtil.getHex(this.body)); + sb.append(ByteUtil.shortHexString(this.body)); } sb.append(", rawData="); - sb.append(ByteUtil.getHex(this.rawData)); + sb.append(ByteUtil.shortHexString(this.rawData)); sb.append("]"); // sb.append(" DT: "); @@ -297,7 +297,7 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte if (head == null) { return "Unidentified record. "; } else { - return "HistoryRecord: head=[" + ByteUtil.getHex(this.head) + "]"; + return "HistoryRecord: head=[" + ByteUtil.shortHexString(this.head) + "]"; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java index 9c1972e16e..6cc6d707e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java @@ -116,7 +116,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder