diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt
index 60b9363238..d9fff23aad 100644
--- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt
+++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt
@@ -166,7 +166,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
throw SessionEstablishmentException("Received resynchronization SQN for the second time")
}
}
-
+ podState.successfulConnections++
podState.commitEapAkaSequenceNumber()
}
@@ -223,6 +223,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
}
emitter.onNext(PodEvent.EstablishingSession)
establishSession(pairResult.msgSeq)
+ podState.successfulConnections++
emitter.onNext(PodEvent.Connected)
emitter.onComplete()
} catch (ex: Exception) {
diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt
index 261f42e0ea..c2e1a848b4 100644
--- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt
+++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt
@@ -64,7 +64,7 @@ class Connection(
fun connect(connectionWaitCond: ConnectionWaitCondition) {
aapsLogger.debug("Connecting connectionWaitCond=$connectionWaitCond")
-
+ podState.connectionAttempts++
podState.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
val autoConnect = false
val gatt = gattConnection
diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt
index af833c4552..2e862b81b1 100644
--- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt
+++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt
@@ -31,6 +31,8 @@ interface OmnipodDashPodStateManager {
val isPodRunning: Boolean
val isPodKaput: Boolean
var bluetoothConnectionState: BluetoothConnectionState
+ var connectionAttempts: Int
+ var successfulConnections: Int
var timeZone: TimeZone
val sameTimeZone: Boolean // The TimeZone is the same on the phone and on the pod
@@ -81,6 +83,7 @@ interface OmnipodDashPodStateManager {
fun updateFromAlarmStatusResponse(response: AlarmStatusResponse)
fun updateFromPairing(uniqueId: Id, pairResult: PairResult)
fun reset()
+ fun connectionSuccessRatio(): Float
fun createActiveCommand(
historyId: String,
diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt
index ad9d789467..0a7ca2ed56 100644
--- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt
+++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt
@@ -98,6 +98,22 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
}
}
+ override var connectionAttempts: Int
+ @Synchronized
+ get() = podState.connectionAttempts
+ @Synchronized
+ set(value) {
+ podState.connectionAttempts = value
+ }
+
+ override var successfulConnections: Int
+ @Synchronized
+ get() = podState.successfulConnections
+ @Synchronized
+ set(value) {
+ podState.successfulConnections = value
+ }
+
override var timeZone: TimeZone
get() = TimeZone.getTimeZone(podState.timeZone)
set(tz) {
@@ -588,6 +604,14 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
podState.uniqueId = uniqueId.toLong()
}
+ override fun connectionSuccessRatio(): Float {
+ val attempts = connectionAttempts
+ if (attempts == 0) {
+ return 1.0F
+ }
+ return successfulConnections.toFloat() * 100 / attempts.toFloat()
+ }
+
override fun reset() {
podState = PodState()
store()
@@ -625,6 +649,8 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
var lastStatusResponseReceived: Long = 0
var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState =
OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED
+ var connectionAttempts = 0
+ var successfulConnections = 0
var messageSequenceNumber: Short = 0
var sequenceNumberOfLastProgrammingCommand: Short? = null
var activationTime: Long? = null
diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt
index 97f70338a5..6eaa1aa29a 100644
--- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt
+++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt
@@ -24,7 +24,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.Comm
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandResumeDelivery
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSilenceAlerts
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSuspendDelivery
-import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.dash.OmnipodDashPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
@@ -83,17 +82,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
}
}
- var _binding: OmnipodDashOverviewBinding? = null
- var _bluetoothStatusBinding: OmnipodDashOverviewBluetoothStatusBinding? = null
- var _podInfoBinding: OmnipodCommonOverviewPodInfoBinding? = null
- var _buttonBinding: OmnipodCommonOverviewButtonsBinding? = null
+ private var _binding: OmnipodDashOverviewBinding? = null
+ private var _bluetoothStatusBinding: OmnipodDashOverviewBluetoothStatusBinding? = null
+ private var _podInfoBinding: OmnipodCommonOverviewPodInfoBinding? = null
+ private var _buttonBinding: OmnipodCommonOverviewButtonsBinding? = null
// These properties are only valid between onCreateView and
// onDestroyView.
val binding get() = _binding!!
val bluetoothStatusBinding get() = _bluetoothStatusBinding!!
- val podInfoBinding get() = _podInfoBinding!!
- val buttonBinding get() = _buttonBinding!!
+ private val podInfoBinding get() = _podInfoBinding!!
+ private val buttonBinding get() = _buttonBinding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
OmnipodDashOverviewBinding.inflate(inflater, container, false).also {
@@ -234,6 +233,23 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING ->
"{fa-bluetooth-b spin}"
}
+
+ val connectionSuccessPercentage = podStateManager.connectionSuccessRatio() * 100
+ val successPercentageString = String.format("%.2f %", podStateManager.connectionSuccessRatio())
+ val connectionQuality = "${podStateManager.successfulConnections}/${podStateManager.connectionAttempts} :: $successPercentageString"
+ bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.text = connectionQuality
+ val connectionStatsColor = when {
+ connectionSuccessPercentage > 90 ->
+ Color.WHITE
+ connectionSuccessPercentage > 60 ->
+ Color.YELLOW
+ else ->
+ Color.RED
+ }
+ bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.setTextColor(connectionStatsColor)
+ bluetoothStatusBinding.omnipodDashDeliveryStatus.text = podStateManager.deliveryStatus?.let {
+ podStateManager.deliveryStatus.toString()
+ } ?: PLACEHOLDER
}
private fun updateOmnipodStatus() {
@@ -361,8 +377,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
)
}
- podInfoBinding.podActiveAlerts.text = podStateManager.activeAlerts?.let {
- it.map { it.toString() }.joinToString(",")
+ podInfoBinding.podActiveAlerts.text = podStateManager.activeAlerts?.let { it ->
+ it.joinToString(",") { it.toString() }
} ?: PLACEHOLDER
}
@@ -415,12 +431,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
if (podStateManager.isSuspended) {
resourceHelper.gs(R.string.omnipod_common_pod_status_suspended)
} else {
- resourceHelper.gs(R.string.omnipod_common_pod_status_running) +
- if (BuildConfig.DEBUG)
- podStateManager.deliveryStatus?.let { " " + podStateManager.deliveryStatus.toString() }
- else ""
+ resourceHelper.gs(R.string.omnipod_common_pod_status_running)
}
- // TODO
/*
} else if (podStateManager.podStatus == PodProgressStatus.FAULT_EVENT_OCCURRED) {
resourceHelper.gs(R.string.omnipod_common_pod_status_pod_fault)
@@ -466,10 +478,10 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
podInfoBinding.lastBolus.setTextColor(textColor)
podStateManager.lastBolus?.let {
// display requested units if delivery is in progress
- var bolusSize = it.deliveredUnits()
+ val bolusSize = it.deliveredUnits()
?: it.requestedUnits
- var text = resourceHelper.gs(
+ val text = resourceHelper.gs(
R.string.omnipod_common_overview_last_bolus_value,
omnipodDashPumpPlugin.model().determineCorrectBolusSize(bolusSize),
resourceHelper.gs(R.string.insulin_unit_shortname),
diff --git a/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml b/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml
index 8d7ac5e903..da4332b934 100644
--- a/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml
+++ b/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml
@@ -13,7 +13,7 @@
android:gravity="end"
android:paddingStart="5dp"
android:paddingEnd="5dp"
- android:text="@string/omnipod_dash_overview_bluetooth_status"
+ android:text="@string/omnipod_dash_overview_bluetooth_address"
android:textSize="14sp" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Bluetooth Status
Bluetooth Address
Firmware %1$s / Bluetooth %2$s
+ Connection quality
+ Delivery Status
Fill a new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press Next.\n\nNote: do not remove the Pod\'s needle cap at this time.
@@ -19,4 +21,4 @@
omnipod_common_preferences_category_confirmation
common_preferences_category_other
-
\ No newline at end of file
+