0xE004 DanaRv2 message

This commit is contained in:
Milos Kozak 2017-05-29 16:45:09 +02:00
parent 9032deaaf3
commit dec627946d
4 changed files with 61 additions and 8 deletions

View file

@ -51,6 +51,15 @@ public class MessageBase {
AddParamByte((byte) (date.get(Calendar.MINUTE))); AddParamByte((byte) (date.get(Calendar.MINUTE)));
} }
public void AddParamDateTime(GregorianCalendar date) {
AddParamByte((byte) (date.get(Calendar.YEAR) - 1900 - 100));
AddParamByte((byte) (date.get(Calendar.MONTH) + 1));
AddParamByte((byte) (date.get(Calendar.DAY_OF_MONTH)));
AddParamByte((byte) (date.get(Calendar.HOUR)));
AddParamByte((byte) (date.get(Calendar.MINUTE)));
AddParamByte((byte) (date.get(Calendar.SECOND)));
}
public void AddParamDateTime(Date date) { public void AddParamDateTime(Date date) {
AddParamByte((byte) (date.getSeconds())); AddParamByte((byte) (date.getSeconds()));
AddParamByte((byte) (date.getMinutes())); AddParamByte((byte) (date.getMinutes()));

View file

@ -151,10 +151,10 @@ public class MessageOriginalNames {
messageNames.put(0x43F2, "CMD_HISTORY_DATEOVER_ALL"); messageNames.put(0x43F2, "CMD_HISTORY_DATEOVER_ALL");
messageNames.put(0x4300, "CMD_HISTORY_DATEOVER_DONE"); messageNames.put(0x4300, "CMD_HISTORY_DATEOVER_DONE");
messageNames.put(0xE001, "CMD_PUMP_APS"); messageNames.put(0xE001, "CMD_PUMPSTATUS_APS");
messageNames.put(0xE002, "CMD_PUMPSET_APS"); messageNames.put(0xE002, "CMD_PUMPSET_APSTEMP");
messageNames.put(0xE003, "CMD_HISTORY_APS"); messageNames.put(0xE003, "CMD_GET_HISTORY");
messageNames.put(0xE004, "CMD_PUMPSET_APSTEMP"); messageNames.put(0xE004, "CMD_SET_HISTORY_ENTRY");
} }

View file

@ -69,9 +69,10 @@ public class MessageHashTable_v2 {
put(new MsgHistoryNewDone()); // 0x42F1 CMD_HISTORY_NEW_DONE put(new MsgHistoryNewDone()); // 0x42F1 CMD_HISTORY_NEW_DONE
put(new MsgHistoryNew()); // 0x42F2 CMD_HISTORY_NEW put(new MsgHistoryNew()); // 0x42F2 CMD_HISTORY_NEW
put(new MsgCheckValue_v2()); // 0xF0F1 CMD_PUMP_CHECK_VALUE put(new MsgCheckValue_v2()); // 0xF0F1 CMD_PUMP_CHECK_VALUE
put(new MsgStatusAPS_v2()); // 0xE001 CMD_PUMP_APS put(new MsgStatusAPS_v2()); // 0xE001 CMD_PUMPSTATUS_APS
put(new MsgSetAPSTempBasalStart_v2()); // 0xE002 CMD_PUMPSET_APSTEMP put(new MsgSetAPSTempBasalStart_v2()); // 0xE002 CMD_PUMPSET_APSTEMP
put(new MsgHistoryEvents_v2()); // 0xE003 CMD_HISTORY_EVENTS put(new MsgHistoryEvents_v2()); // 0xE003 CMD_GET_HISTORY
put(new MsgSetHistoryEntry_v2()); // 0xE004 CMD_SET_HISTORY_ENTRY
} }
} }

View file

@ -0,0 +1,43 @@
package info.nightscout.androidaps.plugins.PumpDanaRv2.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.GregorianCalendar;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgSetHistoryEntry_v2 extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetHistoryEntry_v2.class);
public MsgSetHistoryEntry_v2() {
SetCommand(0xE004);
}
public MsgSetHistoryEntry_v2(int type, Date time, int param1, int param2) {
this();
AddParamByte((byte) type);
GregorianCalendar gtime = new GregorianCalendar();
gtime.setTimeInMillis(time.getTime());
AddParamDateTime(gtime);
AddParamInt(param1);
AddParamInt(param2);
if (Config.logDanaMessageDetail)
log.debug("Set history entry: type: " + type + " date: " + time.toString() + " param1: " + param1 + " param2: " + param2);
}
@Override
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set history entry result: " + result + " FAILED!!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Set history entry result: " + result);
}
}
}