ktlintFormat

This commit is contained in:
Andrei Vereha 2021-05-02 10:38:22 +02:00
parent dd8ebded1a
commit 976ae45057
20 changed files with 95 additions and 86 deletions

View file

@ -132,8 +132,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
},
onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error in setNewBasalProfile", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()))
source.onSuccess(
PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()
)
)
},
onComplete = {
aapsLogger.debug("setNewBasalProfile completed")
@ -147,7 +150,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
it == mapProfileToBasalProgram(profile)
} ?: true
override fun lastDataTime(): Long {
return podStateManager.lastConnection
}
@ -193,8 +195,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
},
onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error in deliverTreatment", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()))
source.onSuccess(
PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()
)
)
},
onComplete = {
aapsLogger.debug("deliverTreatment completed")
@ -250,8 +255,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
},
onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error in setTempBasalAbsolute", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()))
source.onSuccess(
PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()
)
)
},
onComplete = {
aapsLogger.debug("setTempBasalAbsolute completed")
@ -296,8 +304,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
},
onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error in cancelTempBasal", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()))
source.onSuccess(
PumpEnactResult(injector).success(false).enacted(false).comment(
throwable.toString()
)
)
},
onComplete = {
aapsLogger.debug("cancelTempBasal completed")
@ -408,8 +419,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
},
onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error in silenceAlerts", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).comment(
throwable.toString()))
source.onSuccess(
PumpEnactResult(injector).success(false).comment(
throwable.toString()
)
)
},
onComplete = {
aapsLogger.debug("silenceAlerts completed")
@ -515,8 +529,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
},
onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error in playTestBeep", throwable)
source.onSuccess(PumpEnactResult(injector).success(false).enacted(false)
.comment(throwable.toString()))
source.onSuccess(
PumpEnactResult(injector).success(false).enacted(false)
.comment(throwable.toString())
)
},
onComplete = {
aapsLogger.debug("playTestBeep completed")

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm
import info.nightscout.androidaps.extensions.toHex
import java.nio.ByteBuffer
data class Id(val address: ByteArray) {
init {
require(address.size == 4)

View file

@ -17,4 +17,4 @@ class Ids(podState: OmnipodDashPodStateManager) {
)
}
}
}
}

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager
import android.content.Context
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
@ -15,7 +16,6 @@ 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.response.Response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.androidaps.extensions.toHex
import io.reactivex.Observable
import java.util.concurrent.atomic.AtomicBoolean
import javax.inject.Inject
@ -83,7 +83,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
val conn = assertConnected()
return conn.session
?: throw NotConnectedException("Missing session")
}
}
override fun getStatus(): ConnectionStatus {
// TODO is this used?

View file

@ -5,12 +5,12 @@ import android.bluetooth.BluetoothGattCallback
import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor
import android.bluetooth.BluetoothProfile
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.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.IncomingPackets
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.DisconnectHandler
import info.nightscout.androidaps.extensions.toHex
import java.util.*
import java.util.concurrent.BlockingQueue
import java.util.concurrent.CountDownLatch

View file

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

View file

@ -5,13 +5,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.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.WriteConfirmationError
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationSuccess
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.*
import info.nightscout.androidaps.extensions.toHex
import java.util.concurrent.BlockingQueue
import java.util.concurrent.TimeUnit

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.*
@ -7,7 +8,6 @@ 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.PayloadJoiner
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter
import info.nightscout.androidaps.extensions.toHex
sealed class MessageSendResult
object MessageSendSuccess : MessageSendResult()

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import java.nio.ByteBuffer
/***

View file

@ -42,7 +42,7 @@ class PayloadJoiner(private val firstPacket: ByteArray) {
oneExtraPacket = lastPacket.oneExtraPacket
}
idx == fullFragments+1 && oneExtraPacket -> {
idx == fullFragments + 1 && oneExtraPacket -> {
fragments.add(LastOptionalPlusOneBlePacket.parse(packet))
}

View file

@ -1,12 +1,12 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
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.pod.util.RandomByteGenerator
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator
import info.nightscout.androidaps.extensions.toHex
import org.spongycastle.crypto.engines.AESEngine
import org.spongycastle.crypto.macs.CMac
import org.spongycastle.crypto.params.KeyParameter

View file

@ -1,21 +1,18 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
import info.nightscout.androidaps.extensions.hexStringToByteArray
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
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.PairingException
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageIO
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageSendErrorSending
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageSendSuccess
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding
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.X25519KeyGenerator
import info.nightscout.androidaps.extensions.hexStringToByteArray
import info.nightscout.androidaps.extensions.toHex
internal class LTKExchanger(
private val aapsLogger: AAPSLogger,
@ -35,7 +32,7 @@ internal class LTKExchanger(
keys = arrayOf(SP1, SP2),
payloads = arrayOf(ids.podId.address, sp2())
)
throwOnSendError(sp1sp2.messagePacket, SP1+SP2)
throwOnSendError(sp1sp2.messagePacket, SP1 + SP2)
seq++
val sps1 = PairMessage(
@ -67,16 +64,16 @@ internal class LTKExchanger(
seq++
// send SP0GP0
val sp0gp0 = PairMessage (
sequenceNumber = seq,
source = ids.myId,
destination = podAddress,
keys = arrayOf(SP0GP0),
payloads = arrayOf(ByteArray(0))
)
val sp0gp0 = PairMessage(
sequenceNumber = seq,
source = ids.myId,
destination = podAddress,
keys = arrayOf(SP0GP0),
payloads = arrayOf(ByteArray(0))
)
val result = msgIO.sendMessage(sp0gp0.messagePacket)
if (result !is MessageSendSuccess) {
aapsLogger.warn(LTag.PUMPBTCOMM,"Error sending SP0GP0: $result")
aapsLogger.warn(LTag.PUMPBTCOMM, "Error sending SP0GP0: $result")
}
msgIO.receiveMessage()
@ -97,7 +94,6 @@ internal class LTKExchanger(
}
}
private fun processSps1FromPod(msg: MessagePacket) {
aapsLogger.debug(LTag.PUMPBTCOMM, "Received SPS1 from pod: ${msg.payload.toHex()}")

View file

@ -5,6 +5,7 @@ import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothManager
import android.bluetooth.BluetoothProfile
import android.content.Context
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
@ -19,7 +20,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CmdBl
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.DataBleIO
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.extensions.toHex
sealed class ConnectionState

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import info.nightscout.androidaps.extensions.toHex
import java.util.*
enum class EapAkaAttributeType(val type: Byte) {

View file

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

View file

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

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
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.exceptions.CouldNotParseResponseException
@ -16,7 +16,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.NakResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response
import info.nightscout.androidaps.extensions.toHex
import kotlin.reflect.KClass
sealed class CommandSendResult

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
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.exceptions.SessionEstablishmentException
@ -10,7 +10,6 @@ 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.MessageSendSuccess
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageType
import info.nightscout.androidaps.extensions.toHex
import java.security.SecureRandom
import java.util.*

View file

@ -6,6 +6,7 @@ import android.os.Bundle
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep
@ -20,7 +21,6 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.events.EventQueueChanged
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign

View file

@ -28,25 +28,25 @@ class DefaultStatusResponseTest {
/**
* response (hex) 08202EAA0C0A1D1905281000004387D3039A
Status response: 29
Pod status: RUNNING_BELOW_MIN_VOLUME
Basal active: true
Temp Basal active: false
Immediate bolus active: false
Extended bolus active: false
Bolus pulses remaining: 0
sequence number of last programing command: 2
Total full pulses delivered: 2640
Full reservoir pulses remaining: 979
Time since activation: 4321
Alert 1 is InActive
Alert 2 is InActive
Alert 3 is InActive
Alert 4 is InActive
Alert 5 is InActive
Alert 6 is InActive
Alert 7 is InActive
Occlusion alert active false
Status response: 29
Pod status: RUNNING_BELOW_MIN_VOLUME
Basal active: true
Temp Basal active: false
Immediate bolus active: false
Extended bolus active: false
Bolus pulses remaining: 0
sequence number of last programing command: 2
Total full pulses delivered: 2640
Full reservoir pulses remaining: 979
Time since activation: 4321
Alert 1 is InActive
Alert 2 is InActive
Alert 3 is InActive
Alert 4 is InActive
Alert 5 is InActive
Alert 6 is InActive
Alert 7 is InActive
Occlusion alert active false
*/
@Test @Throws(DecoderException::class) fun testValidResponseBelowMin() {
val encoded = Hex.decodeHex("1D1905281000004387D3039A")
@ -67,25 +67,25 @@ class DefaultStatusResponseTest {
/**
* response (hex) 08202EAA080A1D180519C00E0039A7FF8085
Status response: 29
Pod status: RUNNING_ABOVE_MIN_VOLUME
Basal active: true
Temp Basal active: false
Immediate bolus active: false
Extended bolus active: false
Bolus pulses remaining: 14
sequence number of last programing command: 8
Total full pulses delivered: 2611
Full reservoir pulses remaining: 1023
Time since activation: 3689
Alert 1 is InActive
Alert 2 is InActive
Alert 3 is InActive
Alert 4 is InActive
Alert 5 is InActive
Alert 6 is InActive
Alert 7 is InActive
Occlusion alert active false
Status response: 29
Pod status: RUNNING_ABOVE_MIN_VOLUME
Basal active: true
Temp Basal active: false
Immediate bolus active: false
Extended bolus active: false
Bolus pulses remaining: 14
sequence number of last programing command: 8
Total full pulses delivered: 2611
Full reservoir pulses remaining: 1023
Time since activation: 3689
Alert 1 is InActive
Alert 2 is InActive
Alert 3 is InActive
Alert 4 is InActive
Alert 5 is InActive
Alert 6 is InActive
Alert 7 is InActive
Occlusion alert active false
*/
@Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining() {
val encoded = Hex.decodeHex("1D180519C00E0039A7FF8085")