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

View file

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

View file

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