Merge pull request #1715 from avereha/fix-history-id

Fix Dash historyIds
This commit is contained in:
Milos Kozak 2022-05-10 20:35:42 +02:00 committed by GitHub
commit 82760a7a3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 187 additions and 190 deletions

View file

@ -5,11 +5,11 @@ import androidx.room.Room
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.guepardoapps.kulid.ULID import com.github.guepardoapps.kulid.ULID
import info.nightscout.shared.logging.AAPSLoggerTest
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper
import info.nightscout.shared.logging.AAPSLoggerTest
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
@ -48,7 +49,6 @@ import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.TimeChangeType import info.nightscout.androidaps.utils.TimeChangeType
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
@ -66,7 +66,6 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.concurrent.thread import kotlin.concurrent.thread
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.random.Random
@Singleton @Singleton
class OmnipodDashPumpPlugin @Inject constructor( class OmnipodDashPumpPlugin @Inject constructor(
@ -142,7 +141,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
duration = T.mins(PodConstants.MAX_POD_LIFETIME.toMinutes()).msecs(), duration = T.mins(PodConstants.MAX_POD_LIFETIME.toMinutes()).msecs(),
isAbsolute = true, isAbsolute = true,
type = PumpSync.TemporaryBasalType.PUMP_SUSPEND, type = PumpSync.TemporaryBasalType.PUMP_SUSPEND,
pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique pumpId = System.currentTimeMillis(), // we don't use this, just make sure it's unique
pumpType = PumpType.OMNIPOD_DASH, pumpType = PumpType.OMNIPOD_DASH,
pumpSerial = Constants.PUMP_SERIAL_FOR_FAKE_TBR // switching the serialNumber here would need a pumpSerial = Constants.PUMP_SERIAL_FOR_FAKE_TBR // switching the serialNumber here would need a
// call to connectNewPump. If we do that, then we will have a TBR started by the "n/a" pump and // call to connectNewPump. If we do that, then we will have a TBR started by the "n/a" pump and
@ -323,7 +322,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
duration = T.mins(PodConstants.MAX_POD_LIFETIME.toMinutes()).msecs(), duration = T.mins(PodConstants.MAX_POD_LIFETIME.toMinutes()).msecs(),
isAbsolute = true, isAbsolute = true,
type = PumpSync.TemporaryBasalType.PUMP_SUSPEND, type = PumpSync.TemporaryBasalType.PUMP_SUSPEND,
pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique pumpId = System.currentTimeMillis(), // we don't use this, just make sure it's unique
pumpType = PumpType.OMNIPOD_DASH, pumpType = PumpType.OMNIPOD_DASH,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
@ -356,7 +355,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
} }
pumpSync.insertAnnouncement( pumpSync.insertAnnouncement(
error = it.toString(), error = it.toString(),
pumpId = Random.Default.nextLong(), pumpId = System.currentTimeMillis(),
pumpType = PumpType.OMNIPOD_DASH, pumpType = PumpType.OMNIPOD_DASH,
pumpSerial = serialNumber() pumpSerial = serialNumber()
) )
@ -1324,8 +1323,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun executeProgrammingCommand( private fun executeProgrammingCommand(
pre: Completable = Completable.complete(), pre: Completable = Completable.complete(),
historyEntry: Single<String>, historyEntry: Single<Long>,
activeCommandEntry: (historyId: String) -> Single<OmnipodDashPodStateManager.ActiveCommand> = activeCommandEntry: (historyId: Long) -> Single<OmnipodDashPodStateManager.ActiveCommand> =
{ historyId -> podStateManager.createActiveCommand(historyId) }, { historyId -> podStateManager.createActiveCommand(historyId) },
command: Completable, command: Completable,
post: Completable = Completable.complete(), post: Completable = Completable.complete(),

View file

@ -4,11 +4,11 @@ import android.content.Context
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.Reusable import dagger.Reusable
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper
import info.nightscout.shared.logging.AAPSLogger
import javax.inject.Singleton import javax.inject.Singleton
@Module @Module

View file

@ -1,8 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver
import android.os.SystemClock import android.os.SystemClock
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManager
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.*
@ -17,6 +15,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.core.Observable import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.functions.Action import io.reactivex.rxjava3.functions.Action
import io.reactivex.rxjava3.functions.Consumer import io.reactivex.rxjava3.functions.Consumer

View file

@ -4,8 +4,6 @@ import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager import android.bluetooth.BluetoothManager
import android.content.Context import android.content.Context
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.LTKExchanger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.LTKExchanger
@ -15,6 +13,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEven
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.core.Observable import io.reactivex.rxjava3.core.Observable
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean

View file

@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm
import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattCharacteristic
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ConnectException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ConnectException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType
@ -11,6 +9,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.Connection import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.Connection
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.Connection.Companion.STOP_CONNECTING_CHECK_INTERVAL_MS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.Connection.Companion.STOP_CONNECTING_CHECK_INTERVAL_MS
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.ConnectionWaitCondition import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.ConnectionWaitCondition
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.math.BigInteger import java.math.BigInteger
import java.util.* import java.util.*

View file

@ -6,11 +6,11 @@ import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor import android.bluetooth.BluetoothGattDescriptor
import android.bluetooth.BluetoothProfile import android.bluetooth.BluetoothProfile
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType.Companion.byValue import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType.Companion.byValue
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.IncomingPackets import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.IncomingPackets
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.DisconnectHandler import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.DisconnectHandler
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.util.* import java.util.*
import java.util.concurrent.BlockingQueue import java.util.concurrent.BlockingQueue
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
import org.spongycastle.crypto.engines.AESEngine import org.spongycastle.crypto.engines.AESEngine
import org.spongycastle.crypto.modes.CCMBlockCipher import org.spongycastle.crypto.modes.CCMBlockCipher
import org.spongycastle.crypto.params.AEADParameters import org.spongycastle.crypto.params.AEADParameters

View file

@ -6,13 +6,13 @@ import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor import android.bluetooth.BluetoothGattDescriptor
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationError import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationError
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationSuccess import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationSuccess
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommandRTS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommandRTS
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.*
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.util.concurrent.BlockingQueue import java.util.concurrent.BlockingQueue
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit

View file

@ -2,11 +2,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io
import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattCharacteristic
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManagerImpl import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManagerImpl
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommand import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommand
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommandHello import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommandHello
import info.nightscout.shared.logging.AAPSLogger
import java.util.concurrent.BlockingQueue import java.util.concurrent.BlockingQueue
sealed class BleConfirmResult sealed class BleConfirmResult

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io
import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattCharacteristic
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks
import info.nightscout.shared.logging.AAPSLogger
import java.util.concurrent.BlockingQueue import java.util.concurrent.BlockingQueue
class DataBleIO( class DataBleIO(

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.BlePacket import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.BlePacket
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
sealed class MessageSendResult sealed class MessageSendResult
object MessageSendSuccess : MessageSendResult() object MessageSendSuccess : MessageSendResult()

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import org.spongycastle.crypto.engines.AESEngine import org.spongycastle.crypto.engines.AESEngine
import org.spongycastle.crypto.macs.CMac import org.spongycastle.crypto.macs.CMac
import org.spongycastle.crypto.params.KeyParameter import org.spongycastle.crypto.params.KeyParameter

View file

@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
import info.nightscout.androidaps.extensions.hexStringToByteArray import info.nightscout.androidaps.extensions.hexStringToByteArray
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.PairingException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.PairingException
@ -13,6 +11,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
internal class LTKExchanger( internal class LTKExchanger(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,

View file

@ -4,10 +4,10 @@ import android.bluetooth.BluetoothAdapter
import android.bluetooth.le.ScanFilter import android.bluetooth.le.ScanFilter
import android.bluetooth.le.ScanSettings import android.bluetooth.le.ScanSettings
import android.os.ParcelUuid import android.os.ParcelUuid
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.util.* import java.util.*
class PodScanner(private val logger: AAPSLogger, private val bluetoothAdapter: BluetoothAdapter) { class PodScanner(private val logger: AAPSLogger, private val bluetoothAdapter: BluetoothAdapter) {

View file

@ -2,9 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.scan
import android.bluetooth.le.ScanCallback import android.bluetooth.le.ScanCallback
import android.bluetooth.le.ScanResult import android.bluetooth.le.ScanResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException
import java.util.* import java.util.*
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap

View file

@ -7,8 +7,6 @@ import android.bluetooth.BluetoothProfile
import android.content.Context import android.content.Context
import android.os.SystemClock import android.os.SystemClock
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.ServiceDiscoverer import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.ServiceDiscoverer
@ -22,6 +20,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.DataB
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.IncomingPackets import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.IncomingPackets
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageIO import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageIO
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.lang.IllegalArgumentException import java.lang.IllegalArgumentException
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import java.nio.ByteBuffer import java.nio.ByteBuffer
enum class EapCode(val code: Byte) { enum class EapCode(val code: Byte) {

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import org.spongycastle.util.encoders.Hex import org.spongycastle.util.encoders.Hex
import java.security.SecureRandom import java.security.SecureRandom
import javax.crypto.Cipher import javax.crypto.Cipher

View file

@ -1,8 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt.EnDecrypt import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt.EnDecrypt
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.CouldNotParseResponseException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.CouldNotParseResponseException
@ -11,6 +9,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
sealed class CommandSendResult sealed class CommandSendResult
object CommandSendSuccess : CommandSendResult() object CommandSendSuccess : CommandSendResult()

View file

@ -1,8 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt.Nonce import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt.Nonce
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.SessionEstablishmentException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.SessionEstablishmentException
@ -10,6 +8,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageSendSuccess import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageSendSuccess
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageType
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import java.security.SecureRandom import java.security.SecureRandom
import java.util.* import java.util.*

View file

@ -94,7 +94,7 @@ interface OmnipodDashPodStateManager {
fun updateTimeZone() fun updateTimeZone()
fun createActiveCommand( fun createActiveCommand(
historyId: String, historyId: Long,
basalProgram: BasalProgram? = null, basalProgram: BasalProgram? = null,
tempBasal: TempBasal? = null, tempBasal: TempBasal? = null,
requestedBolus: Double? = null requestedBolus: Double? = null
@ -103,7 +103,7 @@ interface OmnipodDashPodStateManager {
fun observeNoActiveCommand(): Completable fun observeNoActiveCommand(): Completable
fun getCommandConfirmationFromState(): CommandConfirmationFromState fun getCommandConfirmationFromState(): CommandConfirmationFromState
fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType) fun createLastBolus(requestedUnits: Double, historyId: Long, bolusType: DetailedBolusInfo.BolusType)
fun markLastBolusComplete(): LastBolus? fun markLastBolusComplete(): LastBolus?
fun onStart() fun onStart()
/* /*
@ -120,7 +120,7 @@ interface OmnipodDashPodStateManager {
val sequence: Short, val sequence: Short,
val createdRealtime: Long, val createdRealtime: Long,
var sentRealtime: Long = 0, var sentRealtime: Long = 0,
val historyId: String, val historyId: Long,
var sendError: Throwable?, var sendError: Throwable?,
var basalProgram: BasalProgram?, var basalProgram: BasalProgram?,
val tempBasal: TempBasal?, val tempBasal: TempBasal?,
@ -135,7 +135,7 @@ interface OmnipodDashPodStateManager {
val requestedUnits: Double, val requestedUnits: Double,
var bolusUnitsRemaining: Double, var bolusUnitsRemaining: Double,
var deliveryComplete: Boolean, var deliveryComplete: Boolean,
val historyId: String, val historyId: Long,
val bolusType: DetailedBolusInfo.BolusType val bolusType: DetailedBolusInfo.BolusType
) { ) {

View file

@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state
import android.os.SystemClock import android.os.SystemClock
import com.google.gson.Gson import com.google.gson.Gson
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
@ -17,6 +15,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.Round
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Maybe import io.reactivex.rxjava3.core.Maybe
@ -323,7 +323,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
get() = podState.activeCommand get() = podState.activeCommand
@Synchronized @Synchronized
override fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType) { override fun createLastBolus(requestedUnits: Double, historyId: Long, bolusType: DetailedBolusInfo.BolusType) {
podState.lastBolus = OmnipodDashPodStateManager.LastBolus( podState.lastBolus = OmnipodDashPodStateManager.LastBolus(
startTime = System.currentTimeMillis(), startTime = System.currentTimeMillis(),
requestedUnits = requestedUnits, requestedUnits = requestedUnits,
@ -358,7 +358,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
@Synchronized @Synchronized
override fun createActiveCommand( override fun createActiveCommand(
historyId: String, historyId: Long,
basalProgram: BasalProgram?, basalProgram: BasalProgram?,
tempBasal: OmnipodDashPodStateManager.TempBasal?, tempBasal: OmnipodDashPodStateManager.TempBasal?,
requestedBolus: Double? requestedBolus: Double?

View file

@ -1,8 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.history package info.nightscout.androidaps.plugins.pump.omnipod.dash.history
import com.github.guepardoapps.kulid.ULID
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_BOLUS import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_BOLUS
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_TEMPORARY_BASAL import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_TEMPORARY_BASAL
@ -11,6 +8,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordEntity import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordEntity
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import java.lang.System.currentTimeMillis import java.lang.System.currentTimeMillis
@ -22,19 +21,19 @@ class DashHistory @Inject constructor(
private val logger: AAPSLogger private val logger: AAPSLogger
) { ) {
private fun markSuccess(id: String): Completable = dao.markResolved( private fun markSuccess(id: Long): Completable = dao.markResolved(
id, id,
ResolvedResult.SUCCESS, ResolvedResult.SUCCESS,
currentTimeMillis() currentTimeMillis()
) )
private fun markFailure(id: String): Completable = dao.markResolved( private fun markFailure(id: Long): Completable = dao.markResolved(
id, id,
ResolvedResult.FAILURE, ResolvedResult.FAILURE,
currentTimeMillis() currentTimeMillis()
) )
fun getById(id: String): HistoryRecord { fun getById(id: Long): HistoryRecord {
val entry = dao.byIdBlocking(id) val entry = dao.byIdBlocking(id)
?: throw java.lang.IllegalArgumentException("history entry [$id] not found") ?: throw java.lang.IllegalArgumentException("history entry [$id] not found")
return historyMapper.entityToDomain(entry) return historyMapper.entityToDomain(entry)
@ -50,9 +49,11 @@ class DashHistory @Inject constructor(
basalProfileRecord: BasalValuesRecord? = null, basalProfileRecord: BasalValuesRecord? = null,
resolveResult: ResolvedResult? = null, resolveResult: ResolvedResult? = null,
resolvedAt: Long? = null resolvedAt: Long? = null
): Single<String> = Single.defer { ): Single<Long> = Single.defer {
val id = ULID.random() var id: Long = 0
if (dao.first() == null) {
id = currentTimeMillis()
}
when { when {
commandType == SET_BOLUS && bolusRecord == null -> commandType == SET_BOLUS && bolusRecord == null ->
Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS")) Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS"))
@ -72,7 +73,7 @@ class DashHistory @Inject constructor(
resolvedResult = resolveResult, resolvedResult = resolveResult,
resolvedAt = resolvedAt resolvedAt = resolvedAt
) )
).toSingle { id } )
} }
} }
@ -82,7 +83,7 @@ class DashHistory @Inject constructor(
fun getRecordsAfter(time: Long): Single<List<HistoryRecord>> = fun getRecordsAfter(time: Long): Single<List<HistoryRecord>> =
dao.allSince(time).map { list -> list.map(historyMapper::entityToDomain) } dao.allSince(time).map { list -> list.map(historyMapper::entityToDomain) }
fun updateFromState(podState: OmnipodDashPodStateManager) = Completable.defer { fun updateFromState(podState: OmnipodDashPodStateManager): Completable = Completable.defer {
val historyId = podState.activeCommand?.historyId val historyId = podState.activeCommand?.historyId
if (historyId == null) { if (historyId == null) {
logger.error(LTag.PUMP, "HistoryId not found to for updating from state") logger.error(LTag.PUMP, "HistoryId not found to for updating from state")

View file

@ -1,11 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data
import com.github.guepardoapps.kulid.ULID
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import java.nio.ByteBuffer
data class HistoryRecord( data class HistoryRecord(
val id: String, // ULID val id: Long,
val createdAt: Long, // creation date of the record val createdAt: Long, // creation date of the record
val date: Long, // when event actually happened val date: Long, // when event actually happened
val commandType: OmnipodCommandType, val commandType: OmnipodCommandType,
@ -15,8 +13,7 @@ data class HistoryRecord(
val resolvedAt: Long? val resolvedAt: Long?
) { ) {
fun pumpId(): Long { fun pumpId(): Long {
val entropy = ULID.getEntropy(id) return id
return ByteBuffer.wrap(entropy).long
} }
fun displayTimestamp(): Long { fun displayTimestamp(): Long {

View file

@ -18,7 +18,7 @@ abstract class DashHistoryDatabase : RoomDatabase() {
companion object { companion object {
const val VERSION = 2 const val VERSION = 3
fun build(context: Context) = fun build(context: Context) =
Room.databaseBuilder( Room.databaseBuilder(

View file

@ -16,27 +16,24 @@ abstract class HistoryRecordDao {
@Query("SELECT * from historyrecords") @Query("SELECT * from historyrecords")
abstract fun all(): Single<List<HistoryRecordEntity>> abstract fun all(): Single<List<HistoryRecordEntity>>
@Query("SELECT * from historyrecords") @Query("SELECT * from historyrecords ORDER BY id LIMIT 1")
abstract fun allBlocking(): List<HistoryRecordEntity> abstract fun first(): HistoryRecordEntity?
@Query("SELECT * from historyrecords WHERE createdAt >= :since ORDER BY createdAt DESC") @Query("SELECT * from historyrecords WHERE createdAt >= :since ORDER BY createdAt DESC")
abstract fun allSince(since: Long): Single<List<HistoryRecordEntity>> abstract fun allSince(since: Long): Single<List<HistoryRecordEntity>>
@Query("SELECT * FROM historyrecords WHERE id = :id LIMIT 1") @Query("SELECT * FROM historyrecords WHERE id = :id LIMIT 1")
abstract fun byIdBlocking(id: String): HistoryRecordEntity? abstract fun byIdBlocking(id: Long): HistoryRecordEntity?
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun saveBlocking(historyRecordEntity: HistoryRecordEntity) abstract fun save(historyRecordEntity: HistoryRecordEntity): Single<Long>
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun save(historyRecordEntity: HistoryRecordEntity): Completable
@Delete @Delete
abstract fun delete(historyRecordEntity: HistoryRecordEntity): Completable abstract fun delete(historyRecordEntity: HistoryRecordEntity): Completable
@Query("UPDATE historyrecords SET resolvedResult = :resolvedResult, resolvedAt = :resolvedAt WHERE id = :id ") @Query("UPDATE historyrecords SET resolvedResult = :resolvedResult, resolvedAt = :resolvedAt WHERE id = :id ")
abstract fun markResolved(id: String, resolvedResult: ResolvedResult, resolvedAt: Long): Completable abstract fun markResolved(id: Long, resolvedResult: ResolvedResult, resolvedAt: Long): Completable
@Query("UPDATE historyrecords SET initialResult = :initialResult WHERE id = :id ") @Query("UPDATE historyrecords SET initialResult = :initialResult WHERE id = :id ")
abstract fun setInitialResult(id: String, initialResult: InitialResult): Completable abstract fun setInitialResult(id: Long, initialResult: InitialResult): Completable
} }

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database
import androidx.room.Embedded import androidx.room.Embedded
import androidx.room.Entity import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BasalValuesRecord import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BasalValuesRecord
@ -10,9 +11,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.Initial
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.ResolvedResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.ResolvedResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.TempBasalRecord import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.TempBasalRecord
@Entity(tableName = "historyrecords") @Entity(
tableName = "historyrecords",
indices = [
Index("createdAt"),
]
)
data class HistoryRecordEntity( data class HistoryRecordEntity(
@PrimaryKey val id: String, // ULID @PrimaryKey(autoGenerate = true)
val id: Long = 0,
val createdAt: Long, // creation date of the record val createdAt: Long, // creation date of the record
val date: Long, // when event actually happened val date: Long, // when event actually happened
val commandType: OmnipodCommandType, val commandType: OmnipodCommandType,

View file

@ -1,27 +1,10 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BasalValuesRecord
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusRecord
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.HistoryRecord import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.HistoryRecord
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.TempBasalRecord
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordEntity import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordEntity
class HistoryMapper { class HistoryMapper {
fun domainToEntity(historyRecord: HistoryRecord): HistoryRecordEntity =
HistoryRecordEntity(
id = historyRecord.id,
createdAt = historyRecord.createdAt,
date = historyRecord.date,
commandType = historyRecord.commandType,
initialResult = historyRecord.initialResult,
tempBasalRecord = historyRecord.record as? TempBasalRecord,
bolusRecord = historyRecord.record as? BolusRecord,
resolvedResult = historyRecord.resolvedResult,
resolvedAt = historyRecord.resolvedAt,
basalProfileRecord = historyRecord.record as? BasalValuesRecord
)
fun entityToDomain(entity: HistoryRecordEntity): HistoryRecord = fun entityToDomain(entity: HistoryRecordEntity): HistoryRecord =
HistoryRecord( HistoryRecord(
id = entity.id, id = entity.id,

View file

@ -53,44 +53,44 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup { private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup {
return when (type) { return when (type) {
OmnipodCommandType.INITIALIZE_POD -> OmnipodCommandType.INITIALIZE_POD ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.INSERT_CANNULA -> OmnipodCommandType.INSERT_CANNULA ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.DEACTIVATE_POD -> OmnipodCommandType.DEACTIVATE_POD ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.DISCARD_POD -> OmnipodCommandType.DISCARD_POD ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> OmnipodCommandType.CANCEL_TEMPORARY_BASAL ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_BASAL_PROFILE -> OmnipodCommandType.SET_BASAL_PROFILE ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_TEMPORARY_BASAL -> OmnipodCommandType.SET_TEMPORARY_BASAL ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.RESUME_DELIVERY -> OmnipodCommandType.RESUME_DELIVERY ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SUSPEND_DELIVERY -> OmnipodCommandType.SUSPEND_DELIVERY ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_BOLUS -> OmnipodCommandType.SET_BOLUS ->
PumpHistoryEntryGroup.Bolus PumpHistoryEntryGroup.Bolus
OmnipodCommandType.CANCEL_BOLUS -> OmnipodCommandType.CANCEL_BOLUS ->
PumpHistoryEntryGroup.Bolus PumpHistoryEntryGroup.Bolus
OmnipodCommandType.ACKNOWLEDGE_ALERTS -> OmnipodCommandType.ACKNOWLEDGE_ALERTS ->
PumpHistoryEntryGroup.Alarm PumpHistoryEntryGroup.Alarm
OmnipodCommandType.CONFIGURE_ALERTS -> OmnipodCommandType.CONFIGURE_ALERTS ->
PumpHistoryEntryGroup.Alarm PumpHistoryEntryGroup.Alarm
OmnipodCommandType.PLAY_TEST_BEEP -> OmnipodCommandType.PLAY_TEST_BEEP ->
PumpHistoryEntryGroup.Alarm PumpHistoryEntryGroup.Alarm
OmnipodCommandType.GET_POD_STATUS -> OmnipodCommandType.GET_POD_STATUS ->
PumpHistoryEntryGroup.Configuration PumpHistoryEntryGroup.Configuration
OmnipodCommandType.SET_TIME -> OmnipodCommandType.SET_TIME ->
PumpHistoryEntryGroup.Configuration PumpHistoryEntryGroup.Configuration
OmnipodCommandType.READ_POD_PULSE_LOG -> OmnipodCommandType.READ_POD_PULSE_LOG ->
PumpHistoryEntryGroup.Unknown PumpHistoryEntryGroup.Unknown
} }
} }
@ -209,7 +209,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
private fun setTextViewColor(check_result: Boolean, textview: TextView, record: HistoryRecord) { private fun setTextViewColor(check_result: Boolean, textview: TextView, record: HistoryRecord) {
if (check_result && !record.isSuccess()) { if (check_result && !record.isSuccess()) {
// Record says not success // Record says not success
textview.setTextColor(rh.gac( textview.context, R.attr.omniYellowColor)) textview.setTextColor(rh.gac(textview.context, R.attr.omniYellowColor))
return return
} }
// On success set color // On success set color
@ -222,13 +222,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
OmnipodCommandType.DISCARD_POD, OmnipodCommandType.DISCARD_POD,
OmnipodCommandType.SUSPEND_DELIVERY, OmnipodCommandType.SUSPEND_DELIVERY,
OmnipodCommandType.RESUME_DELIVERY, OmnipodCommandType.RESUME_DELIVERY,
OmnipodCommandType.SET_BASAL_PROFILE -> { OmnipodCommandType.SET_BASAL_PROFILE -> {
R.attr.omniCyanColor R.attr.omniCyanColor
} }
// User action // User action
OmnipodCommandType.PLAY_TEST_BEEP, OmnipodCommandType.PLAY_TEST_BEEP,
OmnipodCommandType.ACKNOWLEDGE_ALERTS, OmnipodCommandType.ACKNOWLEDGE_ALERTS,
OmnipodCommandType.CANCEL_BOLUS -> { OmnipodCommandType.CANCEL_BOLUS -> {
R.attr.omniCyanColor R.attr.omniCyanColor
} }
// Insulin treatment // Insulin treatment
@ -237,11 +237,11 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
R.attr.defaultTextColor R.attr.defaultTextColor
} }
else -> else ->
// Other // Other
R.attr.omniGrayColor R.attr.omniGrayColor
} }
textview.setTextColor(rh.gac( textview.context, textColorAttr)) textview.setTextColor(rh.gac(textview.context, textColorAttr))
} }
private fun setType(record: HistoryRecord, typeView: TextView) { private fun setType(record: HistoryRecord, typeView: TextView) {
@ -265,7 +265,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
} }
OmnipodCommandType.SET_BOLUS -> { OmnipodCommandType.SET_BOLUS -> {
val bolus = historyEntry.record as BolusRecord val bolus = historyEntry.record as BolusRecord
bolus.let { bolus.let {
rh.gs(R.string.omnipod_common_history_bolus_value, it.amout) rh.gs(R.string.omnipod_common_history_bolus_value, it.amout)
@ -275,12 +275,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
OmnipodCommandType.SET_BASAL_PROFILE, OmnipodCommandType.SET_BASAL_PROFILE,
OmnipodCommandType.SET_TIME, OmnipodCommandType.SET_TIME,
OmnipodCommandType.INSERT_CANNULA, OmnipodCommandType.INSERT_CANNULA,
OmnipodCommandType.RESUME_DELIVERY -> { OmnipodCommandType.RESUME_DELIVERY -> {
val basal = historyEntry.record as BasalValuesRecord val basal = historyEntry.record as BasalValuesRecord
ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH) ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH)
} }
else -> else ->
"" ""
} }
// Set some color // Set some color
@ -303,12 +303,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
return when { return when {
historyEntry.initialResult == InitialResult.FAILURE_SENDING -> historyEntry.initialResult == InitialResult.FAILURE_SENDING ->
R.string.omnipod_dash_failed_to_send R.string.omnipod_dash_failed_to_send
historyEntry.initialResult == InitialResult.NOT_SENT -> historyEntry.initialResult == InitialResult.NOT_SENT ->
R.string.omnipod_dash_command_not_sent R.string.omnipod_dash_command_not_sent
historyEntry.initialResult == InitialResult.SENT && historyEntry.initialResult == InitialResult.SENT &&
historyEntry.resolvedResult == ResolvedResult.FAILURE -> historyEntry.resolvedResult == ResolvedResult.FAILURE ->
R.string.omnipod_dash_command_not_received_by_the_pod R.string.omnipod_dash_command_not_received_by_the_pod
else -> else ->
R.string.omnipod_dash_unknown R.string.omnipod_dash_unknown
} }
} }

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.R

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui
import android.content.Intent import android.content.Intent
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
@ -16,6 +15,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
@ -41,10 +41,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.androidaps.utils.ui.UIRunnable import info.nightscout.androidaps.utils.ui.UIRunnable
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.StringUtils
@ -117,7 +116,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
protectionCheck.queryProtection( protectionCheck.queryProtection(
activity, activity,
ProtectionCheck.Protection.PREFERENCES, ProtectionCheck.Protection.PREFERENCES,
UIRunnable { startActivity(Intent(context, DashPodManagementActivity::class.java)) }) UIRunnable { startActivity(Intent(context, DashPodManagementActivity::class.java)) }
)
} }
} }
@ -267,14 +267,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
val quality = val quality =
"${podStateManager.successfulConnectionAttemptsAfterRetries}/$connectionAttempts :: $successPercentageString" "${podStateManager.successfulConnectionAttemptsAfterRetries}/$connectionAttempts :: $successPercentageString"
bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.text = quality bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.text = quality
val connectionStatsColor = rh.gac( context, when { val connectionStatsColor = rh.gac(
connectionSuccessPercentage < 70 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 -> context,
R.attr.warningColor when {
connectionSuccessPercentage < 90 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 -> connectionSuccessPercentage < 70 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 ->
R.attr.omniYellowColor R.attr.warningColor
else -> connectionSuccessPercentage < 90 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 ->
R.attr.defaultTextColor R.attr.omniYellowColor
}) else ->
R.attr.defaultTextColor
}
)
bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.setTextColor(connectionStatsColor) bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.setTextColor(connectionStatsColor)
bluetoothStatusBinding.omnipodDashDeliveryStatus.text = podStateManager.deliveryStatus?.let { bluetoothStatusBinding.omnipodDashDeliveryStatus.text = podStateManager.deliveryStatus?.let {
podStateManager.deliveryStatus.toString() podStateManager.deliveryStatus.toString()
@ -296,11 +299,11 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
podInfoBinding.firmwareVersion.text = PLACEHOLDER podInfoBinding.firmwareVersion.text = PLACEHOLDER
podInfoBinding.timeOnPod.text = PLACEHOLDER podInfoBinding.timeOnPod.text = PLACEHOLDER
podInfoBinding.podExpiryDate.text = PLACEHOLDER podInfoBinding.podExpiryDate.text = PLACEHOLDER
podInfoBinding.podExpiryDate.setTextColor(rh.gac(context,R.attr.defaultTextColor)) podInfoBinding.podExpiryDate.setTextColor(rh.gac(context, R.attr.defaultTextColor))
podInfoBinding.baseBasalRate.text = PLACEHOLDER podInfoBinding.baseBasalRate.text = PLACEHOLDER
podInfoBinding.totalDelivered.text = PLACEHOLDER podInfoBinding.totalDelivered.text = PLACEHOLDER
podInfoBinding.reservoir.text = PLACEHOLDER podInfoBinding.reservoir.text = PLACEHOLDER
podInfoBinding.reservoir.setTextColor(rh.gac(context,R.attr.defaultTextColor)) podInfoBinding.reservoir.setTextColor(rh.gac(context, R.attr.defaultTextColor))
podInfoBinding.podActiveAlerts.text = PLACEHOLDER podInfoBinding.podActiveAlerts.text = PLACEHOLDER
} else { } else {
podInfoBinding.uniqueId.text = podStateManager.uniqueId.toString() podInfoBinding.uniqueId.text = podStateManager.uniqueId.toString()
@ -335,15 +338,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
).isNegative ).isNegative
} ?: false } ?: false
podInfoBinding.timeOnPod.setTextColor( podInfoBinding.timeOnPod.setTextColor(
rh.gac( context, rh.gac(
when { context,
!podStateManager.sameTimeZone -> when {
R.attr.omniMagentaColor !podStateManager.sameTimeZone ->
timeDeviationTooBig -> R.attr.omniMagentaColor
R.attr.omniYellowColor timeDeviationTooBig ->
else -> R.attr.omniYellowColor
R.attr.defaultTextColor else ->
}) R.attr.defaultTextColor
}
)
) )
// Update Pod expiry time // Update Pod expiry time
@ -353,15 +358,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
} }
?: PLACEHOLDER ?: PLACEHOLDER
podInfoBinding.podExpiryDate.setTextColor( podInfoBinding.podExpiryDate.setTextColor(
rh.gac( context, rh.gac(
when { context,
expiresAt != null && ZonedDateTime.now().isAfter(expiresAt) -> when {
R.attr.warningColor expiresAt != null && ZonedDateTime.now().isAfter(expiresAt) ->
expiresAt != null && ZonedDateTime.now().isAfter(expiresAt.minusHours(4)) -> R.attr.warningColor
R.attr.omniYellowColor expiresAt != null && ZonedDateTime.now().isAfter(expiresAt.minusHours(4)) ->
else -> R.attr.omniYellowColor
R.attr.defaultTextColor else ->
}) R.attr.defaultTextColor
}
)
) )
podStateManager.alarmType?.let { podStateManager.alarmType?.let {
@ -401,7 +408,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
if (podStateManager.pulsesRemaining == null) { if (podStateManager.pulsesRemaining == null) {
podInfoBinding.reservoir.text = podInfoBinding.reservoir.text =
rh.gs(R.string.omnipod_common_overview_reservoir_value_over50) rh.gs(R.string.omnipod_common_overview_reservoir_value_over50)
podInfoBinding.reservoir.setTextColor(rh.gac(context,R.attr.defaultTextColor)) podInfoBinding.reservoir.setTextColor(rh.gac(context, R.attr.defaultTextColor))
} else { } else {
// TODO // TODO
// val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits // val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits
@ -413,12 +420,14 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
(podStateManager.pulsesRemaining!! * PodConstants.POD_PULSE_BOLUS_UNITS) (podStateManager.pulsesRemaining!! * PodConstants.POD_PULSE_BOLUS_UNITS)
) )
podInfoBinding.reservoir.setTextColor( podInfoBinding.reservoir.setTextColor(
rh.gac(context, rh.gac(
if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) { context,
R.attr.warningColor if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) {
} else { R.attr.warningColor
R.attr.defaultTextColor } else {
}) R.attr.defaultTextColor
}
)
) )
} }
@ -429,10 +438,10 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
if (errors.size == 0) { if (errors.size == 0) {
podInfoBinding.errors.text = PLACEHOLDER podInfoBinding.errors.text = PLACEHOLDER
podInfoBinding.errors.setTextColor(rh.gac(context,R.attr.defaultTextColor)) podInfoBinding.errors.setTextColor(rh.gac(context, R.attr.defaultTextColor))
} else { } else {
podInfoBinding.errors.text = StringUtils.join(errors, System.lineSeparator()) podInfoBinding.errors.text = StringUtils.join(errors, System.lineSeparator())
podInfoBinding.errors.setTextColor(rh.gac(context,R.attr.warningColor)) podInfoBinding.errors.setTextColor(rh.gac(context, R.attr.warningColor))
} }
} }
@ -468,15 +477,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
) )
) )
val lastConnectionColor = val lastConnectionColor =
rh.gac(context, rh.gac(
if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().toMillis())) { context,
R.attr.warningColor if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().toMillis())) {
} else { R.attr.warningColor
R.attr.defaultTextColor } else {
}) R.attr.defaultTextColor
}
)
podInfoBinding.lastConnection.setTextColor(lastConnectionColor) podInfoBinding.lastConnection.setTextColor(lastConnectionColor)
} else { } else {
podInfoBinding.lastConnection.setTextColor(rh.gac(context,R.attr.defaultTextColor )) podInfoBinding.lastConnection.setTextColor(rh.gac(context, R.attr.defaultTextColor))
podInfoBinding.lastConnection.text = PLACEHOLDER podInfoBinding.lastConnection.text = PLACEHOLDER
} }
} }
@ -512,14 +523,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
} }
} }
val podStatusColor = rh.gac( context, when { val podStatusColor = rh.gac(
!podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended -> context,
R.attr.warningColor when {
podStateManager.activeCommand != null -> !podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended ->
R.attr.omniYellowColor R.attr.warningColor
else -> podStateManager.activeCommand != null ->
R.attr.defaultTextColor R.attr.omniYellowColor
}) else ->
R.attr.defaultTextColor
}
)
podInfoBinding.podStatus.setTextColor(podStatusColor) podInfoBinding.podStatus.setTextColor(podStatusColor)
} }

View file

@ -13,5 +13,5 @@ class DashPodActivationWizardActivity : PodActivationWizardActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
blePreCheck.prerequisitesCheck(this) blePreCheck.prerequisitesCheck(this)
} }
} }

View file

@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activatio
import androidx.annotation.StringRes import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InitializePodViewModel import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InitializePodViewModel
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
@ -15,8 +14,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.InitialResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.InitialResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.ResolvedResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.ResolvedResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign

View file

@ -6,8 +6,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
@ -25,8 +24,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.Constants
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign

View file

@ -4,7 +4,6 @@ import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
@ -14,6 +13,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.deactiva
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.util package info.nightscout.androidaps.plugins.pump.omnipod.dash.util
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.FailedToConnectException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.FailedToConnectException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.NotConnectedException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.NotConnectedException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException
import info.nightscout.androidaps.interfaces.ResourceHelper
class I8n { class I8n {
companion object { companion object {

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLoggerTest
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
import info.nightscout.shared.logging.AAPSLoggerTest
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.spongycastle.util.encoders.Hex import org.spongycastle.util.encoders.Hex

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
import com.google.crypto.tink.subtle.Hex import com.google.crypto.tink.subtle.Hex
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLoggerTest
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
import info.nightscout.shared.logging.AAPSLoggerTest
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.shared.logging.AAPSLoggerTest
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator
import info.nightscout.shared.logging.AAPSLoggerTest
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test
import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyInt