switch pumps properly
This commit is contained in:
parent
5ce8b998d9
commit
75cd9bccdc
|
@ -103,8 +103,10 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (event.isChanged(getResourceHelper(), R.string.key_danar_bt_name))
|
if (event.isChanged(getResourceHelper(), R.string.key_danar_bt_name)) {
|
||||||
danaRPump.setLastConnection(0);
|
danaRPump.setLastConnection(0);
|
||||||
|
danaRPump.setLastSettingsRead(0);
|
||||||
|
getCommandQueue().readStatus("DeviceChanged", null); }
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ class DanaRFragment : DaggerFragment() {
|
||||||
|
|
||||||
// GUI functions
|
// GUI functions
|
||||||
@Synchronized
|
@Synchronized
|
||||||
internal fun updateGUI() {
|
fun updateGUI() {
|
||||||
if (danar_dailyunits == null) return
|
if (danar_dailyunits == null) return
|
||||||
val pump = danaRPump
|
val pump = danaRPump
|
||||||
val plugin: PumpInterface = activePlugin.activePump
|
val plugin: PumpInterface = activePlugin.activePump
|
||||||
|
|
|
@ -166,9 +166,9 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventDanaRSDeviceChange.class)
|
.toObservable(EventDanaRSDeviceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> loadAddress(), fabricPrivacy::logException)
|
.subscribe(event -> changePump(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
loadAddress(); // load device name
|
changePump(); // load device name
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,10 +194,12 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void loadAddress() {
|
public void changePump() {
|
||||||
mDeviceAddress = sp.getString(R.string.key_danars_address, "");
|
mDeviceAddress = sp.getString(R.string.key_danars_address, "");
|
||||||
mDeviceName = sp.getString(R.string.key_danars_name, "");
|
mDeviceName = sp.getString(R.string.key_danars_name, "");
|
||||||
danaRPump.setLastConnection(0);
|
danaRPump.setLastConnection(0);
|
||||||
|
danaRPump.setLastSettingsRead(0);
|
||||||
|
getCommandQueue().readStatus("DeviceChanged", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -96,6 +96,9 @@ class BLEComm @Inject internal constructor(
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isConnected = false
|
||||||
|
v3Encryption = false
|
||||||
|
encryptedDataRead = false
|
||||||
isConnecting = true
|
isConnecting = true
|
||||||
val device = bluetoothAdapter?.getRemoteDevice(address)
|
val device = bluetoothAdapter?.getRemoteDevice(address)
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
|
@ -118,13 +121,14 @@ class BLEComm @Inject internal constructor(
|
||||||
fun disconnect(from: String) {
|
fun disconnect(from: String) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from")
|
||||||
|
|
||||||
if (!encryptedDataRead) {
|
if (!encryptedDataRead && v3Encryption) {
|
||||||
// there was no response from pump after started encryption
|
// there was no response from pump after started encryption
|
||||||
// assume pairing keys are invalid
|
// assume pairing keys are invalid
|
||||||
sp.remove(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName)
|
sp.remove(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName)
|
||||||
sp.remove(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName)
|
sp.remove(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName)
|
||||||
sp.remove(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName)
|
sp.remove(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName)
|
||||||
ToastUtils.showToastInUiThread(context, R.string.invalidpairing)
|
ToastUtils.showToastInUiThread(context, R.string.invalidpairing)
|
||||||
|
danaRSPlugin.changePump()
|
||||||
}
|
}
|
||||||
// cancel previous scheduled disconnection to prevent closing upcoming connection
|
// cancel previous scheduled disconnection to prevent closing upcoming connection
|
||||||
scheduledDisconnection?.cancel(false)
|
scheduledDisconnection?.cancel(false)
|
||||||
|
|
|
@ -374,12 +374,14 @@ class CommandQueue @Inject constructor(
|
||||||
callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run()
|
callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
/* this is breaking setting of profile at all if not engineering mode
|
||||||
if (!buildHelper.isEngineeringModeOrRelease()) {
|
if (!buildHelper.isEngineeringModeOrRelease()) {
|
||||||
val notification = Notification(Notification.NOT_ENG_MODE_OR_RELEASE, resourceHelper.gs(R.string.not_eng_mode_or_release), Notification.URGENT)
|
val notification = Notification(Notification.NOT_ENG_MODE_OR_RELEASE, resourceHelper.gs(R.string.not_eng_mode_or_release), Notification.URGENT)
|
||||||
rxBus.send(EventNewNotification(notification))
|
rxBus.send(EventNewNotification(notification))
|
||||||
callback?.result(PumpEnactResult(injector).success(false).enacted(false).comment(resourceHelper.gs(R.string.not_eng_mode_or_release)))?.run()
|
callback?.result(PumpEnactResult(injector).success(false).enacted(false).comment(resourceHelper.gs(R.string.not_eng_mode_or_release)))?.run()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Compare with pump limits
|
// Compare with pump limits
|
||||||
val basalValues = profile.basalValues
|
val basalValues = profile.basalValues
|
||||||
for (basalValue in basalValues) {
|
for (basalValue in basalValues) {
|
||||||
|
|
Loading…
Reference in a new issue