RS history OK
This commit is contained in:
parent
fdc3c49a2a
commit
1eeb1c6f7a
|
@ -42,6 +42,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionServi
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
@ -122,6 +123,7 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
statusView.setVisibility(View.GONE);
|
statusView.setVisibility(View.GONE);
|
||||||
|
|
||||||
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP);
|
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP);
|
||||||
|
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginBase.PUMP);
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
|
|
||||||
|
@ -132,8 +134,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, getString(R.string.danar_history_carbohydrates)));
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, getString(R.string.danar_history_carbohydrates)));
|
||||||
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, getString(R.string.danar_history_dailyinsulin)));
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, getString(R.string.danar_history_dailyinsulin)));
|
||||||
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, getString(R.string.danar_history_glucose)));
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, getString(R.string.danar_history_glucose)));
|
||||||
if (!isKorean) {
|
if (!isKorean && !isRS) {
|
||||||
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, getString(R.string.danar_history_errors)));
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, getString(R.string.danar_history_errors)));
|
||||||
|
}
|
||||||
|
if (isRS)
|
||||||
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_PRIME, getString(R.string.danar_history_prime)));
|
||||||
|
if (!isKorean) {
|
||||||
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, getString(R.string.danar_history_refill)));
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, getString(R.string.danar_history_refill)));
|
||||||
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, getString(R.string.danar_history_syspend)));
|
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, getString(R.string.danar_history_syspend)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,6 +256,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadHistory(byte type) {
|
public boolean loadHistory(byte type) {
|
||||||
|
connectIfNotConnected("loadHistory");
|
||||||
return danaRSService.loadHistory(type);
|
return danaRSService.loadHistory(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,223 +60,6 @@ public class DanaRS_Packet {
|
||||||
return "UNKNOWN_PACKET";
|
return "UNKNOWN_PACKET";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public static DanaRS_Packet parseResponse(byte[] data) {
|
|
||||||
DanaRS_Packet ret = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
int type = byteArrayToInt(getBytes(data, TYPE_START, 1));
|
|
||||||
int tOpCode = byteArrayToInt(getBytes(data, OPCODE_START, 1));
|
|
||||||
if (type == BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY) {
|
|
||||||
switch (tOpCode) {
|
|
||||||
// Notify
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE:
|
|
||||||
ret = new DanaRS_Packet_Notify_Delivery_Complete();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY:
|
|
||||||
ret = new DanaRS_Packet_Notify_Delivery_Rate_Display();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__ALARM:
|
|
||||||
ret = new DanaRS_Packet_Notify_Alarm();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM:
|
|
||||||
ret = new DanaRS_Packet_Notify_Missed_Bolus_Alarm();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (type == BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE) {
|
|
||||||
switch (tOpCode) {
|
|
||||||
// Init
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION:
|
|
||||||
ret = new DanaRS_Packet_General_Initial_Screen_Information();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS:
|
|
||||||
ret = new DanaRS_Packet_General_Delivery_Status();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD:
|
|
||||||
ret = new DanaRS_Packet_General_Get_Password();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Review
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG:
|
|
||||||
ret = new DanaRS_Packet_Review_Bolus_Avg();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS:
|
|
||||||
ret = new DanaRS_Packet_History_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY:
|
|
||||||
ret = new DanaRS_Packet_History_Daily();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME:
|
|
||||||
ret = new DanaRS_Packet_History_Prime();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL:
|
|
||||||
ret = new DanaRS_Packet_History_Refill();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE:
|
|
||||||
ret = new DanaRS_Packet_History_Blood_Glucose();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE:
|
|
||||||
ret = new DanaRS_Packet_History_Carbohydrate();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY:
|
|
||||||
ret = new DanaRS_Packet_History_Temporary();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND:
|
|
||||||
ret = new DanaRS_Packet_History_Suspend();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM:
|
|
||||||
ret = new DanaRS_Packet_History_Alarm();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL:
|
|
||||||
ret = new DanaRS_Packet_History_Basal();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY:
|
|
||||||
ret = new DanaRS_Packet_History_All_History();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION:
|
|
||||||
ret = new DanaRS_Packet_General_Get_Shipping_Information();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK:
|
|
||||||
ret = new DanaRS_Packet_General_Get_Pump_Check();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG:
|
|
||||||
ret = new DanaRS_Packet_General_Get_User_Time_Change_Flag();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR:
|
|
||||||
ret = new DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION:
|
|
||||||
ret = new DanaRS_Packet_General_Get_More_Information();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE:
|
|
||||||
ret = new DanaRS_Packet_General_Set_History_Upload_Mode();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL:
|
|
||||||
ret = new DanaRS_Packet_General_Get_Today_Delivery_Total();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Bolus
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Step_Bolus_Information();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Extended_Bolus_State();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Extended_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Dual_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Extended_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Dual_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Calculation_Information();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Initial_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Initial_Bolus();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_CIR_CF_Array();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_CIR_CF_Array();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Get_Bolus_Option();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION:
|
|
||||||
ret = new DanaRS_Packet_Bolus_Set_Bolus_Option();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Basal
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Temporary_Basal();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE:
|
|
||||||
ret = new DanaRS_Packet_Basal_Get_Temporary_Basal_State();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER:
|
|
||||||
ret = new DanaRS_Packet_Basal_Get_Profile_Number();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Profile_Number();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE:
|
|
||||||
ret = new DanaRS_Packet_Basal_Get_Profile_Basal_Rate();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE:
|
|
||||||
ret = new DanaRS_Packet_Basal_Get_Basal_Rate();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_BASAL_RATE:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Basal_Rate();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Suspend_On();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF:
|
|
||||||
ret = new DanaRS_Packet_Basal_Set_Suspend_Off();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Option
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME:
|
|
||||||
ret = new DanaRS_Packet_Option_Get_Pump_Time();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME:
|
|
||||||
ret = new DanaRS_Packet_Option_Set_Pump_Time();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION:
|
|
||||||
ret = new DanaRS_Packet_Option_Get_User_Option();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION:
|
|
||||||
ret = new DanaRS_Packet_Option_Set_User_Option();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Etc
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE:
|
|
||||||
ret = new DanaRS_Packet_Etc_Set_History_Save();
|
|
||||||
break;
|
|
||||||
case BleCommandUtil.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION:
|
|
||||||
ret = new DanaRS_Packet_Etc_Keep_Connection();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
ret = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
protected static byte[] getBytes(byte[] data, int srcStart, int srcLength) {
|
protected static byte[] getBytes(byte[] data, int srcStart, int srcLength) {
|
||||||
try {
|
try {
|
||||||
byte[] ret = new byte[srcLength];
|
byte[] ret = new byte[srcLength];
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||||
|
|
||||||
|
import com.cozmo.danar.util.BleCommandUtil;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -7,7 +9,11 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
|
public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
|
||||||
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_History_.class);
|
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_History_.class);
|
||||||
|
@ -19,14 +25,11 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
|
||||||
private int min = 0;
|
private int min = 0;
|
||||||
private int sec = 0;
|
private int sec = 0;
|
||||||
|
|
||||||
public static long lastEventTimeLoaded = 0;
|
|
||||||
|
|
||||||
public boolean done;
|
public boolean done;
|
||||||
public int totalCount;
|
public int totalCount;
|
||||||
|
|
||||||
public DanaRS_Packet_History_() {
|
public DanaRS_Packet_History_() {
|
||||||
super();
|
super();
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS;
|
|
||||||
done = false;
|
done = false;
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -80,46 +83,148 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet {
|
||||||
totalCount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
totalCount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||||
log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount);
|
log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount);
|
||||||
} else {
|
} else {
|
||||||
int dataIndex = DATA_START;
|
int recordCode = byteArrayToInt(getBytes(data, DATA_START, 1));
|
||||||
int dataSize = 1;
|
int historyYear = byteArrayToInt(getBytes(data, DATA_START + 1, 1));
|
||||||
int historyType = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
int historyMonth = byteArrayToInt(getBytes(data, DATA_START +2 , 1));
|
||||||
|
int historyDay = byteArrayToInt(getBytes(data, DATA_START + 3, 1));
|
||||||
|
int historyHour = byteArrayToInt(getBytes(data, DATA_START + 4, 1));
|
||||||
|
double dailyBasal = (((data[DATA_START + 4] & 0xFF) << 8) + (data[DATA_START + 5] & 0xFF)) * 0.01d;
|
||||||
|
int historyMinute = byteArrayToInt(getBytes(data, DATA_START + 5, 1));
|
||||||
|
int historySecond = byteArrayToInt(getBytes(data, DATA_START + 6, 1));
|
||||||
|
byte paramByte7 = (byte) historySecond;
|
||||||
|
double dailyBolus = (((data[DATA_START + 6] & 0xFF) << 8) + (data[DATA_START + 7] & 0xFF)) * 0.01d;
|
||||||
|
|
||||||
dataIndex += dataSize;
|
Date date = new Date(100 + historyYear, historyMonth - 1, historyDay);
|
||||||
dataSize = 1;
|
Date datetime = new Date(100 + historyYear, historyMonth - 1, historyDay, historyHour, historyMinute);
|
||||||
int historyYear = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
Date datetimewihtsec = new Date(100 + historyYear, historyMonth - 1, historyDay, historyHour, historyMinute, historySecond);
|
||||||
|
|
||||||
dataIndex += dataSize;
|
int historyCode = byteArrayToInt(getBytes(data, DATA_START + 7, 1));
|
||||||
dataSize = 1;
|
byte paramByte8 = (byte) historyCode;
|
||||||
int historyMonth = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
|
||||||
|
|
||||||
dataIndex += dataSize;
|
int value = ((data[DATA_START + 8] & 0xFF) << 8) + (data[DATA_START + 9] & 0xFF);
|
||||||
dataSize = 1;
|
|
||||||
int historyDay = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
|
||||||
|
|
||||||
dataIndex += dataSize;
|
log.debug("History packet: " + recordCode + " Date: " + datetimewihtsec.toLocaleString() + " Code: " + historyCode + " Value: " + value);
|
||||||
dataSize = 1;
|
|
||||||
int historyHour = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
|
||||||
|
|
||||||
dataIndex += dataSize;
|
|
||||||
dataSize = 1;
|
|
||||||
int historyMinute = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
|
||||||
|
|
||||||
dataIndex += dataSize;
|
EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
|
||||||
dataSize = 1;
|
DanaRHistoryRecord danaRHistoryRecord = new DanaRHistoryRecord();
|
||||||
int historySecond = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
|
||||||
|
|
||||||
Date date = new Date(100 + historyYear, historyMonth - 1, historyDay, historyHour, historyMinute, historySecond);
|
danaRHistoryRecord.setBytes(data);
|
||||||
lastEventTimeLoaded = date.getTime();
|
// danaRHistoryRecord.recordCode is different from DanaR codes
|
||||||
|
// set in switch for every type
|
||||||
|
|
||||||
dataIndex += dataSize;
|
String messageType = "";
|
||||||
dataSize = 1;
|
|
||||||
int historyCode = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
|
||||||
|
|
||||||
dataIndex += dataSize;
|
switch (recordCode) {
|
||||||
dataSize = 2;
|
case 0x02:
|
||||||
int historyValue = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_BOLUS;
|
||||||
|
danaRHistoryRecord.recordDate = datetime.getTime();
|
||||||
|
switch (0xF0 & paramByte8) {
|
||||||
|
case 0xA0:
|
||||||
|
danaRHistoryRecord.bolusType = "DS";
|
||||||
|
messageType += "DS bolus";
|
||||||
|
break;
|
||||||
|
case 0xC0:
|
||||||
|
danaRHistoryRecord.bolusType = "E";
|
||||||
|
messageType += "E bolus";
|
||||||
|
break;
|
||||||
|
case 0x80:
|
||||||
|
danaRHistoryRecord.bolusType = "S";
|
||||||
|
messageType += "S bolus";
|
||||||
|
break;
|
||||||
|
case 0x90:
|
||||||
|
danaRHistoryRecord.bolusType = "DE";
|
||||||
|
messageType += "DE bolus";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
danaRHistoryRecord.bolusType = "None";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
danaRHistoryRecord.recordDuration = ((int) paramByte8 & 0x0F) * 60 + (int) paramByte7;
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_DAILY;
|
||||||
|
messageType += "dailyinsulin";
|
||||||
|
danaRHistoryRecord.recordDate = date.getTime();
|
||||||
|
danaRHistoryRecord.recordDailyBasal = dailyBasal;
|
||||||
|
danaRHistoryRecord.recordDailyBolus = dailyBolus;
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_PRIME;
|
||||||
|
messageType += "prime";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x05:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_REFILL;
|
||||||
|
messageType += "refill";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x0b:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_BASALHOUR;
|
||||||
|
messageType += "basal hour";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x99: ///// ????????? don't know the right code
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_TEMP_BASAL;
|
||||||
|
messageType += "tb";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_GLUCOSE;
|
||||||
|
messageType += "glucose";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
danaRHistoryRecord.recordValue = value;
|
||||||
|
break;
|
||||||
|
case 0x07:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_CARBO;
|
||||||
|
messageType += "carbo";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
danaRHistoryRecord.recordValue = value;
|
||||||
|
break;
|
||||||
|
case 0x0a:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_ALARM;
|
||||||
|
messageType += "alarm";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
String strAlarm = "None";
|
||||||
|
switch ((int) paramByte8) {
|
||||||
|
case 67:
|
||||||
|
strAlarm = "Check";
|
||||||
|
break;
|
||||||
|
case 79:
|
||||||
|
strAlarm = "Occlusion";
|
||||||
|
break;
|
||||||
|
case 66:
|
||||||
|
strAlarm = "Low Battery";
|
||||||
|
break;
|
||||||
|
case 83:
|
||||||
|
strAlarm = "Shutdown";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
danaRHistoryRecord.recordAlarm = strAlarm;
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x09:
|
||||||
|
danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_SUSPEND;
|
||||||
|
messageType += "suspend";
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
|
String strRecordValue = "Off";
|
||||||
|
if ((int) paramByte8 == 79)
|
||||||
|
strRecordValue = "On";
|
||||||
|
danaRHistoryRecord.stringRecordValue = strRecordValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord);
|
||||||
|
|
||||||
|
ev.message = DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate);
|
||||||
|
ev.message += " " + messageType;
|
||||||
|
MainApp.bus().post(ev);
|
||||||
|
|
||||||
log.debug("History packet: " + historyType + " Date: " + date.toLocaleString() + " Code: " + historyCode + " Value: " + historyValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.activities.PairingHelperActivity;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.activities.PairingHelperActivity;
|
||||||
|
@ -67,8 +68,17 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Bolus_Se
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Get_Pump_Check;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Get_Pump_Check;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Get_Shipping_Information;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Get_Shipping_Information;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Initial_Screen_Information;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Initial_Screen_Information;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_General_Set_History_Upload_Mode;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_All_History;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Alarm;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Basal;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Blood_Glucose;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Bolus;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Carbohydrate;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Daily;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Prime;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Refill;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_History_Suspend;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Notify_Delivery_Complete;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Notify_Delivery_Complete;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Notify_Delivery_Rate_Display;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Notify_Delivery_Rate_Display;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Get_Pump_Time;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Get_Pump_Time;
|
||||||
|
@ -181,17 +191,6 @@ public class DanaRSService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadEvents() {
|
public boolean loadEvents() {
|
||||||
if (!isConnected())
|
|
||||||
return false;
|
|
||||||
SystemClock.sleep(300);
|
|
||||||
DanaRS_Packet_History_All_History msg;
|
|
||||||
msg = new DanaRS_Packet_History_All_History(new Date(lastHistoryFetched));
|
|
||||||
sendMessage(msg);
|
|
||||||
while (!msg.done && isConnected()) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
}
|
|
||||||
SystemClock.sleep(200); // #### nefunguje
|
|
||||||
lastHistoryFetched = DanaRS_Packet_History_.lastEventTimeLoaded;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +317,48 @@ public class DanaRSService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadHistory(byte type) {
|
public boolean loadHistory(byte type) {
|
||||||
return false;
|
if (!isConnected()) return false;
|
||||||
|
DanaRS_Packet_History_ msg = null;
|
||||||
|
switch (type) {
|
||||||
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
|
msg = new DanaRS_Packet_History_Alarm();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_PRIME:
|
||||||
|
msg = new DanaRS_Packet_History_Prime();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
|
msg = new DanaRS_Packet_History_Basal();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_BOLUS:
|
||||||
|
msg = new DanaRS_Packet_History_Bolus();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
|
msg = new DanaRS_Packet_History_Carbohydrate();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
|
msg = new DanaRS_Packet_History_Daily();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
|
msg = new DanaRS_Packet_History_Blood_Glucose();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_REFILL:
|
||||||
|
msg = new DanaRS_Packet_History_Refill();
|
||||||
|
break;
|
||||||
|
case RecordTypes.RECORD_TYPE_SUSPEND:
|
||||||
|
msg = new DanaRS_Packet_History_Suspend();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (msg != null) {
|
||||||
|
sendMessage(new DanaRS_Packet_General_Set_History_Upload_Mode(1));
|
||||||
|
SystemClock.sleep(200);
|
||||||
|
sendMessage(msg);
|
||||||
|
while (!msg.done && isConnected()) {
|
||||||
|
SystemClock.sleep(100);
|
||||||
|
}
|
||||||
|
SystemClock.sleep(200);
|
||||||
|
sendMessage(new DanaRS_Packet_General_Set_History_Upload_Mode(0));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,6 +366,7 @@ public class DanaRSService extends Service {
|
||||||
public DanaRSService getServiceInstance() {
|
public DanaRSService getServiceInstance() {
|
||||||
return DanaRSService.this;
|
return DanaRSService.this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -726,5 +726,6 @@
|
||||||
<string name="key_wizard_include_trend_bg">wizard_include_trend_bg</string>
|
<string name="key_wizard_include_trend_bg">wizard_include_trend_bg</string>
|
||||||
<string name="key_wizard_include_bolus_iob">wizard_include_bolus_iob</string>
|
<string name="key_wizard_include_bolus_iob">wizard_include_bolus_iob</string>
|
||||||
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
||||||
|
<string name="danar_history_prime">Prime</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue