Medtrum: Allow reset of all suspended states
This commit is contained in:
parent
9dee913977
commit
7627fcce7d
3 changed files with 7 additions and 10 deletions
|
@ -27,6 +27,10 @@ enum class MedtrumPumpState(val state: Byte) {
|
|||
NO_CALIBRATION(103),
|
||||
STOPPED(128.toByte());
|
||||
|
||||
fun isSuspendedByPump(): Boolean {
|
||||
return this in LOW_BG_SUSPENDED..SUSPENDED
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun fromByte(state: Byte) = values().find { it.state == state }
|
||||
|
|
|
@ -281,13 +281,8 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
|||
}
|
||||
|
||||
fun clearAlarms(): Boolean {
|
||||
var result = true
|
||||
if (medtrumPump.pumpState in listOf(
|
||||
MedtrumPumpState.PAUSED,
|
||||
MedtrumPumpState.HOURLY_MAX_SUSPENDED,
|
||||
MedtrumPumpState.DAILY_MAX_SUSPENDED
|
||||
)
|
||||
) {
|
||||
var result = loadEvents() // Make sure we have all events before clearing alarms
|
||||
if (result && medtrumPump.pumpState.isSuspendedByPump()) {
|
||||
when (medtrumPump.pumpState) {
|
||||
MedtrumPumpState.HOURLY_MAX_SUSPENDED -> {
|
||||
result = sendPacketAndGetResponse(ClearPumpAlarmPacket(injector, ALARM_HOURLY_MAX_CLEAR_CODE))
|
||||
|
|
|
@ -119,9 +119,7 @@ class MedtrumOverviewViewModel @Inject constructor(
|
|||
medtrumPump.pumpStateFlow.collect { state ->
|
||||
aapsLogger.debug(LTag.PUMP, "MedtrumViewModel pumpStateFlow: $state")
|
||||
_canDoResetAlarms.postValue(
|
||||
medtrumPump.pumpState in listOf(
|
||||
MedtrumPumpState.PAUSED, MedtrumPumpState.HOURLY_MAX_SUSPENDED, MedtrumPumpState.DAILY_MAX_SUSPENDED
|
||||
)
|
||||
medtrumPump.pumpState.isSuspendedByPump()
|
||||
)
|
||||
|
||||
updateGUI()
|
||||
|
|
Loading…
Reference in a new issue