set initial basalProgram. fix handshaking state

This commit is contained in:
Andrei Vereha 2021-07-16 23:17:37 +02:00
parent 32183aff37
commit f9aa967b46
3 changed files with 8 additions and 3 deletions

View file

@ -200,11 +200,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
override fun isConnecting(): Boolean {
return stopConnecting != null && podStateManager.bluetoothConnectionState == OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
return stopConnecting != null
}
override fun isHandshakeInProgress(): Boolean {
return stopConnecting != null
return stopConnecting != null &&
podStateManager.bluetoothConnectionState == OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTED
}
override fun finishHandshaking() {
@ -212,6 +213,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun connect(reason: String) {
aapsLogger.info(LTag.PUMP, "connect reason=$reason")
podStateManager.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
thread(
start = true,
name = "ConnectionThread",
@ -437,7 +439,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
// TODO: what do we have to answer here if delivery is suspended?
val running = podStateManager.basalProgram
val equal = (mapProfileToBasalProgram(profile) == running)
aapsLogger.info(LTag.PUMP, "isThisProfileSet: $equal")
aapsLogger.info(LTag.PUMP, "set: $equal. profile=$profile, running=$running")
return equal
}

View file

@ -218,7 +218,9 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
}
override var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState
@Synchronized
get() = podState.bluetoothConnectionState
@Synchronized
set(bluetoothConnectionState) {
podState.bluetoothConnectionState = bluetoothConnectionState
rxBus.send(EventOmnipodDashPumpValuesChanged())

View file

@ -73,6 +73,7 @@ class DashInsertCannulaViewModel @Inject constructor(
},
onComplete = {
logger.debug("Pod activation part 2 completed")
podStateManager.basalProgram = basalProgram
pumpSync.connectNewPump()
pumpSync.insertTherapyEventIfNewWithTimestamp(
timestamp = System.currentTimeMillis(),