Revert "more debugging output"

This reverts commit f1f8bae2d1.
This commit is contained in:
PoweRGbg 2018-06-13 09:49:45 +03:00
parent 90a3a66c30
commit 0f067ef3a7
4 changed files with 39 additions and 70 deletions

View file

@ -11,9 +11,25 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
*/
public class MsgGetUserOptions extends MessageBase {
private int backlightOnTimeSec;
private int beepAndAlarm;
private int buttonScrollOnOff;
private int cannulaVolume;
private int glucoseUnit;
private int lcdOnTimeSec;
private int lowReservoirRate;
private int refillRate;
private int selectableLanguage1;
private int selectableLanguage2;
private int selectableLanguage3;
private int selectableLanguage4;
private int selectableLanguage5;
private int selectedLanguage;
private int shutdownHour;
private int timeDisplayType;
private static Logger log = LoggerFactory.getLogger(MsgGetUserOptions.class);
private byte[] optionsInPump;
public MsgGetUserOptions() {
SetCommand(0x320B);
}
@ -21,9 +37,8 @@ public class MsgGetUserOptions extends MessageBase {
public void handleMessage(byte[] packet) {
DanaRPump pump = DanaRPump.getInstance();
byte[] bytes = getDataBytes(packet, 0, packet.length - 10);
this.optionsInPump = getDataBytes(packet, 0, packet.length - 10);
for(int pos=0; pos < packet.length; pos++) {
log.debug("[" + pos + "]" + packet[pos]);
for(int pos=0; pos < bytes.length; pos++) {
log.debug("[" + pos + "]" + bytes[pos]);
}
pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1; // 1 -> 24h 0 -> 12h
pump.buttonScrollOnOff = bytes[1] == (byte) 1 ? 1 : 0; // 1 -> ON, 0-> OFF
@ -54,7 +69,6 @@ public class MsgGetUserOptions extends MessageBase {
log.debug("Low reservoir: " + pump.lowReservoirRate);
// }
}
public static byte[] getDataBytes(byte[] bytes, int start, int len) {
if (bytes == null) {
return null;
@ -63,6 +77,4 @@ public class MsgGetUserOptions extends MessageBase {
System.arraycopy(bytes, start + 6, ret, 0, len);
return ret;
}
}

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.support.v4.internal.view.SupportMenu;
import info.nightscout.androidaps.Config;
@ -23,7 +22,7 @@ public class MsgSettingUserOptions extends MessageBase {
private int selectedLanguage;
private int shutdownHour;
private int timeDisplayType;
byte[] newOptions;
public boolean done;
public MsgSettingUserOptions(int timeDisplayType, int buttonScrollOnOff, int beepAndAlarm, int lcdOnTimeSec, int backlightOnTimeSec, int selectedLanguage, int glucoseUnit, int shutdownHour, int lowReservoirRate, int cannulaVolume, int refillRate) {
@ -49,19 +48,17 @@ public class MsgSettingUserOptions extends MessageBase {
this.lowReservoirRate = lowReservoirRate;
this.cannulaVolume = cannulaVolume;
this.refillRate = refillRate;
newOptions[0] = (byte) (timeDisplayType == 1 ? 0 : 1);
newOptions[1] = (byte) buttonScrollOnOff;
newOptions[2] = (byte) beepAndAlarm;
newOptions[3] = (byte) lcdOnTimeSec;
newOptions[4] = (byte) backlightOnTimeSec;
newOptions[5] = (byte) selectedLanguage;
newOptions[8] = (byte) glucoseUnit;
newOptions[9] = (byte) shutdownHour;
newOptions[27] = (byte) lowReservoirRate;
// need to organize here
// glucoseunit is at pos 8 and lowReservoirRate is at pos 27
// 6 extended bolus on/off
// 10 missed bolus
AddParamByte((byte) timeDisplayType);
AddParamByte((byte) buttonScrollOnOff);
AddParamByte((byte) beepAndAlarm);
AddParamByte((byte) lcdOnTimeSec);
AddParamByte((byte) backlightOnTimeSec);
AddParamByte((byte) selectedLanguage);
AddParamByte((byte) glucoseUnit);
AddParamByte((byte) shutdownHour);
AddParamByte((byte) lowReservoirRate);
}
private static Logger log = LoggerFactory.getLogger(MsgSettingUserOptions.class);
@ -72,7 +69,6 @@ public class MsgSettingUserOptions extends MessageBase {
public void handleMessage(byte[] bytes) {
log.debug("Entering handleMessage ");
newOptions = new byte[]{bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[15], bytes[16], bytes[17], bytes[18], bytes[19], bytes[20], bytes[21], bytes[22], bytes[23], bytes[24], bytes[25], bytes[26], bytes[27], bytes[28], bytes[29], bytes[30], bytes[31], bytes[32]};
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
@ -83,49 +79,4 @@ public class MsgSettingUserOptions extends MessageBase {
}
}
public byte[] getCommByte(int cmd, byte[] data) {
int len = (data == null ? 0 : data.length) + 3;
byte[] btSendData = new byte[(len + 7)];
byte[] csr = new byte[2];
byte[] crcData = new byte[len];
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
btSendData[0] = (byte) 126;
btSendData[1] = (byte) 126;
btSendData[2] = (byte) len;
btSendData[3] = (byte) 241;
btSendData[4] = (byte) ((cmd >> 8) & 255);
btSendData[5] = (byte) (cmd & 255);
if (len > 3) {
System.arraycopy(data, 0, btSendData, 6, len - 3);
}
System.arraycopy(btSendData, 3, crcData, 0, len);
int crc_result = GenerateCrc(crcData, len) & SupportMenu.USER_MASK;
csr[0] = (byte) (crc_result & 255);
csr[1] = (byte) ((crc_result >> 8) & 255);
btSendData[len + 3] = csr[1];
btSendData[len + 4] = csr[0];
btSendData[len + 5] = (byte) 46;
btSendData[len + 6] = (byte) 46;
return btSendData;
}
public static int GenerateCrc(byte[] send_buf, int len) {
int crc = 0;
for (int i = 0; i < len; i++) {
crc = Crc16(send_buf[i], crc);
}
return crc;
}
static int Crc16(byte byte1, int crc) {
int li_crc = ((((crc >> 8) | (crc << 8)) & SupportMenu.USER_MASK) ^ (byte1 & 255)) & SupportMenu.USER_MASK;
li_crc = (li_crc ^ ((li_crc & 255) >> 4)) & SupportMenu.USER_MASK;
li_crc = (li_crc ^ ((li_crc << 8) << 4)) & SupportMenu.USER_MASK;
return (li_crc ^ (((li_crc & 255) << 4) << 1)) & SupportMenu.USER_MASK;
}
}

View file

@ -392,6 +392,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@Override
public PumpEnactResult setUserOptions() {
DanaRv2ExecutionService service = new DanaRv2ExecutionService();
log.debug("MsgSetUserOptions executed!");
return service.setUserOptions();
}

View file

@ -201,7 +201,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(new MsgSettingGlucose());
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
//added by Roumen for testing and
//added by Roumen for testing
mSerialIOThread.sendMessage(new MsgGetUserOptions());
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
@ -478,7 +478,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult setUserOptions() {
if (!isConnected()) {
return new PumpEnactResult().success(false);
log.debug("MsgSetUserOptions - service is not connected");
// return new PumpEnactResult().success(false);
connect();
}
SystemClock.sleep(300);
DanaRPump pump = DanaRPump.getInstance();
@ -499,11 +501,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public PumpEnactResult getUserOptions() {
if (!isConnected()) {
return new PumpEnactResult().success(false);
log.debug("MsgGetUserOptions fails - disconnected!");
connect();
// return new PumpEnactResult().success(false);
}
MsgGetUserOptions msg = new MsgGetUserOptions();
mSerialIOThread.sendMessage(msg);
// mSerialIOThread.sendMessage(msg); // == null
mDanaRPump.lastConnection = System.currentTimeMillis();
log.debug("MsgGetUserOptions executed!");
return new PumpEnactResult().success(true);
}
}