Rename PodInfo*HighFlashLogDump to PodInfo*PulseLog and don't show spaces in hex string when showing the response of these commands (as per suggested by @itsmojo)

This commit is contained in:
Bart Sopers 2019-12-28 21:56:10 -05:00
parent ae0e18e128
commit a79a1c1108
12 changed files with 75 additions and 50 deletions

View file

@ -116,6 +116,21 @@ public class ByteUtil {
return rval; return rval;
} }
public static String shortHexStringWithoutSpaces(byte[] byteArray) {
String hexString = "";
if (byteArray == null) {
return hexString;
}
if (byteArray.length == 0) {
return hexString;
}
for (byte b : byteArray) {
hexString = hexString + HEX_DIGITS[(b & 0xF0) >> 4];
hexString = hexString + HEX_DIGITS[(b & 0x0F)];
}
return hexString;
}
public static String shortHexString(List<Byte> list) { public static String shortHexString(List<Byte> list) {
byte[] abyte0 = getByteArrayFromList(list); byte[] abyte0 = getByteArrayFromList(list);

View file

@ -48,7 +48,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
@ -67,7 +67,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.OKDialog;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
@ -377,7 +376,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
if (omnipodStatusRequest==OmnipodStatusRequest.GetPodPulseLog) { if (omnipodStatusRequest==OmnipodStatusRequest.GetPodPulseLog) {
OmnipodUITask omnipodUITask = omnipodUIComm.executeCommand(omnipodStatusRequest.getCommandType()); OmnipodUITask omnipodUITask = omnipodUIComm.executeCommand(omnipodStatusRequest.getCommandType());
PodInfoRecentHighFlashLogDump result = (PodInfoRecentHighFlashLogDump)omnipodUITask.returnDataObject; PodInfoRecentPulseLog result = (PodInfoRecentPulseLog)omnipodUITask.returnDataObject;
if (result==null) { if (result==null) {
LOG.warn("Result was null."); LOG.warn("Result was null.");

View file

@ -28,7 +28,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.Inser
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService; import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.CancelDeliveryCommand; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.CancelDeliveryCommand;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus; import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus;
@ -408,8 +408,8 @@ public class OmnipodManager {
// FIXME replace by storing to file // FIXME replace by storing to file
if (isLoggingEnabled()) { if (isLoggingEnabled()) {
try { try {
PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podState, PodInfoType.RECENT_HIGH_FLASH_LOG_DUMP)); PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podState, PodInfoType.RECENT_PULSE_LOG));
PodInfoRecentHighFlashLogDump pulseLogInfo = podInfoResponse.getPodInfo(); PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo();
LOG.info("Retrieved pulse log from the pod: {}", pulseLogInfo.toString()); LOG.info("Retrieved pulse log from the pod: {}", pulseLogInfo.toString());
} catch (Exception ex) { } catch (Exception ex) {
LOG.warn("Failed to retrieve pulse log from the pod", ex); LOG.warn("Failed to retrieve pulse log from the pod", ex);

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo; package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo;
import android.text.TextUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -7,12 +9,12 @@ import java.util.List;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
public class PodInfoOlderHighFlashLogDump extends PodInfo { public class PodInfoOlderPulseLog extends PodInfo {
private static final int MINIMUM_MESSAGE_LENGTH = 3; private static final int MINIMUM_MESSAGE_LENGTH = 3;
private final ArrayList<byte[]> dwords; private final ArrayList<byte[]> dwords;
public PodInfoOlderHighFlashLogDump(byte[] encodedData) { public PodInfoOlderPulseLog(byte[] encodedData) {
super(encodedData); super(encodedData);
if (encodedData.length < MINIMUM_MESSAGE_LENGTH) { if (encodedData.length < MINIMUM_MESSAGE_LENGTH) {
@ -30,7 +32,7 @@ public class PodInfoOlderHighFlashLogDump extends PodInfo {
@Override @Override
public PodInfoType getType() { public PodInfoType getType() {
return PodInfoType.OLDER_HIGH_FLASH_LOG_DUMP; return PodInfoType.OLDER_PULSE_LOG;
} }
public List<byte[]> getDwords() { public List<byte[]> getDwords() {
@ -39,8 +41,16 @@ public class PodInfoOlderHighFlashLogDump extends PodInfo {
@Override @Override
public String toString() { public String toString() {
return "PodInfoOlderHighFlashLogDump{" + String out = "PodInfoOlderPulseLog{" +
"dwords=" + dwords + "dwords=[";
'}';
List<String> hexDwords = new ArrayList<>();
for (byte[] dword : dwords) {
hexDwords.add(ByteUtil.shortHexStringWithoutSpaces(dword));
}
out += TextUtils.join(", ", hexDwords);
out += "]}";
return out;
} }
} }

View file

@ -9,14 +9,14 @@ import java.util.List;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
public class PodInfoRecentHighFlashLogDump extends PodInfo { public class PodInfoRecentPulseLog extends PodInfo {
private static final int MINIMUM_MESSAGE_LENGTH = 3; private static final int MINIMUM_MESSAGE_LENGTH = 3;
private final ArrayList<byte[]> dwords; private final ArrayList<byte[]> dwords;
private final int lastEntryIndex; private final int lastEntryIndex;
public PodInfoRecentHighFlashLogDump(byte[] encodedData, int bodyLength) { public PodInfoRecentPulseLog(byte[] encodedData, int bodyLength) {
super(encodedData); super(encodedData);
if (encodedData.length < MINIMUM_MESSAGE_LENGTH) { if (encodedData.length < MINIMUM_MESSAGE_LENGTH) {
@ -36,7 +36,7 @@ public class PodInfoRecentHighFlashLogDump extends PodInfo {
@Override @Override
public PodInfoType getType() { public PodInfoType getType() {
return PodInfoType.RECENT_HIGH_FLASH_LOG_DUMP; return PodInfoType.RECENT_PULSE_LOG;
} }
public List<byte[]> getDwords() { public List<byte[]> getDwords() {
@ -49,12 +49,13 @@ public class PodInfoRecentHighFlashLogDump extends PodInfo {
@Override @Override
public String toString() { public String toString() {
String out = "PodInfoRecentHighFlashLogDump{" + String out = "PodInfoRecentPulseLog{" +
"lastEntryIndex=" + lastEntryIndex + "lastEntryIndex=" + lastEntryIndex +
",dwords=["; ",dwords=[";
List<String> hexDwords = new ArrayList<>(); List<String> hexDwords = new ArrayList<>();
for (byte[] dword : dwords) { for (byte[] dword : dwords) {
hexDwords.add(ByteUtil.shortHexString(dword)); hexDwords.add(ByteUtil.shortHexStringWithoutSpaces(dword));
} }
out += TextUtils.join(", ", hexDwords); out += TextUtils.join(", ", hexDwords);
out += "]}"; out += "]}";

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair; import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
public interface OmnipodCommunicationManagerInterface { public interface OmnipodCommunicationManagerInterface {
@ -74,5 +74,5 @@ public interface OmnipodCommunicationManagerInterface {
void setPumpStatus(OmnipodPumpStatus pumpStatusLocal); void setPumpStatus(OmnipodPumpStatus pumpStatusLocal);
PodInfoRecentHighFlashLogDump readPulseLog(); PodInfoRecentPulseLog readPulseLog();
} }

View file

@ -6,8 +6,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.pod
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultAndInitializationTime; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultAndInitializationTime;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoLowFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoLowFlashLogDump;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoOlderHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoOlderPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoTestValues; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoTestValues;
public enum PodInfoType { public enum PodInfoType {
@ -18,8 +18,8 @@ public enum PodInfoType {
FAULT_AND_INITIALIZATION_TIME((byte) 0x05), FAULT_AND_INITIALIZATION_TIME((byte) 0x05),
HARDCODED_TEST_VALUES((byte) 0x06), HARDCODED_TEST_VALUES((byte) 0x06),
LOW_FLASH_DUMP_LOG((byte) 0x46), // Starting at $4000 LOW_FLASH_DUMP_LOG((byte) 0x46), // Starting at $4000
RECENT_HIGH_FLASH_LOG_DUMP((byte) 0x50), // Starting at $4200 RECENT_PULSE_LOG((byte) 0x50), // Starting at $4200
OLDER_HIGH_FLASH_LOG_DUMP((byte) 0x51); // Starting at $4200 but dumps entries before the last 50 OLDER_PULSE_LOG((byte) 0x51); // Starting at $4200 but dumps entries before the last 50
private final byte value; private final byte value;
@ -58,10 +58,10 @@ public enum PodInfoType {
return new PodInfoTestValues(encodedData); return new PodInfoTestValues(encodedData);
case LOW_FLASH_DUMP_LOG: case LOW_FLASH_DUMP_LOG:
return new PodInfoLowFlashLogDump(encodedData); return new PodInfoLowFlashLogDump(encodedData);
case RECENT_HIGH_FLASH_LOG_DUMP: case RECENT_PULSE_LOG:
return new PodInfoRecentHighFlashLogDump(encodedData, bodyLength); return new PodInfoRecentPulseLog(encodedData, bodyLength);
case OLDER_HIGH_FLASH_LOG_DUMP: case OLDER_PULSE_LOG:
return new PodInfoOlderHighFlashLogDump(encodedData); return new PodInfoOlderPulseLog(encodedData);
default: default:
throw new IllegalArgumentException("Cannot decode " + this.name()); throw new IllegalArgumentException("Cannot decode " + this.name());
} }

View file

@ -35,7 +35,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunication
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult; import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType;
@ -443,8 +443,8 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
return new PumpEnactResult().success(true).enacted(true); return new PumpEnactResult().success(true).enacted(true);
} }
public PodInfoRecentHighFlashLogDump readPulseLog() { public PodInfoRecentPulseLog readPulseLog() {
PodInfoResponse response = delegate.getPodInfo(PodInfoType.RECENT_HIGH_FLASH_LOG_DUMP); PodInfoResponse response = delegate.getPodInfo(PodInfoType.RECENT_PULSE_LOG);
return response.getPodInfo(); return response.getPodInfo();
} }

View file

@ -11,7 +11,7 @@ import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair; import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentHighFlashLogDump; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
@ -118,7 +118,7 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana
} }
@Override @Override
public PodInfoRecentHighFlashLogDump readPulseLog() { public PodInfoRecentPulseLog readPulseLog() {
return null; return null;
} }

View file

@ -1,5 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo; package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo;
public class PodInfoOlderHighFlashLogDumpTest { public class PodInfoOlderPulseLogTest {
// TODO // TODO
} }

View file

@ -1,16 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import static org.junit.Assert.assertEquals;
public class PodInfoRecentHighFlashLogDumpTest {
@Test
public void testDecoding() {
PodInfoRecentHighFlashLogDump podInfoRecentHighFlashLogDump = new PodInfoRecentHighFlashLogDump(ByteUtil.fromHexString("3d313b004030350045303a00483033004d313a005031310054313f00583038805d302d806030368001313b800c3033801130388014313480193138801c313280213039802431360029313d002c31390031303f0034313900393140003c31390041313e00443137004905723a80087335800d733a801073358015733a80187235801d7338802073338025733a00287235002d723b003072360035703b00383134"), 160);
assertEquals(39, podInfoRecentHighFlashLogDump.getDwords().size());
}
}

View file

@ -0,0 +1,16 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import static org.junit.Assert.assertEquals;
public class PodInfoRecentPulseLogTest {
@Test
public void testDecoding() {
PodInfoRecentPulseLog podInfoRecentPulseLog = new PodInfoRecentPulseLog(ByteUtil.fromHexString("3d313b004030350045303a00483033004d313a005031310054313f00583038805d302d806030368001313b800c3033801130388014313480193138801c313280213039802431360029313d002c31390031303f0034313900393140003c31390041313e00443137004905723a80087335800d733a801073358015733a80187235801d7338802073338025733a00287235002d723b003072360035703b00383134"), 160);
assertEquals(39, podInfoRecentPulseLog.getDwords().size());
}
}