diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt index 1e9976fa74..b18d539464 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt @@ -207,7 +207,7 @@ class MedtronicFragment : DaggerFragment() { when (medtronicPumpStatus.pumpDeviceState) { null, - PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name()); + PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name()); PumpDeviceState.NeverContacted, PumpDeviceState.WakingUp, PumpDeviceState.PumpUnreachable, @@ -215,7 +215,7 @@ class MedtronicFragment : DaggerFragment() { PumpDeviceState.TimeoutWhenCommunicating, PumpDeviceState.InvalidConfiguration -> binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) - PumpDeviceState.Active -> { + PumpDeviceState.Active -> { val cmd = medtronicUtil.currentCommand if (cmd == null) binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) @@ -328,5 +328,27 @@ class MedtronicFragment : DaggerFragment() { medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() binding.errors.text = medtronicPumpStatus.errorInfo + + var showRileyLinkBatteryLevel: Boolean = rileyLinkServiceData.showBatteryLevel + + if (showRileyLinkBatteryLevel) { + binding.rlBatteryView.visibility = View.VISIBLE + binding.rlBatteryLabel.visibility = View.VISIBLE + binding.rlBatteryState.visibility = View.VISIBLE + binding.rlBatteryLayout.visibility = View.VISIBLE + binding.rlBatterySemicolon.visibility = View.VISIBLE + if (rileyLinkServiceData.batteryLevel == null) { + binding.rlBatteryState.text = " ?" + } else { + binding.rlBatteryState.text = "{fa-battery-" + rileyLinkServiceData.batteryLevel / 25 + "} " + rileyLinkServiceData.batteryLevel + "%" + } + } else { + binding.rlBatteryView.visibility = View.GONE + binding.rlBatteryLabel.visibility = View.GONE + binding.rlBatteryState.visibility = View.GONE + binding.rlBatteryLayout.visibility = View.GONE + binding.rlBatterySemicolon.visibility = View.GONE + } + } } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 32fed6e448..af16b76bd1 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -780,7 +780,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter if ((clock.localDeviceTime.getYear() <= 2015) || (timeDiff <= 24 * 60 * 60)) { - aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is {} s. Set time on pump.", timeDiff); + aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Set time on pump.", timeDiff)); rileyLinkMedtronicService.getMedtronicUIComm().executeCommand(MedtronicCommandType.SetRealTimeClock); @@ -790,13 +790,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter } } else { if ((clock.localDeviceTime.getYear() > 2015)) { - aapsLogger.error("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff={} s]. Doing nothing.", timeDiff); + aapsLogger.error(String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff=%d s]. Doing nothing.", timeDiff)); medtronicUtil.sendNotification(MedtronicNotificationType.TimeChangeOver24h, getResourceHelper(), rxBus); } } } else { - aapsLogger.info(LTag.PUMP, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is {} s. Do nothing.", timeDiff); + aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is %d s. Do nothing.", timeDiff)); } scheduleNextRefresh(MedtronicStatusRefreshType.PumpTime, 0); @@ -1068,7 +1068,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter @NonNull @Override - public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) { + public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) { if (percent == 0) { return setTempBasalAbsolute(0.0d, durationInMinutes, profile, enforceNew); } else { diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index 94c9d35b5e..32963e8d9a 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -7,6 +7,7 @@ import org.joda.time.LocalDateTime; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.inject.Inject; @@ -171,8 +172,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager PumpMessage pumpResponse = createResponseMessage(radioResponse.getPayload()); if (!pumpResponse.isValid()) { - aapsLogger.warn(LTag.PUMPCOMM, "Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(), - rfSpyResponse.wasTimeout()); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Response is invalid ! [interrupted=%b, timeout=%b]", rfSpyResponse.wasInterrupted(), + rfSpyResponse.wasTimeout())); } else { // radioResponse.rssi; @@ -186,8 +187,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager medtronicUtil.setMedtronicPumpModel(pumpModel); } - aapsLogger.debug(LTag.PUMPCOMM, "isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid, - radioResponse.rssi); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "isDeviceReachable. PumpModel is %s - Valid: %b (rssi=%d)", pumpModel.name(), valid, + radioResponse.rssi)); if (valid) { if (state == PumpDeviceState.PumpUnreachable) @@ -245,7 +246,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager rval = sendAndListen(msg); if (debugSetCommands) - aapsLogger.debug(LTag.PUMPCOMM, "2nd Response: {}", rval); + aapsLogger.debug(LTag.PUMPCOMM, "2nd Response: " + rval); return rval; } else { @@ -258,7 +259,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List> frames) throws RileyLinkCommunicationException { - aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: {}", commandType.name()); + aapsLogger.debug(LTag.PUMPCOMM, "Run command with Frames: " + commandType.name()); PumpMessage rval = null; PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0})); @@ -288,14 +289,14 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager // aapsLogger.debug(LTag.PUMPCOMM,"PumpResponse: " + rval); if (rval.commandType != MedtronicCommandType.CommandACK) { - aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #{}", frameNr); + aapsLogger.error(LTag.PUMPCOMM, "runCommandWithFrames: Pump did not ACK frame #" + frameNr); - aapsLogger.error(LTag.PUMPCOMM, "Run command with Frames FAILED (command={}, response={})", commandType.name(), - rval.toString()); + aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Run command with Frames FAILED (command=%s, response=%s)", commandType.name(), + rval.toString())); return new PumpMessage(aapsLogger, "No ACK after frame #" + frameNr); } else { - aapsLogger.debug(LTag.PUMPCOMM, "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++; @@ -326,7 +327,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData, new GetHistoryPageCarelinkMessageBody(pageNumber)); - aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Page {}", pageNumber); + aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Page " + pageNumber); // aapsLogger.info(LTag.PUMPCOMM,"getPumpHistoryPage("+pageNumber+"): "+ByteUtil.shortHexString(getHistoryMsg.getTxData())); // Ask the pump to transfer history (we get first frame?) @@ -342,7 +343,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager failed = false; break; } catch (RileyLinkCommunicationException e) { - aapsLogger.error(LTag.PUMPCOMM, "First call for PumpHistory failed (retry={})", retries); + aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "First call for PumpHistory failed (retry=%d)", retries)); failed = true; } } @@ -379,7 +380,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager medtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber, currentResponse.getFrameNumber()); - aapsLogger.info(LTag.PUMPCOMM, "getPumpHistory: Got frame {} of Page {}", currentResponse.getFrameNumber(), pageNumber); + aapsLogger.info(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getPumpHistory: Got frame %d of Page %d", currentResponse.getFrameNumber(), pageNumber)); // Do we need to ask for the next frame? if (expectedFrameNum < 16) { // This number may not be correct for pumps other than 522/722 expectedFrameNum++; @@ -390,16 +391,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (frameData == null) { aapsLogger.error(LTag.PUMPCOMM, "null frame data, retrying"); } else if (currentResponse.getFrameNumber() != expectedFrameNum) { - aapsLogger.warn(LTag.PUMPCOMM, "Expected frame number {}, received {} (retrying)", expectedFrameNum, - currentResponse.getFrameNumber()); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Expected frame number %d, received %d (retrying)", expectedFrameNum, + currentResponse.getFrameNumber())); } else if (frameData.length == 0) { aapsLogger.warn(LTag.PUMPCOMM, "Frame has zero length, retrying"); } failures++; if (failures == 6) { aapsLogger.error(LTag.PUMPCOMM, - "getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.", - expectedFrameNum, pageNumber); + String.format(Locale.ENGLISH, "getPumpHistory: 6 failures in attempting to download frame %d of page %d, giving up.", + expectedFrameNum, pageNumber)); done = true; // failure completion. doneWithError = true; } @@ -415,7 +416,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager nextMsg = sendAndListen(ackMsg); break; } catch (RileyLinkCommunicationException e) { - aapsLogger.error(LTag.PUMPCOMM, "Problem acknowledging frame response. (retry={})", retries); + aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Problem acknowledging frame response. (retry=%d)", retries)); } } @@ -447,11 +448,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager List medtronicHistoryEntries = medtronicPumpHistoryDecoder.processPageAndCreateRecords(rawHistoryPage); - aapsLogger.debug(LTag.PUMPCOMM, "getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size()); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getPumpHistory: Found %d history entries.", medtronicHistoryEntries.size())); pumpTotalResult.addHistoryEntries(medtronicHistoryEntries, pageNumber); - aapsLogger.debug(LTag.PUMPCOMM, "getPumpHistory: Search status: Search finished: {}", pumpTotalResult.isSearchFinished()); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getPumpHistory: Search status: Search finished: %b", pumpTotalResult.isSearchFinished())); if (pumpTotalResult.isSearchFinished()) { medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping); @@ -563,7 +564,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager private Object sendAndGetResponseWithCheck(MedtronicCommandType commandType, byte[] bodyData) { - aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: {}", commandType); + aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: " + commandType); for (int retries = 0; retries < MAX_COMMAND_TRIES; retries++) { @@ -578,7 +579,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (dataResponse != null) { this.errorMessage = null; - aapsLogger.debug(LTag.PUMPCOMM, "Converted response for {} is {}.", commandType.name(), dataResponse); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Converted response for %s is %s.", commandType.name(), dataResponse)); return dataResponse; } else { @@ -590,7 +591,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager } } catch (RileyLinkCommunicationException e) { - aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1)); } } @@ -611,7 +612,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (contents != null) { if (contents.length >= expectedLength) { - aapsLogger.debug(LTag.PUMPCOMM, "{}: Content: {}", method, ByteUtil.shortHexString(contents)); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Content: %s", method, ByteUtil.shortHexString(contents))); return null; } else { @@ -656,7 +657,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager MedtronicCommandType commandType = MedtronicCommandType.GetBasalProfileSTD; - aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: {}", commandType); + aapsLogger.debug(LTag.PUMPCOMM, "getDataFromPump: " + commandType); medtronicUtil.setCurrentCommand(commandType); @@ -714,7 +715,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(medtronicPumpPlugin.getPumpDescription().getPumpType(), commandType, data); if (basalProfile != null) { - aapsLogger.debug(LTag.PUMPCOMM, "Converted response for {} is {}.", commandType.name(), basalProfile); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Converted response for %s is %s.", commandType.name(), basalProfile)); medtronicUtil.setCurrentCommand(null); medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping); @@ -723,7 +724,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager } } catch (RileyLinkCommunicationException e) { - aapsLogger.error(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1); + aapsLogger.error(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1)); } } @@ -850,24 +851,24 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager wakeUp(false); if (debugSetCommands) - aapsLogger.debug(LTag.PUMPCOMM, "{}: Body - {}", commandType.getCommandDescription(), - ByteUtil.getHex(body)); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Body - %s", commandType.getCommandDescription(), + ByteUtil.getHex(body))); PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body)); PumpMessage pumpMessage = runCommandWithArgs(msg); if (debugSetCommands) - aapsLogger.debug(LTag.PUMPCOMM, "{}: {}", commandType.getCommandDescription(), pumpMessage.getResponseContent()); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: %s", commandType.getCommandDescription(), pumpMessage.getResponseContent())); if (pumpMessage.commandType == MedtronicCommandType.CommandACK) { return true; } else { - aapsLogger.warn(LTag.PUMPCOMM, "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) { - aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1)); } } @@ -903,11 +904,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager return true; } catch (RileyLinkCommunicationException e) { - aapsLogger.warn(LTag.PUMPCOMM, "Error getting response from RileyLink (error={}, retry={})", e.getMessage(), retries + 1); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Error getting response from RileyLink (error=%s, retry=%d)", e.getMessage(), retries + 1)); } if (responseMessage != null) - aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Invalid response: commandType={},rawData={}", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent())); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Set Basal Profile: Invalid response: commandType=%s,rawData=%s", responseMessage.commandType, ByteUtil.shortHexString(responseMessage.getRawContent()))); else aapsLogger.warn(LTag.PUMPCOMM, "Set Basal Profile: Null response."); } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java index 64a957bb40..f9ad49b723 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.java @@ -4,6 +4,7 @@ import org.joda.time.IllegalFieldValueException; import org.joda.time.LocalDateTime; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.inject.Inject; @@ -46,8 +47,8 @@ public class MedtronicConverter { Object convertResponse(PumpType pumpType, MedtronicCommandType commandType, byte[] rawContent) { if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) { - 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); + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Content is empty or too short, no data to convert (type=%s,isNull=%b,length=%s)", + commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length)); return null; } @@ -120,7 +121,7 @@ public class MedtronicConverter { String rawModel = StringUtil.fromBytes(ByteUtil.substring(rawContent, 1, 3)); MedtronicDeviceType pumpModel = MedtronicDeviceType.getByDescription(rawModel); - aapsLogger.debug(LTag.PUMPCOMM, "PumpModel: [raw={}, resolved={}]", rawModel, pumpModel.name()); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "PumpModel: [raw=%s, resolved=%s]", rawModel, pumpModel.name())); if (pumpModel != MedtronicDeviceType.Unknown_Device) { if (!medtronicUtil.isModelSet()) { @@ -177,7 +178,7 @@ public class MedtronicConverter { startIdx = 2; } - int reqLength = startIdx+1; + int reqLength = startIdx + 1; float value = 0; if (reqLength >= rawData.length) { @@ -204,8 +205,8 @@ public class MedtronicConverter { return pumpTime; } catch (IllegalFieldValueException e) { aapsLogger.error(LTag.PUMPCOMM, - "decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d", - year, month, day, hours, minutes, seconds); + String.format(Locale.ENGLISH, "decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d", + year, month, day, hours, minutes, seconds)); return null; } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryDecoder.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryDecoder.java index 922eb34ea1..2b33249503 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryDecoder.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryDecoder.java @@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.inject.Inject; @@ -137,9 +138,9 @@ public abstract class MedtronicHistoryDecoder i String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length()); - aapsLogger.info(LTag.PUMPCOMM, String.format(" %s%s - %d. Elements: %s", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString())); + aapsLogger.info(LTag.PUMPCOMM, String.format(Locale.ENGLISH, " %s%s - %d. Elements: %s", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString())); } else { - aapsLogger.info(LTag.PUMPCOMM, String.format(" %s - %d", entry.getKey().name(), entry.getValue().size())); + aapsLogger.info(LTag.PUMPCOMM, String.format(Locale.ENGLISH, " %s - %d", entry.getKey().name(), entry.getValue().size())); } } } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java index b59dce7113..b5d41f6bfa 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/MedtronicHistoryEntry.java @@ -171,7 +171,7 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte StringBuilder sb = new StringBuilder(); if (this.DT == null) { - LOG.error("DT is null. RawData={}", ByteUtil.getHex(this.rawData)); + LOG.error("DT is null. RawData=" + ByteUtil.getHex(this.rawData)); } sb.append(getToStringStart()); diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/RawHistoryPage.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/RawHistoryPage.java index 3203283e4d..182e09b1bd 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/RawHistoryPage.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/RawHistoryPage.java @@ -1,6 +1,7 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history; import java.util.Arrays; +import java.util.Locale; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -53,8 +54,8 @@ public class RawHistoryPage { int crcStored = ByteUtil.toInt(data[1022], data[1023]); if (crcCalculated != crcStored) { - aapsLogger.error(LTag.PUMPBTCOMM, "Stored CRC ({}) is different than calculated ({}), but ignored for now.", crcStored, - crcCalculated); + aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Stored CRC (%d) is different than calculated (%d), but ignored for now.", crcStored, + crcCalculated)); } else { if (MedtronicUtil.isLowLevelDebug()) aapsLogger.debug(LTag.PUMPBTCOMM, "CRC ok."); @@ -81,6 +82,6 @@ public class RawHistoryPage { offset += linesize; } - aapsLogger.debug(LTag.PUMPBTCOMM, "History Page Data:\n{}", sb.toString()); + aapsLogger.info(LTag.PUMPBTCOMM, "History Page Data:\n" + sb.toString()); } } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java index 3a6c4851ec..a1595f5829 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java @@ -179,7 +179,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder primeRecords = getFilteredItems(PumpHistoryEntryType.Prime); - aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Prime [count={}, items={}]", primeRecords.size(), gson().toJson(primeRecords)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: Prime [count=%d, items=%s]", primeRecords.size(), gson().toJson(primeRecords))); if (isCollectionNotEmpty(primeRecords)) { try { processPrime(primeRecords); } catch (Exception ex) { - aapsLogger.error("ProcessHistoryData: Error processing Prime entries: " + ex.getMessage(), ex); + aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Prime entries: " + ex.getMessage(), ex); throw ex; } } @@ -447,13 +447,13 @@ public class MedtronicHistoryData { // Rewind (for marking insulin change) List rewindRecords = getFilteredItems(PumpHistoryEntryType.Rewind); - aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Rewind [count={}, items={}]", rewindRecords.size(), gson().toJson(rewindRecords)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: Rewind [count=%d, items=%s]", rewindRecords.size(), gson().toJson(rewindRecords))); if (isCollectionNotEmpty(rewindRecords)) { try { processRewind(rewindRecords); } catch (Exception ex) { - aapsLogger.error("ProcessHistoryData: Error processing Rewind entries: " + ex.getMessage(), ex); + aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Rewind entries: " + ex.getMessage(), ex); throw ex; } } @@ -461,7 +461,7 @@ public class MedtronicHistoryData { // TDD List tdds = getFilteredItems(PumpHistoryEntryType.EndResultTotals, getTDDType()); - aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TDD [count={}, items={}]", tdds.size(), gson().toJson(tdds)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: TDD [count=%d, items=%s]", tdds.size(), gson().toJson(tdds))); if (isCollectionNotEmpty(tdds)) { try { @@ -477,13 +477,13 @@ public class MedtronicHistoryData { // Bolus List treatments = getFilteredItems(PumpHistoryEntryType.Bolus); - aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: Bolus [count={}, items={}]", treatments.size(), gson().toJson(treatments)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: Bolus [count=%d, items=%s]", treatments.size(), gson().toJson(treatments))); if (treatments.size() > 0) { try { processBolusEntries(treatments); } catch (Exception ex) { - aapsLogger.error("ProcessHistoryData: Error processing Bolus entries: " + ex.getMessage(), ex); + aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Bolus entries: " + ex.getMessage(), ex); throw ex; } } @@ -491,13 +491,13 @@ public class MedtronicHistoryData { // TBR List tbrs = getFilteredItems(PumpHistoryEntryType.TempBasalCombined); - aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: TBRs Processed [count={}, items={}]", tbrs.size(), gson().toJson(tbrs)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: TBRs Processed [count=%d, items=%s]", tbrs.size(), gson().toJson(tbrs))); if (tbrs.size() > 0) { try { processTBREntries(tbrs); } catch (Exception ex) { - aapsLogger.error("ProcessHistoryData: Error processing TBR entries: " + ex.getMessage(), ex); + aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing TBR entries: " + ex.getMessage(), ex); throw ex; } } @@ -512,14 +512,14 @@ public class MedtronicHistoryData { throw ex; } - aapsLogger.debug(LTag.PUMP, "ProcessHistoryData: 'Delivery Suspend' Processed [count={}, items={}]", suspends.size(), - gson().toJson(suspends)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "ProcessHistoryData: 'Delivery Suspend' Processed [count=%d, items=%s]", suspends.size(), + gson().toJson(suspends))); if (isCollectionNotEmpty(suspends)) { try { processSuspends(suspends); } catch (Exception ex) { - aapsLogger.error("ProcessHistoryData: Error processing Suspends entries: " + ex.getMessage(), ex); + aapsLogger.error(LTag.PUMP, "ProcessHistoryData: Error processing Suspends entries: " + ex.getMessage(), ex); throw ex; } } @@ -586,7 +586,9 @@ public class MedtronicHistoryData { private void uploadCareportalEvent(long date, TherapyEvent.Type event) { if (repository.getTherapyEventByTimestamp(event, date) != null) return; - disposable.add(repository.runTransactionForResult(new InsertTherapyEventIfNewTransaction(date, event, 0, null, sp.getString("careportal_enteredby", "AndroidAPS"), null, null, null)) + disposable.add(repository.runTransactionForResult(new InsertTherapyEventIfNewTransaction(date, + event, 0, null, sp.getString("careportal_enteredby", "AndroidAPS"), + null, null, TherapyEvent.GlucoseUnit.MGDL)) .subscribe( result -> result.getInserted().forEach(nsUpload::uploadEvent), error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error) @@ -597,7 +599,7 @@ public class MedtronicHistoryData { List tdds = filterTDDs(tddsIn); - aapsLogger.debug(LTag.PUMP, getLogPrefix() + "TDDs found: {}.\n{}", tdds.size(), gson().toJson(tdds)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, getLogPrefix() + "TDDs found: %d.\n%s", tdds.size(), gson().toJson(tdds))); List tddsDb = databaseHelper.getTDDsForLastXDays(3); @@ -613,7 +615,7 @@ public class MedtronicHistoryData { TDD tddNew = new TDD(); totalsDTO.setTDD(tddNew); - aapsLogger.debug(LTag.PUMP, "TDD Add: {}", tddNew); + aapsLogger.debug(LTag.PUMP, "TDD Add: " + tddNew); databaseHelper.createOrUpdateTDD(tddNew); @@ -622,7 +624,7 @@ public class MedtronicHistoryData { if (!totalsDTO.doesEqual(tddDbEntry)) { totalsDTO.setTDD(tddDbEntry); - aapsLogger.debug(LTag.PUMP, "TDD Edit: {}", tddDbEntry); + aapsLogger.debug(LTag.PUMP, "TDD Edit: " + tddDbEntry); databaseHelper.createOrUpdateTDD(tddDbEntry); } @@ -656,8 +658,8 @@ public class MedtronicHistoryData { List entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.Bolus); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (before filter): {}, FromDb={}", gson().toJson(entryList), - gsonCore().toJson(entriesFromHistory)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: List (before filter): %s, FromDb=%s", gson().toJson(entryList), + gsonCore().toJson(entriesFromHistory))); filterOutAlreadyAddedEntries(entryList, entriesFromHistory); @@ -670,23 +672,23 @@ public class MedtronicHistoryData { filterOutNonInsulinEntries(entriesFromHistory); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: List (after filter): {}, FromDb={}", gson().toJson(entryList), - gsonCore().toJson(entriesFromHistory)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: List (after filter): %s, FromDb=%s", gson().toJson(entryList), + gsonCore().toJson(entriesFromHistory))); if (isCollectionEmpty(entriesFromHistory)) { for (PumpHistoryEntry treatment : entryList) { aapsLogger.debug(LTag.PUMP, "Add Bolus (no db entry): " + treatment); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: Add Bolus: FromDb=null, Treatment={}", treatment); + aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: Add Bolus: FromDb=null, Treatment=" + treatment); addBolus(treatment, null); } } else { for (PumpHistoryEntry treatment : entryList) { DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory); - aapsLogger.debug(LTag.PUMP, "Add Bolus {} - (entryFromDb={}) ", treatment, treatmentDb); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Add Bolus %s - (entryFromDb=%s) ", treatment, treatmentDb)); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: Add Bolus: FromDb={}, Treatment={}", treatmentDb, treatment); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: Add Bolus: FromDb=%s, Treatment=%s", treatmentDb, treatment)); addBolus(treatment, (Treatment) treatmentDb); } @@ -734,8 +736,8 @@ public class MedtronicHistoryData { List entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.TBR); - aapsLogger.debug(LTag.PUMP, ProcessHistoryRecord.TBR.getDescription() + " List (before filter): {}, FromDb={}", gson().toJson(entryList), - gson().toJson(entriesFromHistory)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, ProcessHistoryRecord.TBR.getDescription() + " List (before filter): %s, FromDb=%s", gson().toJson(entryList), + gson().toJson(entriesFromHistory))); TempBasalProcessDTO processDTO = null; @@ -755,7 +757,7 @@ public class MedtronicHistoryData { readOldItem = false; } } else { - aapsLogger.error("processDTO was null - shouldn't happen. ItemTwo={}", treatment); + aapsLogger.error("processDTO was null - shouldn't happen. ItemTwo=" + treatment); } } else { if (processDTO != null) { @@ -787,9 +789,9 @@ public class MedtronicHistoryData { databaseHelper.createOrUpdate(tempBasal); - aapsLogger.debug(LTag.PUMP, "Edit " + ProcessHistoryRecord.TBR.getDescription() + " - (entryFromDb={}) ", tempBasal); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Edit " + ProcessHistoryRecord.TBR.getDescription() + " - (entryFromDb=%s) ", tempBasal)); } else { - aapsLogger.error("TempBasal not found. Item: {}", tempBasalProcessDTO.itemOne); + aapsLogger.error(LTag.PUMP, "TempBasal not found. Item: " + tempBasalProcessDTO.itemOne); } } else { @@ -805,7 +807,7 @@ public class MedtronicHistoryData { if (tempBasal == null) { DbObjectBase treatmentDb = findDbEntry(treatment, entriesFromHistory); - aapsLogger.debug(LTag.PUMP, "Add " + ProcessHistoryRecord.TBR.getDescription() + " {} - (entryFromDb={}) ", treatment, treatmentDb); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Add " + ProcessHistoryRecord.TBR.getDescription() + " %s - (entryFromDb=%s) ", treatment, treatmentDb)); addTBR(treatment, (TemporaryBasal) treatmentDb); } else { @@ -854,22 +856,22 @@ public class MedtronicHistoryData { //proposedTime += (this.pumpTime.timeDifference * 1000); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}", treatment, gson().toJson(entriesFromHistory)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s", treatment, gson().toJson(entriesFromHistory))); if (entriesFromHistory.size() == 0) { if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb=null", treatment); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=null", treatment)); return null; } else if (entriesFromHistory.size() == 1) { if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=SingleEntry", treatment, entriesFromHistory.get(0)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment=%s, FromDb=%s. Type=SingleEntry", treatment, entriesFromHistory.get(0))); // TODO: Fix db code // if difference is bigger than 2 minutes we discard entry long maxMillisAllowed = DateTimeUtil.getMillisFromATDWithAddedMinutes(treatment.atechDateTime, 2); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry maxMillisAllowed={}, AtechDateTime={} (add 2 minutes). ", maxMillisAllowed, treatment.atechDateTime); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry maxMillisAllowed=%d, AtechDateTime=%d (add 2 minutes). ", maxMillisAllowed, treatment.atechDateTime)); if (entriesFromHistory.get(0).getDate() > maxMillisAllowed) { if (doubleBolusDebug) @@ -901,17 +903,17 @@ public class MedtronicHistoryData { if (outList.size() == 1) { if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=EntrySelected, AtTimeMin={}, AtTimeSec={}", treatment, entriesFromHistory.get(0), min, sec); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Treatment={}, FromDb={}. Type=EntrySelected, AtTimeMin={}, AtTimeSec={}", treatment, entriesFromHistory.get(0), min, sec)); return outList.get(0); } if (min == 0 && sec == 10 && outList.size() > 1) { - aapsLogger.error("Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})", - min, sec, outList.size(), gson().toJson(outList)); + aapsLogger.error(String.format(Locale.ENGLISH, "Too many entries (with too small diff): (timeDiff=[min=%d,sec=%d],count=%d,list=%s)", + min, sec, outList.size(), gson().toJson(outList))); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: findDbEntry Error - Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})", - min, sec, outList.size(), gson().toJson(outList)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: findDbEntry Error - Too many entries (with too small diff): (timeDiff=[min=%d,sec=%d],count=%d,list=%s)", + min, sec, outList.size(), gson().toJson(outList))); } } } @@ -960,9 +962,9 @@ public class MedtronicHistoryData { } if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: filterOutAlreadyAddedEntries: PumpHistory={}, Treatments={}", + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: filterOutAlreadyAddedEntries: PumpHistory=%s, Treatments=%s", gson().toJson(removeTreatmentsFromPH), - gsonCore().toJson(removeTreatmentsFromHistory)); + gsonCore().toJson(removeTreatmentsFromHistory))); treatmentsFromHistory.removeAll(removeTreatmentsFromHistory); } @@ -974,7 +976,7 @@ public class MedtronicHistoryData { if (treatment == null) { if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): Bolus={}", bolusDTO); + aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): Bolus=" + bolusDTO); switch (bolusDTO.getBolusType()) { case Normal: { @@ -988,14 +990,14 @@ public class MedtronicHistoryData { addCarbsFromEstimate(detailedBolusInfo, bolus); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): DetailedBolusInfo={}", detailedBolusInfo); + aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): DetailedBolusInfo=" + detailedBolusInfo); boolean newRecord = activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false); bolus.setLinkedObject(detailedBolusInfo); - aapsLogger.debug(LTag.PUMP, "addBolus - [date={},pumpId={}, insulin={}, newRecord={}]", detailedBolusInfo.date, - detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "addBolus - [date=%d,pumpId=%d, insulin=%.2f, newRecord=%b]", detailedBolusInfo.date, + detailedBolusInfo.pumpId, detailedBolusInfo.insulin, newRecord)); } break; @@ -1012,12 +1014,12 @@ public class MedtronicHistoryData { bolus.setLinkedObject(extendedBolus); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): ExtendedBolus={}", extendedBolus); + aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament==null): ExtendedBolus=" + extendedBolus); activePlugin.getActiveTreatments().addToHistoryExtendedBolus(extendedBolus); - aapsLogger.debug(LTag.PUMP, "addBolus - Extended [date={},pumpId={}, insulin={}, duration={}]", extendedBolus.date, - extendedBolus.pumpId, extendedBolus.insulin, extendedBolus.durationInMinutes); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "addBolus - Extended [date=%d,pumpId=%d, insulin=%.3f, duration=%d]", extendedBolus.date, + extendedBolus.pumpId, extendedBolus.insulin, extendedBolus.durationInMinutes)); } break; @@ -1026,7 +1028,7 @@ public class MedtronicHistoryData { } else { if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(OldTreatment={}): Bolus={}", treatment, bolusDTO); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: addBolus(OldTreatment=%s): Bolus=%s", treatment, bolusDTO)); treatment.source = Source.PUMP; treatment.pumpId = bolus.getPumpId(); @@ -1035,10 +1037,10 @@ public class MedtronicHistoryData { TreatmentUpdateReturn updateReturn = activePlugin.getActiveTreatments().createOrUpdateMedtronic(treatment, false); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addBolus(tretament!=null): NewTreatment={}, UpdateReturn={}", treatment, updateReturn); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: addBolus(tretament!=null): NewTreatment=%s, UpdateReturn=%s", treatment, updateReturn)); - aapsLogger.debug(LTag.PUMP, "editBolus - [date={},pumpId={}, insulin={}, newRecord={}]", treatment.date, - treatment.pumpId, treatment.insulin, updateReturn.toString()); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "editBolus - [date=%d,pumpId=%d, insulin=%.3f, newRecord=%s]", treatment.date, + treatment.pumpId, treatment.insulin, updateReturn.toString())); bolus.setLinkedObject(treatment); @@ -1053,7 +1055,7 @@ public class MedtronicHistoryData { BolusWizardDTO bolusWizard = (BolusWizardDTO) bolus.getDecodedData().get("Estimate"); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: addCarbsFromEstimate: Bolus={}, BolusWizardDTO={}", bolus, bolusWizard); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: addCarbsFromEstimate: Bolus=%s, BolusWizardDTO=%s", bolus, bolusWizard)); detailedBolusInfo.carbs = bolusWizard.carbs; } @@ -1084,13 +1086,13 @@ public class MedtronicHistoryData { databaseHelper.createOrUpdate(temporaryBasalDb); - aapsLogger.debug(LTag.PUMP, operation + " - [date={},pumpId={}, rate={} {}, duration={}]", // + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, operation + " - [date=%d,pumpId=%d, rate=%s %s, duration=%d]", // temporaryBasalDb.date, // temporaryBasalDb.pumpId, // temporaryBasalDb.isAbsolute ? String.format(Locale.ENGLISH, "%.2f", temporaryBasalDb.absoluteRate) : String.format(Locale.ENGLISH, "%d", temporaryBasalDb.percentRate), // temporaryBasalDb.isAbsolute ? "U/h" : "%", // - temporaryBasalDb.durationInMinutes); + temporaryBasalDb.durationInMinutes)); } @@ -1372,7 +1374,7 @@ public class MedtronicHistoryData { // oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference); // } } catch (Exception ex) { - aapsLogger.error("Problem decoding date from last record: {}" + currentTreatment); + aapsLogger.error("Problem decoding date from last record: " + currentTreatment); return 8; // default return of 6 minutes } @@ -1381,8 +1383,8 @@ public class MedtronicHistoryData { Minutes minutes = Minutes.minutesBetween(oldestEntryTime, now); // returns oldest time in history, with calculated time difference between pump and phone, minus 5 minutes - aapsLogger.debug(LTag.PUMP, "Oldest entry: {}, pumpTimeDifference={}, newDt={}, currentTime={}, differenceMin={}", dt, - this.pumpTime.timeDifference, oldestEntryTime, now, minutes.getMinutes()); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "Oldest entry: %d, pumpTimeDifference=%d, newDt=%s, currentTime=%s, differenceMin=%d", dt, + this.pumpTime.timeDifference, oldestEntryTime, now, minutes.getMinutes())); return minutes.getMinutes(); } @@ -1402,22 +1404,22 @@ public class MedtronicHistoryData { } if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: getOldestTimestamp. Oldest entry found: time={}, object={}", dt, currentTreatment); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: getOldestTimestamp. Oldest entry found: time=%d, object=%s", dt, currentTreatment)); try { GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(dt); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime: {}", DateTimeUtil.toString(oldestEntryTime)); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime: %s", DateTimeUtil.toString(oldestEntryTime))); oldestEntryTime.add(Calendar.MINUTE, -2); if (doubleBolusDebug) - aapsLogger.debug(LTag.PUMP, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime (-2m): {}, timeInMillis={}", DateTimeUtil.toString(oldestEntryTime), oldestEntryTime.getTimeInMillis()); + aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "DoubleBolusDebug: getOldestTimestamp. oldestEntryTime (-2m): %s, timeInMillis=%d", DateTimeUtil.toString(oldestEntryTime), oldestEntryTime.getTimeInMillis())); return oldestEntryTime.getTimeInMillis(); } catch (Exception ex) { - aapsLogger.error("Problem decoding date from last record: {}", currentTreatment); + aapsLogger.error("Problem decoding date from last record: " + currentTreatment); return 8; // default return of 6 minutes } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java index 8af98fd4bc..3cbd03f20d 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java @@ -1,12 +1,14 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; +import androidx.annotation.NonNull; + import com.google.gson.annotations.Expose; -import androidx.annotation.NonNull; import org.joda.time.Instant; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -47,7 +49,7 @@ public class BasalProfile { public BasalProfile(AAPSLogger aapsLogger, byte[] data) { - this .aapsLogger = aapsLogger; + this.aapsLogger = aapsLogger; setRawData(data); } @@ -68,7 +70,7 @@ public class BasalProfile { private boolean setRawData(byte[] data) { if (data == null) { - aapsLogger.error(LTag.PUMPCOMM,"setRawData: buffer is null!"); + aapsLogger.error(LTag.PUMPCOMM, "setRawData: buffer is null!"); return false; } @@ -91,7 +93,7 @@ public class BasalProfile { public boolean setRawDataFromHistory(byte[] data) { if (data == null) { - aapsLogger.error(LTag.PUMPCOMM,"setRawData: buffer is null!"); + aapsLogger.error(LTag.PUMPCOMM, "setRawData: buffer is null!"); return false; } @@ -116,14 +118,14 @@ public class BasalProfile { public void dumpBasalProfile() { - aapsLogger.debug(LTag.PUMPCOMM,"Basal Profile entries:"); + aapsLogger.debug(LTag.PUMPCOMM, "Basal Profile entries:"); List entries = getEntries(); for (int i = 0; i < entries.size(); i++) { BasalProfileEntry entry = entries.get(i); String startString = entry.startTime.toString("HH:mm"); // this doesn't work - 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)); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Entry %d, rate=%.3f (%s), start=%s (0x%02X)", i + 1, entry.rate, + ByteUtil.getHex(entry.rate_raw), startString, entry.startTime_raw)); } } @@ -136,7 +138,7 @@ public class BasalProfile { BasalProfileEntry entry = entries.get(i); String startString = entry.startTime.toString("HH:mm"); - sb.append(String.format("Entry %d, rate=%.3f, start=%s\n", i + 1, entry.rate, startString)); + sb.append(String.format(Locale.ENGLISH, "Entry %d, rate=%.3f, start=%s\n", i + 1, entry.rate, startString)); } return sb.toString(); @@ -154,7 +156,7 @@ public class BasalProfile { BasalProfileEntry entry = entries.get(i); String startString = entry.startTime.toString("HH:mm"); - sb.append(String.format("%s=%.3f, ", startString, entry.rate)); + sb.append(String.format(Locale.ENGLISH, "%s=%.3f, ", startString, entry.rate)); } sb.append("]"); @@ -169,14 +171,14 @@ public class BasalProfile { BasalProfileEntry rval = new BasalProfileEntry(); List entries = getEntries(); if (entries.size() == 0) { - aapsLogger.warn(LTag.PUMPCOMM,String.format("getEntryForTime(%s): table is empty", + aapsLogger.warn(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getEntryForTime(%s): table is empty", when.toDateTime().toLocalTime().toString("HH:mm"))); return rval; } // Log.w(TAG,"Assuming first entry"); rval = entries.get(0); if (entries.size() == 1) { - aapsLogger.debug(LTag.PUMPCOMM,"getEntryForTime: Only one entry in profile"); + aapsLogger.debug(LTag.PUMPCOMM, "getEntryForTime: Only one entry in profile"); return rval; } @@ -186,17 +188,17 @@ public class BasalProfile { while (!done) { BasalProfileEntry entry = entries.get(i); if (DEBUG_BASALPROFILE) { - aapsLogger.debug(LTag.PUMPCOMM,String.format("Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime() + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "Comparing 'now'=%s to entry 'start time'=%s", when.toDateTime().toLocalTime() .toString("HH:mm"), entry.startTime.toString("HH:mm"))); } if (localMillis >= entry.startTime.getMillisOfDay()) { rval = entry; if (DEBUG_BASALPROFILE) - aapsLogger.debug(LTag.PUMPCOMM,"Accepted Entry"); + aapsLogger.debug(LTag.PUMPCOMM, "Accepted Entry"); } else { // entry at i has later start time, keep older entry if (DEBUG_BASALPROFILE) - aapsLogger.debug(LTag.PUMPCOMM,"Rejected Entry"); + aapsLogger.debug(LTag.PUMPCOMM, "Rejected Entry"); done = true; } i++; @@ -205,8 +207,8 @@ public class BasalProfile { } } if (DEBUG_BASALPROFILE) { - 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, + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "getEntryForTime(%s): Returning entry: rate=%.3f (%s), start=%s (%d)", when + .toDateTime().toLocalTime().toString("HH:mm"), rval.rate, ByteUtil.getHex(rval.rate_raw), rval.startTime.toString("HH:mm"), rval.startTime_raw)); } return rval; @@ -217,7 +219,7 @@ public class BasalProfile { List entries = new ArrayList<>(); if (mRawData == null || mRawData[2] == 0x3f) { - aapsLogger.warn(LTag.PUMPCOMM,"Raw Data is empty."); + aapsLogger.warn(LTag.PUMPCOMM, "Raw Data is empty."); return entries; // an empty list } int r, st; @@ -236,7 +238,7 @@ public class BasalProfile { try { entries.add(new BasalProfileEntry(aapsLogger, r, st)); } catch (Exception ex) { - aapsLogger.error(LTag.PUMPCOMM,"Error decoding basal profile from bytes: {}", ByteUtil.shortHexString(mRawData)); + aapsLogger.error(LTag.PUMPCOMM, "Error decoding basal profile from bytes: " + ByteUtil.shortHexString(mRawData)); throw ex; } @@ -285,10 +287,10 @@ public class BasalProfile { try { entries = getEntries(); } catch (Exception ex) { - aapsLogger.error(LTag.PUMPCOMM,"============================================================================="); - aapsLogger.error(LTag.PUMPCOMM," Error generating entries. Ex.: " + ex, ex); - aapsLogger.error(LTag.PUMPCOMM," rawBasalValues: " + ByteUtil.shortHexString(this.getRawData())); - aapsLogger.error(LTag.PUMPCOMM,"============================================================================="); + aapsLogger.error(LTag.PUMPCOMM, "============================================================================="); + aapsLogger.error(LTag.PUMPCOMM, " Error generating entries. Ex.: " + ex, ex); + aapsLogger.error(LTag.PUMPCOMM, " rawBasalValues: " + ByteUtil.shortHexString(this.getRawData())); + aapsLogger.error(LTag.PUMPCOMM, "============================================================================="); //FabricUtil.createEvent("MedtronicBasalProfileGetByHourError", null); } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileEntry.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileEntry.java index 05d8eaaa16..da2a7181c0 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileEntry.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileEntry.java @@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; import org.joda.time.LocalTime; +import java.util.Locale; + import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; @@ -53,8 +55,8 @@ public class BasalProfileEntry { startTime = new LocalTime(startTimeInterval / 2, (startTimeInterval % 2) * 30); } catch (Exception ex) { aapsLogger.error(LTag.PUMPCOMM, - "Error creating BasalProfileEntry: startTimeInterval={}, startTime_raw={}, hours={}, rateStrokes={}", - startTimeInterval, startTime_raw, startTimeInterval / 2, rateStrokes); + String.format(Locale.ENGLISH, "Error creating BasalProfileEntry: startTimeInterval=%d, startTime_raw=%d, hours=%d, rateStrokes=%d", + startTimeInterval, startTime_raw, startTimeInterval / 2, rateStrokes)); throw ex; } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusWizardDTO.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusWizardDTO.java index 5d9710a5c5..24b63015c4 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusWizardDTO.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BolusWizardDTO.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; +import java.util.Locale; + import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; /** @@ -26,15 +28,15 @@ public class BolusWizardDTO extends PumpTimeStampedRecord { // public long atechDateTime; public String getValue() { - return String.format("BG=%d;CH=%d;CH_UNIT=%s;CH_INS_RATIO=%5.3f;BG_INS_RATIO=%5.3f;" - + "BG_TARGET_LOW=%d;BG_TARGET_HIGH=%d;BOLUS_TOTAL=%5.3f;" - + "BOLUS_CORRECTION=%5.3f;BOLUS_FOOD=%5.3f;UNABSORBED_INSULIN=%5.3f", // - bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, // - bgTargetHigh, bolusTotal, correctionEstimate, foodEstimate, unabsorbedInsulin); + return String.format(Locale.ENGLISH, "BG=%d;CH=%d;CH_UNIT=%s;CH_INS_RATIO=%5.3f;BG_INS_RATIO=%5.3f;" + + "BG_TARGET_LOW=%d;BG_TARGET_HIGH=%d;BOLUS_TOTAL=%5.3f;" + + "BOLUS_CORRECTION=%5.3f;BOLUS_FOOD=%5.3f;UNABSORBED_INSULIN=%5.3f", // + bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, // + bgTargetHigh, bolusTotal, correctionEstimate, foodEstimate, unabsorbedInsulin); } public String getDisplayableValue() { - return String.format("Bg=%d, CH=%d %s, Ch/Ins Ratio=%5.3f, Bg/Ins Ratio=%5.3f;" + return String.format(Locale.ENGLISH, "Bg=%d, CH=%d %s, Ch/Ins Ratio=%5.3f, Bg/Ins Ratio=%5.3f;" + "Bg Target(L/H)=%d/%d, Bolus: Total=%5.3f, " + "Correction=%5.3f, Food=%5.3f, IOB=%5.3f", // bloodGlucose, carbs, chUnit, carbRatio, insulinSensitivity, bgTargetLow, // diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/DailyTotalsDTO.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/DailyTotalsDTO.java index 72c3af8a6b..697b74aa74 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/DailyTotalsDTO.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/DailyTotalsDTO.java @@ -6,6 +6,8 @@ import com.google.gson.annotations.Expose; import org.apache.commons.lang3.builder.ToStringBuilder; +import java.util.Locale; + import info.nightscout.androidaps.db.TDD; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; @@ -128,11 +130,11 @@ public class DailyTotalsDTO { int j1 = ByteUtil.toInt(body[i + 1], body[i]); int k1 = ByteUtil.toInt(body[i + 2], body[i + 1], body[i]); - System.out.println(String.format( + System.out.println(String.format(Locale.ENGLISH, "index: %d, number=%d, del/40=%.3f, del/10=%.3f, singular=%d, sing_hex=%s", i, j, j / 40.0d, j / 10.0d, body[i], ByteUtil.shortHexString(body[i]))); - System.out.println(String.format(" number[k,j1,k1]=%d / %d /%d, del/40=%.3f, del/40=%.3f, del/40=%.3f", + System.out.println(String.format(Locale.ENGLISH, " number[k,j1,k1]=%d / %d /%d, del/40=%.3f, del/40=%.3f, del/40=%.3f", k, j1, k1, k / 40.0d, j1 / 40.0d, k1 / 40.0d)); } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java index 86e5c9bd36..d6399beafd 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java @@ -76,7 +76,7 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo durationMinutes = MedtronicUtil.makeUnsignedShort(response[4], response[5]); } - aapsLogger.warn(LTag.PUMPBTCOMM, "TempBasalPair (with {} byte response): {}", response.length, toString()); + aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "TempBasalPair (with %d byte response): %s", response.length, toString())); } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java index 9f1d2a092b..870bbe273d 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java @@ -14,25 +14,24 @@ import javax.inject.Singleton; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; +import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus; import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType; import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType; -import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; - /** * Created by andy on 4/28/18. */ @Singleton -public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump.common.data.PumpStatus { +public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump.common.data.PumpStatus { private final ResourceHelper resourceHelper; private final SP sp; @@ -62,9 +61,9 @@ public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump @Inject public MedtronicPumpStatus(ResourceHelper resourceHelper, - SP sp, - RxBusWrapper rxBus, - RileyLinkUtil rileyLinkUtil + SP sp, + RxBusWrapper rxBus, + RileyLinkUtil rileyLinkUtil ) { super(PumpType.Medtronic_522_722); this.resourceHelper = resourceHelper; diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index 5447240b04..2c5274ba0b 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -261,7 +261,7 @@ public class RileyLinkMedtronicService extends RileyLinkService { } else { if (!rileyLinkAddress.matches(regexMac)) { medtronicPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid); - aapsLogger.debug(LTag.PUMP, "RileyLink address invalid: {}", rileyLinkAddress); + aapsLogger.debug(LTag.PUMP, "RileyLink address invalid: %s", rileyLinkAddress); } else { if (!rileyLinkAddress.equals(this.rileyLinkAddress)) { this.rileyLinkAddress = rileyLinkAddress; @@ -317,6 +317,8 @@ public class RileyLinkMedtronicService extends RileyLinkService { //boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on)); //MedtronicHistoryData.doubleBolusDebug = bolusDebug; + rileyLinkServiceData.showBatteryLevel = sp.getBoolean(RileyLinkConst.Prefs.ShowBatteryLevel, false); + reconfigureService(forceRileyLinkAddressRenewal); return true; @@ -366,7 +368,7 @@ public class RileyLinkMedtronicService extends RileyLinkService { try { val = Double.parseDouble(value); } catch (Exception ex) { - aapsLogger.error("Error parsing setting: {}, value found {}", key, value); + aapsLogger.error("Error parsing setting: %s, value found %s", key, value); val = defaultValueDouble; } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.java index 3ff79616ec..680896751c 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.java @@ -9,6 +9,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.inject.Inject; @@ -20,8 +21,8 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; +import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO; @@ -31,7 +32,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandTy import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType; import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; -import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange; import info.nightscout.androidaps.utils.resources.ResourceHelper; /** @@ -276,7 +276,7 @@ public class MedtronicUtil { byte[] payload = sendPayloadBuffer.array(); - aapsLogger.debug(LTag.PUMPCOMM, "buildCommandPayload [{}]", ByteUtil.shortHexString(payload)); + aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "buildCommandPayload [%s]", ByteUtil.shortHexString(payload))); // int crc = computeCRC8WithPolynomial(payload, 0, payload.length - 1); diff --git a/medtronic/src/main/res/layout/medtronic_fragment.xml b/medtronic/src/main/res/layout/medtronic_fragment.xml index 2be4848f46..bd30507a75 100644 --- a/medtronic/src/main/res/layout/medtronic_fragment.xml +++ b/medtronic/src/main/res/layout/medtronic_fragment.xml @@ -86,6 +86,58 @@ + + + + + + + + + + + + + + NiMH (Extended view) Bolus/Treatments Debugging - + + RileyLink Battery Errors @@ -79,8 +80,6 @@ Medtronic Pump History - - You cancelled Bolus, after it was already set on Pump. Since Medtronic Pump doesn\'t support cancel, you will need to manually cancel it. Put the Pump into Suspend mode and then do Resume (if you still want to cancel). Application will pick up changes, on next update (in less than 5 minutes). Could not read current TBR. @@ -117,6 +116,7 @@ Set neutral temp basals If enabled, it will cancel a temporary basal before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. + ^\\d{6} \ No newline at end of file diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java index a7aae37175..0a88d5b510 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink; +import java.util.Locale; + import javax.inject.Inject; import dagger.android.HasAndroidInjector; @@ -85,8 +87,8 @@ public abstract class RileyLinkCommunicationManager { // Mark this as the last time we heard from the pump. rememberLastGoodDeviceCommunicationTime(); } else { - aapsLogger.warn(LTag.PUMPBTCOMM, "isDeviceReachable. Response is invalid ! [noResponseFromRileyLink={}, interrupted={}, timeout={}, unknownCommand={}, invalidParam={}]", - rfSpyResponse.wasNoResponseFromRileyLink(), rfSpyResponse.wasInterrupted(), rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam()); + aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "isDeviceReachable. Response is invalid ! [noResponseFromRileyLink=%b, interrupted=%b, timeout=%b, unknownCommand=%b, invalidParam=%b]", + rfSpyResponse.wasNoResponseFromRileyLink(), rfSpyResponse.wasInterrupted(), rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam())); if (rfSpyResponse.wasTimeout()) { if (rileyLinkServiceData.targetDevice.isTuneUpEnabled()) { @@ -214,7 +216,7 @@ public abstract class RileyLinkCommunicationManager { private double scanForDevice(double[] frequencies) { - aapsLogger.info(LTag.PUMPBTCOMM, "Scanning for receiver ({})", receiverDeviceID); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Scanning for receiver (%s)", receiverDeviceID)); wakeUp(receiverDeviceAwakeForMinutes, false); FrequencyScanResults results = new FrequencyScanResults(); @@ -231,7 +233,7 @@ public abstract class RileyLinkCommunicationManager { RFSpyResponse resp = rfspy.transmitThenReceive(new RadioPacket(injector, pumpMsgContent), (byte) 0, (byte) 0, (byte) 0, (byte) 0, 1250, (byte) 0); if (resp.wasTimeout()) { - aapsLogger.error(LTag.PUMPBTCOMM, "scanForPump: Failed to find pump at frequency {}", frequencies[i]); + aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "scanForPump: Failed to find pump at frequency %.3f", frequencies[i])); } else if (resp.looksLikeRadioPacket()) { RadioResponse radioResponse = new RadioResponse(injector); @@ -319,14 +321,14 @@ public abstract class RileyLinkCommunicationManager { RadioPacket pkt = new RadioPacket(injector, pumpMsgContent); RFSpyResponse resp = rfspy.transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, SCAN_TIMEOUT, (byte) 0); if (resp.wasTimeout()) { - aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: no pump response at frequency {}", freqMHz); + aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "tune_tryFrequency: no pump response at frequency %.3f", freqMHz)); } else if (resp.looksLikeRadioPacket()) { RadioResponse radioResponse = new RadioResponse(injector); try { radioResponse.init(resp.getRaw()); if (radioResponse.isValid()) { - aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: saw response level {} at frequency {}", radioResponse.rssi, freqMHz); + aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "tune_tryFrequency: saw response level %d at frequency %.3f", radioResponse.rssi, freqMHz)); return calculateRssi(radioResponse.rssi); } else { aapsLogger.warn(LTag.PUMPBTCOMM, "tune_tryFrequency: invalid radio response:" @@ -365,9 +367,9 @@ public abstract class RileyLinkCommunicationManager { } else { rfspy.setBaseFrequency(betterFrequency); if (betterFrequency != startFrequencyMHz) { - aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: new frequency is {}MHz", betterFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "quickTuneForPump: new frequency is %.3fMHz", betterFrequency)); } else { - aapsLogger.info(LTag.PUMPBTCOMM, "quickTuneForPump: pump frequency is the same: {}MHz", startFrequencyMHz); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "quickTuneForPump: pump frequency is the same: %.3fMHz", startFrequencyMHz)); } } return betterFrequency; @@ -375,7 +377,7 @@ public abstract class RileyLinkCommunicationManager { private double quickTunePumpStep(double startFrequencyMHz, double stepSizeMHz) { - aapsLogger.info(LTag.PUMPBTCOMM, "Doing quick radio tune for receiver ({})", receiverDeviceID); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Doing quick radio tune for receiver (%s)", receiverDeviceID)); wakeUp(false); int startRssi = tune_tryFrequency(startFrequencyMHz); double lowerFrequency = startFrequencyMHz - stepSizeMHz; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java index 28f551e188..2d6c93a0a9 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java @@ -37,6 +37,7 @@ public class RileyLinkConst { public static final String LastGoodDeviceCommunicationTime = Prefix + "lastGoodDeviceCommunicationTime"; public static final String LastGoodDeviceFrequency = Prefix + "LastGoodDeviceFrequency"; public static final int Encoding = R.string.key_medtronic_encoding; + public static final int ShowBatteryLevel = R.string.key_riley_link_show_battery_level; } public static class IPC { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index 0f3f92cb5d..9d8c976363 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -4,6 +4,7 @@ import android.os.SystemClock; import org.apache.commons.lang3.ArrayUtils; +import java.util.Locale; import java.util.Optional; import java.util.UUID; @@ -115,7 +116,7 @@ public class RFSpy { if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) { if (ArrayUtils.isNotEmpty(result.value)) { int value = result.value[0]; - aapsLogger.debug(LTag.PUMPBTCOMM, "BLE battery level: {}", value); + aapsLogger.debug(LTag.PUMPBTCOMM, "getBatteryLevel response received: " + value); return value; } else { aapsLogger.error(LTag.PUMPBTCOMM, "getBatteryLevel received an empty result. Value: " + result.value); @@ -150,7 +151,7 @@ public class RFSpy { byte[] getVersionRaw = getByteArray(RileyLinkCommandType.GetVersion.code); byte[] response = writeToDataRaw(getVersionRaw, 5000); - aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. GetVersion [response={}]", ByteUtil.shortHexString(response)); + aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Firmware Version. GetVersion [response=%s]", ByteUtil.shortHexString(response))); if (response != null) { // && response[0] == (byte) 0xDD) { @@ -171,14 +172,14 @@ public class RFSpy { static RileyLinkFirmwareVersion getFirmwareVersion(AAPSLogger aapsLogger, String bleVersion, String cc1110Version) { if (cc1110Version != null) { RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(cc1110Version); - aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", cc1110Version, version); + aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Firmware Version string: %s, resolved to %s.", cc1110Version, version)); if (version != RileyLinkFirmwareVersion.UnknownVersion) { return version; } } - aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [{}].", bleVersion); + aapsLogger.error(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Firmware Version can't be determined. Checking with BLE Version [%s].", bleVersion)); if (bleVersion.contains(" 2.")) { return RileyLinkFirmwareVersion.Version_2_0; @@ -201,7 +202,7 @@ public class RFSpy { // prepend length, and send it. byte[] prepended = ByteUtil.concat(new byte[]{(byte) (bytes.length)}, bytes); - aapsLogger.debug(LTag.PUMPBTCOMM, "writeToData (raw={})", ByteUtil.shortHexString(prepended)); + aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "writeToData (raw=%s)", ByteUtil.shortHexString(prepended))); BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID, prepended); @@ -292,7 +293,7 @@ public class RFSpy { updateRegister(CC111XRegister.freq0, (byte) (value & 0xff)); updateRegister(CC111XRegister.freq1, (byte) ((value >> 8) & 0xff)); updateRegister(CC111XRegister.freq2, (byte) ((value >> 16) & 0xff)); - aapsLogger.info(LTag.PUMPBTCOMM, "Set frequency to {} MHz", freqMHz); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Set frequency to %.3f MHz", freqMHz)); this.currentFrequencyMHz = freqMHz; @@ -350,7 +351,7 @@ public class RFSpy { setPreamble(0x6665); break; default: - aapsLogger.warn(LTag.PUMPBTCOMM, "No region configuration for RfSpy and {}", frequency.name()); + aapsLogger.warn(LTag.PUMPBTCOMM, "No region configuration for RfSpy and " + frequency.name()); break; } @@ -359,7 +360,7 @@ public class RFSpy { private void setMedtronicEncoding() { RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal; - if (rileyLinkServiceData.firmwareVersion!=null && + if (rileyLinkServiceData.firmwareVersion != null && rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) { if (sp.getString(RileyLinkConst.Prefs.Encoding, "None") .equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java index 7b13811a25..3527daaa94 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java @@ -14,6 +14,7 @@ import android.os.SystemClock; import org.apache.commons.lang3.StringUtils; import java.util.List; +import java.util.Locale; import java.util.UUID; import java.util.concurrent.Semaphore; @@ -148,20 +149,20 @@ public class RileyLinkBLE { if (status == BluetoothGatt.GATT_SUCCESS) { rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.BluetoothConnected, context); } else { - aapsLogger.debug(LTag.PUMPBTCOMM, "BT State connected, GATT status {} ({})", status, getGattStatusMessage(status)); + aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "BT State connected, GATT status %d (%s)", status, getGattStatusMessage(status))); } } else if ((newState == BluetoothProfile.STATE_CONNECTING) || // (newState == BluetoothProfile.STATE_DISCONNECTING)) { - aapsLogger.debug(LTag.PUMPBTCOMM, "We are in {} state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" : - "Disconnecting"); + aapsLogger.debug(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "We are in %s state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" : + "Disconnecting")); } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnected, context); if (manualDisconnect) close(); aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLink Disconnected."); } else { - aapsLogger.warn(LTag.PUMPBTCOMM, "Some other state: (status={},newState={})", status, newState); + aapsLogger.warn(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Some other state: (status=%d, newState=%d)", status, newState)); } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java index 8d4e80d752..36a4b4cd71 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java @@ -17,8 +17,8 @@ public abstract class Encoding4b6bAbstract implements Encoding4b6b { * The 6 bit codes are what is used on the RF side of the RileyLink to communicate * with a Medtronic pump. */ - public static final byte[] encode4b6bList = new byte[] { - 0x15, 0x31, 0x32, 0x23, 0x34, 0x25, 0x26, 0x16, 0x1a, 0x19, 0x2a, 0x0b, 0x2c, 0x0d, 0x0e, 0x1c }; + public static final byte[] encode4b6bList = new byte[]{ + 0x15, 0x31, 0x32, 0x23, 0x34, 0x25, 0x26, 0x16, 0x1a, 0x19, 0x2a, 0x0b, 0x2c, 0x0d, 0x0e, 0x1c}; // 21, 49, 50, 35, 52, 37, 38, 22, 26, 25, 42, 11, 44, 13, 14, 28 @@ -53,12 +53,12 @@ public abstract class Encoding4b6bAbstract implements Encoding4b6b { public void writeError(Logger LOG, byte[] raw, String errorData) { - LOG.error("\n=============================================================================\n" + // - " Decoded payload length is zero.\n" + - " encodedPayload: {}\n" + - " errors: {}\n" + - "=============================================================================", // - ByteUtil.getHex(raw), errorData); + LOG.error(String.format("\n=============================================================================\n" + // + " Decoded payload length is zero.\n" + + " encodedPayload: %s\n" + + " errors: %s\n" + + "=============================================================================", // + ByteUtil.getHex(raw), errorData)); //FabricUtil.createEvent("MedtronicDecode4b6bError", null); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java index 1b0dcb7dc4..a5b81a10c6 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; @@ -121,7 +122,7 @@ 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( + errorMessageBuilder.append(String.format(Locale.ENGLISH, "decode4b6b: i=%d,x=%08X, coding error: highcode=0x%02X, lowcode=0x%02X, %d bits remaining.\n", i, x, highcode, lowcode, availableBits)); codingErrors++; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java index 378f478643..5c8e47d74a 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java @@ -6,6 +6,8 @@ import android.content.Intent; import androidx.annotation.NonNull; +import java.util.Locale; + import javax.inject.Inject; import dagger.android.DaggerService; @@ -174,8 +176,8 @@ public abstract class RileyLinkService extends DaggerService { if (rileyLinkServiceData.getRileyLinkServiceState() == RileyLinkServiceState.NotStarted) { if (!bluetoothInit()) { - aapsLogger.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}", - getError() != null ? getError().name() : "Unknown error (null)"); + aapsLogger.error("RileyLink can't get activated, Bluetooth is not functioning correctly. " + + (getError() != null ? getError().name() : "Unknown error (null)")); return false; } } @@ -205,7 +207,7 @@ public abstract class RileyLinkService extends DaggerService { newFrequency = getDeviceCommunicationManager().tuneForDevice(); if ((newFrequency != 0.0) && (newFrequency != lastGoodFrequency)) { - aapsLogger.info(LTag.PUMPBTCOMM, "Saving new pump frequency of {} MHz", newFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Saving new pump frequency of %.3f MHz", newFrequency)); sp.putDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, newFrequency); rileyLinkServiceData.lastGoodFrequency = newFrequency; rileyLinkServiceData.tuneUpDone = true; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java index e7f38d0a58..7b68549902 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service; +import java.util.Locale; + import javax.inject.Inject; import javax.inject.Singleton; @@ -38,6 +40,7 @@ public class RileyLinkServiceData { public String rileyLinkAddress; public String rileyLinkName; public Integer batteryLevel; + public boolean showBatteryLevel = false; long lastTuneUpTime = 0L; public Double lastGoodFrequency; @@ -83,7 +86,7 @@ public class RileyLinkServiceData { lastServiceStateChange = System.currentTimeMillis(); this.rileyLinkError = errorCode; - aapsLogger.info(LTag.PUMP, "RileyLink State Changed: {} {}", newState, errorCode == null ? "" : " - Error State: " + errorCode.name()); + aapsLogger.info(LTag.PUMP, String.format(Locale.ENGLISH, "RileyLink State Changed: %s %s", newState, errorCode == null ? "" : " - Error State: " + errorCode.name())); rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice)); rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode)); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java index bea2d44323..c4732ea938 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java @@ -2,10 +2,11 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.task import android.content.Context; +import java.util.Locale; + import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.common.ManufacturerType; @@ -83,7 +84,7 @@ public class InitializePumpManagerTask extends ServiceTask { rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady); - aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Setting radio frequency to %.3f MHz", lastGoodFrequency)); rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency); @@ -112,7 +113,7 @@ public class InitializePumpManagerTask extends ServiceTask { rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady); rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod; // TODO shouldn't be needed - aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to {} MHz", lastGoodFrequency); + aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Setting radio frequency to %.3f MHz", lastGoodFrequency)); rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);