WIP on integrating Omnipod Dash activation wizard

This commit is contained in:
Bart Sopers 2021-03-15 00:51:07 +01:00
parent dd480134e2
commit 6d4521ca6b
6 changed files with 19 additions and 11 deletions

View file

@ -161,7 +161,7 @@ class OmnipodDashManagerImpl @Inject constructor(
if (podStateManager.podStatus == PodStatus.CLUTCH_DRIVE_ENGAGED) {
Observable.empty()
} else {
Observable.error(IllegalStateException("Unexpected Pod status"))
Observable.error(IllegalStateException("Unexpected Pod status: got ${podStateManager.podStatus}, expected CLUTCH_DRIVE_ENGAGED"))
}
}
)

View file

@ -47,6 +47,7 @@ class Session(
val responseMsg = msgIO.receiveMessage()
val decrypted = enDecrypt.decrypt(responseMsg)
aapsLogger.debug(LTag.PUMPBTCOMM, "Received response: $decrypted")
val response = parseResponse(decrypted)
if (!responseType.isInstance(response)) {
@ -69,8 +70,17 @@ class Session(
@Throws(CouldNotParseResponseException::class, UnsupportedOperationException::class)
private fun parseResponse(decrypted: MessagePacket): Response {
val payload = parseKeys(arrayOf(RESPONSE_PREFIX), decrypted.payload)[0]
aapsLogger.info(LTag.PUMPBTCOMM, "Received decrypted response: ${payload.toHex()} in packet: $decrypted")
val data = parseKeys(arrayOf(RESPONSE_PREFIX), decrypted.payload)[0]
aapsLogger.info(LTag.PUMPBTCOMM, "Received decrypted response: ${data.toHex()} in packet: $decrypted")
// TODO verify length
val uniqueId = data.copyOfRange(0, 4)
val lenghtAndSequenceNumber = data.copyOfRange(4, 6)
val payload = data.copyOfRange(6, data.size - 2)
val crc = data.copyOfRange(data.size - 2, data.size)
// TODO validate uniqueId, sequenceNumber and crc
return ResponseUtil.parseResponse(payload)
}

View file

@ -216,8 +216,8 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
override fun updateFromSetUniqueIdResponse(response: SetUniqueIdResponse) {
podState.pulseRate = response.pumpRate
podState.primePulseRate = response.primePumpRate
podState.firstPrimeBolusVolume = response.numberOfPrimePulses
podState.secondPrimeBolusVolume = response.numberOfEngagingClutchDrivePulses
podState.firstPrimeBolusVolume = response.numberOfEngagingClutchDrivePulses
podState.secondPrimeBolusVolume = response.numberOfPrimePulses
podState.podLifeInHours = response.podExpirationTimeInHours
podState.bleVersion = SoftwareVersion(
response.bleVersionMajor,

View file

@ -25,9 +25,6 @@ import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import javax.inject.Inject
/**
* Created by andy on 30/08/2019
*/
class DashPodManagementActivity : NoSplashAppCompatActivity() {
@Inject lateinit var rxBus: RxBusWrapper
@ -70,7 +67,7 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() {
this,
resourceHelper.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation),
Thread {
// TODO discard Pod
podStateManager.reset()
}
)
}

View file

@ -313,7 +313,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
podInfoBinding.reservoir.text = resourceHelper.gs(
R.string.omnipod_common_overview_reservoir_value,
podStateManager.pulsesRemaining
(podStateManager.pulsesRemaining!! / 20.0)
)
podInfoBinding.reservoir.setTextColor(
if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) {

View file

@ -119,6 +119,7 @@
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<!-- FIXME visible for development -->
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/button_discard_pod"
style="?android:attr/buttonStyle"
@ -127,7 +128,7 @@
android:drawableTop="@drawable/ic_pod_management_discard_pod"
android:text="@string/omnipod_common_pod_management_button_discard_pod"
android:textAllCaps="false"
android:visibility="gone"
android:visibility="visible"
app:layout_constrainedHeight="@+id/Actions_Row_2_horizontal_guideline"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="@+id/Actions_Col_1_Row_2_vertical_guideline"