|
|
@ -1,33 +1,33 @@
|
|
|
|
package info.nightscout.androidaps.plugins.pump.danaRS.services;
|
|
|
|
package info.nightscout.androidaps.plugins.pump.danaRS.services;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.Service;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Binder;
|
|
|
|
import android.os.Binder;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.SystemClock;
|
|
|
|
import android.os.SystemClock;
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import dagger.android.DaggerService;
|
|
|
|
import info.nightscout.androidaps.Constants;
|
|
|
|
import info.nightscout.androidaps.Constants;
|
|
|
|
import info.nightscout.androidaps.MainApp;
|
|
|
|
import info.nightscout.androidaps.MainApp;
|
|
|
|
import info.nightscout.androidaps.R;
|
|
|
|
import info.nightscout.androidaps.R;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.activities.ErrorHelperActivity;
|
|
|
|
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.dialogs.BolusProgressDialog;
|
|
|
|
import info.nightscout.androidaps.events.EventAppExit;
|
|
|
|
import info.nightscout.androidaps.events.EventAppExit;
|
|
|
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
|
|
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
|
|
|
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
|
|
|
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
|
|
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|
|
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|
|
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
|
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
|
|
import info.nightscout.androidaps.logging.L;
|
|
|
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
|
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
|
|
import info.nightscout.androidaps.logging.LTag;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
|
|
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
|
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
|
|
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.activities.ErrorHelperActivity;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
|
|
@ -80,16 +80,25 @@ import info.nightscout.androidaps.queue.Callback;
|
|
|
|
import info.nightscout.androidaps.queue.commands.Command;
|
|
|
|
import info.nightscout.androidaps.queue.commands.Command;
|
|
|
|
import info.nightscout.androidaps.utils.DateUtil;
|
|
|
|
import info.nightscout.androidaps.utils.DateUtil;
|
|
|
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
|
|
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
|
|
|
import info.nightscout.androidaps.utils.SP;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.utils.T;
|
|
|
|
import info.nightscout.androidaps.utils.T;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
|
|
|
|
|
|
public class DanaRSService extends Service {
|
|
|
|
public class DanaRSService extends DaggerService {
|
|
|
|
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
|
|
|
@Inject AAPSLogger aapsLogger;
|
|
|
|
|
|
|
|
@Inject RxBusWrapper rxBus;
|
|
|
|
|
|
|
|
@Inject SP sp;
|
|
|
|
|
|
|
|
@Inject ResourceHelper resourceHelper;
|
|
|
|
|
|
|
|
@Inject ProfileFunction profileFunction;
|
|
|
|
|
|
|
|
@Inject MainApp mainApp;
|
|
|
|
|
|
|
|
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
|
|
|
|
|
|
|
@Inject DanaRSPlugin danaRSPlugin;
|
|
|
|
|
|
|
|
|
|
|
|
private CompositeDisposable disposable = new CompositeDisposable();
|
|
|
|
private CompositeDisposable disposable = new CompositeDisposable();
|
|
|
|
|
|
|
|
|
|
|
|
private BLEComm bleComm = BLEComm.getInstance(this);
|
|
|
|
private BLEComm bleComm = new BLEComm(this);
|
|
|
|
|
|
|
|
|
|
|
|
private IBinder mBinder = new LocalBinder();
|
|
|
|
private IBinder mBinder = new LocalBinder();
|
|
|
|
|
|
|
|
|
|
|
@ -98,17 +107,14 @@ public class DanaRSService extends Service {
|
|
|
|
private long lastHistoryFetched = 0;
|
|
|
|
private long lastHistoryFetched = 0;
|
|
|
|
private long lastApproachingDailyLimit = 0;
|
|
|
|
private long lastApproachingDailyLimit = 0;
|
|
|
|
|
|
|
|
|
|
|
|
public DanaRSService() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
|
|
|
super.onCreate();
|
|
|
|
disposable.add(RxBus.Companion.getINSTANCE()
|
|
|
|
disposable.add(rxBus
|
|
|
|
.toObservable(EventAppExit.class)
|
|
|
|
.toObservable(EventAppExit.class)
|
|
|
|
.observeOn(Schedulers.io())
|
|
|
|
.observeOn(Schedulers.io())
|
|
|
|
.subscribe(event -> {
|
|
|
|
.subscribe(event -> {
|
|
|
|
if (L.isEnabled(L.PUMP)) log.debug("EventAppExit received");
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "EventAppExit received");
|
|
|
|
stopSelf();
|
|
|
|
stopSelf();
|
|
|
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
|
|
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -140,6 +146,7 @@ public class DanaRSService extends Service {
|
|
|
|
bleComm.disconnect(from);
|
|
|
|
bleComm.disconnect(from);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public void sendMessage(DanaRS_Packet message) {
|
|
|
|
public void sendMessage(DanaRS_Packet message) {
|
|
|
|
bleComm.sendMessage(message);
|
|
|
|
bleComm.sendMessage(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -147,29 +154,29 @@ public class DanaRSService extends Service {
|
|
|
|
public void getPumpStatus() {
|
|
|
|
public void getPumpStatus() {
|
|
|
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
|
|
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus)));
|
|
|
|
|
|
|
|
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information());
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
|
|
|
|
|
|
|
|
danaRPump.lastConnection = System.currentTimeMillis();
|
|
|
|
danaRPump.lastConnection = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
|
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
|
|
|
Profile profile = profileFunction.getProfile();
|
|
|
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
|
|
|
PumpInterface pump = configBuilderPlugin.getActivePump();
|
|
|
|
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
|
|
|
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
|
|
|
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
|
|
|
if (!pump.isThisProfileSet(profile) && !configBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventProfileNeedsUpdate());
|
|
|
|
rxBus.send(new EventProfileNeedsUpdate());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
|
|
|
|
|
|
|
|
|
|
|
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
|
|
|
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
|
|
@ -177,13 +184,13 @@ public class DanaRSService extends Service {
|
|
|
|
// initial handshake was not successfull
|
|
|
|
// initial handshake was not successfull
|
|
|
|
// deinitialize pump
|
|
|
|
// deinitialize pump
|
|
|
|
danaRPump.lastConnection = 0;
|
|
|
|
danaRPump.lastConnection = 0;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventDanaRNewStatus());
|
|
|
|
rxBus.send(new EventDanaRNewStatus());
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventInitializationChanged());
|
|
|
|
rxBus.send(new EventInitializationChanged());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
long now = System.currentTimeMillis();
|
|
|
|
long now = System.currentTimeMillis();
|
|
|
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
|
|
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no
|
|
|
|
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_General_Get_Pump_Check()); // firmware
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
|
|
|
@ -195,24 +202,22 @@ public class DanaRSService extends Service {
|
|
|
|
danaRPump.lastSettingsRead = now;
|
|
|
|
danaRPump.lastSettingsRead = now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds");
|
|
|
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
|
|
|
|
|
|
|
if (Math.abs(timeDiff) > 3) {
|
|
|
|
if (Math.abs(timeDiff) > 3) {
|
|
|
|
if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
|
|
|
|
if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds - large difference");
|
|
|
|
log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
|
|
|
|
|
|
|
|
//If time-diff is very large, warn user until we can synchronize history readings properly
|
|
|
|
//If time-diff is very large, warn user until we can synchronize history readings properly
|
|
|
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
|
|
|
Intent i = new Intent(mainApp, ErrorHelperActivity.class);
|
|
|
|
i.putExtra("soundid", R.raw.error);
|
|
|
|
i.putExtra("soundid", R.raw.error);
|
|
|
|
i.putExtra("status", MainApp.gs(R.string.largetimediff));
|
|
|
|
i.putExtra("status", resourceHelper.gs(R.string.largetimediff));
|
|
|
|
i.putExtra("title", MainApp.gs(R.string.largetimedifftitle));
|
|
|
|
i.putExtra("title", resourceHelper.gs(R.string.largetimedifftitle));
|
|
|
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
MainApp.instance().startActivity(i);
|
|
|
|
mainApp.startActivity(i);
|
|
|
|
|
|
|
|
|
|
|
|
//deinitialize pump
|
|
|
|
//deinitialize pump
|
|
|
|
danaRPump.lastConnection = 0;
|
|
|
|
danaRPump.lastConnection = 0;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventDanaRNewStatus());
|
|
|
|
rxBus.send(new EventDanaRNewStatus());
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventInitializationChanged());
|
|
|
|
rxBus.send(new EventInitializationChanged());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (danaRPump.protocol >= 6) {
|
|
|
|
if (danaRPump.protocol >= 6) {
|
|
|
@ -224,36 +229,33 @@ public class DanaRSService extends Service {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds");
|
|
|
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
|
|
|
|
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventDanaRNewStatus());
|
|
|
|
rxBus.send(new EventDanaRNewStatus());
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventInitializationChanged());
|
|
|
|
rxBus.send(new EventInitializationChanged());
|
|
|
|
//NSUpload.uploadDeviceStatus();
|
|
|
|
//NSUpload.uploadDeviceStatus();
|
|
|
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
|
|
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
|
|
|
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
|
|
|
|
|
|
|
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
|
|
|
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
|
|
|
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
|
|
|
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT);
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventNewNotification(reportFail));
|
|
|
|
rxBus.send(new EventNewNotification(reportFail));
|
|
|
|
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
|
|
|
NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
|
|
|
lastApproachingDailyLimit = System.currentTimeMillis();
|
|
|
|
lastApproachingDailyLimit = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("Unhandled exception", e);
|
|
|
|
aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Pump status loaded");
|
|
|
|
log.debug("Pump status loaded");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PumpEnactResult loadEvents() {
|
|
|
|
public PumpEnactResult loadEvents() {
|
|
|
|
|
|
|
|
|
|
|
|
if (!DanaRSPlugin.getPlugin().isInitialized()) {
|
|
|
|
if (!danaRSPlugin.isInitialized()) {
|
|
|
|
PumpEnactResult result = new PumpEnactResult().success(false);
|
|
|
|
PumpEnactResult result = new PumpEnactResult().success(false);
|
|
|
|
result.comment = "pump not initialized";
|
|
|
|
result.comment = "pump not initialized";
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
@ -264,12 +266,10 @@ public class DanaRSService extends Service {
|
|
|
|
DanaRS_Packet_APS_History_Events msg;
|
|
|
|
DanaRS_Packet_APS_History_Events msg;
|
|
|
|
if (lastHistoryFetched == 0) {
|
|
|
|
if (lastHistoryFetched == 0) {
|
|
|
|
msg = new DanaRS_Packet_APS_History_Events(0);
|
|
|
|
msg = new DanaRS_Packet_APS_History_Events(0);
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history");
|
|
|
|
log.debug("Loading complete event history");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
msg = new DanaRS_Packet_APS_History_Events(lastHistoryFetched);
|
|
|
|
msg = new DanaRS_Packet_APS_History_Events(lastHistoryFetched);
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
|
|
|
log.debug("Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bleComm.sendMessage(msg);
|
|
|
|
bleComm.sendMessage(msg);
|
|
|
|
while (!msg.done && bleComm.isConnected()) {
|
|
|
|
while (!msg.done && bleComm.isConnected()) {
|
|
|
@ -279,8 +279,7 @@ public class DanaRSService extends Service {
|
|
|
|
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - T.mins(1).msecs();
|
|
|
|
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - T.mins(1).msecs();
|
|
|
|
else
|
|
|
|
else
|
|
|
|
lastHistoryFetched = 0;
|
|
|
|
lastHistoryFetched = 0;
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded");
|
|
|
|
log.debug("Events loaded");
|
|
|
|
|
|
|
|
DanaRPump.getInstance().lastConnection = System.currentTimeMillis();
|
|
|
|
DanaRPump.getInstance().lastConnection = System.currentTimeMillis();
|
|
|
|
return new PumpEnactResult().success(true);
|
|
|
|
return new PumpEnactResult().success(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -297,9 +296,9 @@ public class DanaRSService extends Service {
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (BolusProgressDialog.stopPressed) return false;
|
|
|
|
if (BolusProgressDialog.stopPressed) return false;
|
|
|
|
|
|
|
|
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.startingbolus)));
|
|
|
|
bolusingTreatment = t;
|
|
|
|
bolusingTreatment = t;
|
|
|
|
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
|
|
|
|
final int preferencesSpeed = sp.getInt(R.string.key_danars_bolusspeed, 0);
|
|
|
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed);
|
|
|
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed);
|
|
|
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(insulin, t); // initialize static variables
|
|
|
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(insulin, t); // initialize static variables
|
|
|
|
DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables
|
|
|
|
DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables
|
|
|
@ -327,8 +326,7 @@ public class DanaRSService extends Service {
|
|
|
|
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm
|
|
|
|
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm
|
|
|
|
stop.stopped = true;
|
|
|
|
stop.stopped = true;
|
|
|
|
stop.forced = true;
|
|
|
|
stop.forced = true;
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "Communication stopped");
|
|
|
|
log.debug("Communication stopped");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -354,27 +352,26 @@ public class DanaRSService extends Service {
|
|
|
|
long expectedEnd = bolusStart + bolusDurationInMSec + 2000;
|
|
|
|
long expectedEnd = bolusStart + bolusDurationInMSec + 2000;
|
|
|
|
while (System.currentTimeMillis() < expectedEnd) {
|
|
|
|
while (System.currentTimeMillis() < expectedEnd) {
|
|
|
|
long waitTime = expectedEnd - System.currentTimeMillis();
|
|
|
|
long waitTime = expectedEnd - System.currentTimeMillis();
|
|
|
|
bolusingEvent.setStatus(String.format(MainApp.gs(R.string.waitingforestimatedbolusend), waitTime / 1000));
|
|
|
|
bolusingEvent.setStatus(String.format(resourceHelper.gs(R.string.waitingforestimatedbolusend), waitTime / 1000));
|
|
|
|
RxBus.Companion.getINSTANCE().send(bolusingEvent);
|
|
|
|
rxBus.send(bolusingEvent);
|
|
|
|
SystemClock.sleep(1000);
|
|
|
|
SystemClock.sleep(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// do not call loadEvents() directly, reconnection may be needed
|
|
|
|
// do not call loadEvents() directly, reconnection may be needed
|
|
|
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadEvents(new Callback() {
|
|
|
|
configBuilderPlugin.getCommandQueue().loadEvents(new Callback() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
// reread bolus status
|
|
|
|
// reread bolus status
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus
|
|
|
|
bolusingEvent.setPercent(100);
|
|
|
|
bolusingEvent.setPercent(100);
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return !start.failed;
|
|
|
|
return !start.failed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void bolusStop() {
|
|
|
|
public void bolusStop() {
|
|
|
|
if (L.isEnabled(L.PUMPCOMM))
|
|
|
|
aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + (bolusingTreatment == null ? "" : bolusingTreatment.insulin));
|
|
|
|
log.debug("bolusStop >>>>> @ " + (bolusingTreatment == null ? "" : bolusingTreatment.insulin));
|
|
|
|
|
|
|
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop();
|
|
|
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop();
|
|
|
|
stop.forced = true;
|
|
|
|
stop.forced = true;
|
|
|
|
if (isConnected()) {
|
|
|
|
if (isConnected()) {
|
|
|
@ -391,86 +388,86 @@ public class DanaRSService extends Service {
|
|
|
|
public boolean tempBasal(Integer percent, int durationInHours) {
|
|
|
|
public boolean tempBasal(Integer percent, int durationInHours) {
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
|
|
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
SystemClock.sleep(500);
|
|
|
|
SystemClock.sleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(percent, durationInHours));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(percent, durationInHours));
|
|
|
|
SystemClock.sleep(200);
|
|
|
|
SystemClock.sleep(200);
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean highTempBasal(Integer percent) {
|
|
|
|
public boolean highTempBasal(Integer percent) {
|
|
|
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
|
|
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
SystemClock.sleep(500);
|
|
|
|
SystemClock.sleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean tempBasalShortDuration(Integer percent, int durationInMinutes) {
|
|
|
|
public boolean tempBasalShortDuration(Integer percent, int durationInMinutes) {
|
|
|
|
if (durationInMinutes != 15 && durationInMinutes != 30) {
|
|
|
|
if (durationInMinutes != 15 && durationInMinutes != 30) {
|
|
|
|
log.error("Wrong duration param");
|
|
|
|
aapsLogger.error(LTag.PUMPCOMM, "Wrong duration param");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
|
|
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
SystemClock.sleep(500);
|
|
|
|
SystemClock.sleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent, durationInMinutes == 15, durationInMinutes == 30));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent, durationInMinutes == 15, durationInMinutes == 30));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean tempBasalStop() {
|
|
|
|
public boolean tempBasalStop() {
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean extendedBolus(Double insulin, int durationInHalfHours) {
|
|
|
|
public boolean extendedBolus(Double insulin, int durationInHalfHours) {
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(insulin, durationInHalfHours));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(insulin, durationInHalfHours));
|
|
|
|
SystemClock.sleep(200);
|
|
|
|
SystemClock.sleep(200);
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean extendedBolusStop() {
|
|
|
|
public boolean extendedBolusStop() {
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
|
|
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
|
|
|
loadEvents();
|
|
|
|
loadEvents();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean updateBasalsInPump(Profile profile) {
|
|
|
|
public boolean updateBasalsInPump(Profile profile) {
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
if (!isConnected()) return false;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
|
|
|
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
|
|
|
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
|
|
|
DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal);
|
|
|
|
DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal);
|
|
|
|
bleComm.sendMessage(msgSet);
|
|
|
|
bleComm.sendMessage(msgSet);
|
|
|
@ -478,7 +475,7 @@ public class DanaRSService extends Service {
|
|
|
|
bleComm.sendMessage(msgActivate);
|
|
|
|
bleComm.sendMessage(msgActivate);
|
|
|
|
DanaRPump.getInstance().lastSettingsRead = 0; // force read full settings
|
|
|
|
DanaRPump.getInstance().lastSettingsRead = 0; // force read full settings
|
|
|
|
getPumpStatus();
|
|
|
|
getPumpStatus();
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -554,7 +551,7 @@ public class DanaRSService extends Service {
|
|
|
|
long timeToWholeMinute = (60000 - time % 60000);
|
|
|
|
long timeToWholeMinute = (60000 - time % 60000);
|
|
|
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 300)
|
|
|
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 300)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
|
|
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
|
|
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
|
|
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|