DanaRS time setting update for protocol #6
This commit is contained in:
parent
7176a8654b
commit
33d1d3e82d
1 changed files with 21 additions and 17 deletions
|
@ -181,6 +181,20 @@ public class DanaRSService extends Service {
|
||||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||||
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check()); // firmware
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option()); // isExtendedEnabled
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array());
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option()); // Getting user options
|
||||||
|
danaRPump.lastSettingsRead = now;
|
||||||
|
}
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
if (Math.abs(timeDiff) > 3) {
|
if (Math.abs(timeDiff) > 3) {
|
||||||
|
@ -201,9 +215,13 @@ public class DanaRSService extends Service {
|
||||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
if (danaRPump.protocol >= 6) {
|
||||||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date()));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
|
} else {
|
||||||
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
|
}
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||||
timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
|
@ -211,20 +229,6 @@ public class DanaRSService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
|
||||||
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check()); // firmware
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option()); // isExtendedEnabled
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array());
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option()); // Getting user options
|
|
||||||
danaRPump.lastSettingsRead = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadEvents();
|
loadEvents();
|
||||||
|
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
|
|
Loading…
Reference in a new issue