From 59bfa7a04da295eb410b7aace334bde2f76b8376 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 1 Mar 2021 01:23:40 +0100 Subject: [PATCH 1/7] Implement Pod activation command flow --- .../omnipod/dash/driver/OmnipodDashManager.kt | 5 +- .../dash/driver/OmnipodDashManagerImpl.kt | 287 ++++++++++++++++-- .../pod/definition/ActivationProgress.kt | 3 +- .../pod/state/OmnipodDashPodStateManager.kt | 2 +- .../state/OmnipodDashPodStateManagerImpl.kt | 14 +- .../action/DashInitializePodViewModel.kt | 4 +- .../action/DashInsertCannulaViewModel.kt | 24 +- 7 files changed, 313 insertions(+), 26 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt index c567702331..4d7523eff6 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import io.reactivex.Observable @@ -9,9 +10,9 @@ import java.util.* interface OmnipodDashManager { - fun activatePodPart1(): Observable + fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable - fun activatePodPart2(): Observable + fun activatePodPart2(basalProgram: BasalProgram): Observable fun getStatus(): Observable diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt index 8426a62e07..884e755db7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt @@ -4,21 +4,15 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag 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.pod.command.GetVersionCommand +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.GetVersionCommand.Companion.DEFAULT_UNIQUE_ID -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response -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.definition.* +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.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.retryWithBackoff import io.reactivex.Observable +import io.reactivex.functions.Action import io.reactivex.functions.Consumer import java.util.* import java.util.concurrent.TimeUnit @@ -42,9 +36,109 @@ class OmnipodDashManagerImpl @Inject constructor( } } + private val observePodReadyForActivationPart2: Observable + get() = Observable.defer { + if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) && podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED)) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Pod is in an incorrect state")) + } + } + private val observeConnectToPod: Observable get() = Observable.defer { bleManager.connect().retryWithBackoff(retries = 2, delay = 3, timeUnit = TimeUnit.SECONDS) } // TODO are these reasonable values? + private fun observeSendProgramBolusCommand(units: Double, rateInEighthPulsesPerSeconds: Byte, confirmationBeeps: Boolean, completionBeeps: Boolean): Observable { + return Observable.defer { + bleManager.sendCommand(ProgramBolusCommand.Builder() + .setUniqueId(podStateManager.uniqueId!!.toInt()) + .setSequenceNumber(podStateManager.messageSequenceNumber) + .setNonce(1229869870) // TODO + .setNumberOfUnits(units) + .setDelayBetweenPulsesInEighthSeconds(rateInEighthPulsesPerSeconds) + .setProgramReminder(ProgramReminder(confirmationBeeps, completionBeeps, 0)) + .build() + ) + } + } + + private fun observeSendGetPodStatusCommand(type: ResponseType.StatusResponseType = ResponseType.StatusResponseType.DEFAULT_STATUS_RESPONSE): Observable { + return Observable.defer { + bleManager.sendCommand( + GetStatusCommand.Builder() + .setUniqueId(podStateManager.uniqueId!!.toInt()) + .setSequenceNumber(podStateManager.messageSequenceNumber) + .setStatusResponseType(type) + .build() + ) + } + } + + private val observeVerifyCannulaInsertion: Observable + get() = Observable.defer { + observeSendGetPodStatusCommand() + .ignoreElements() // + .andThen(Observable.defer { + if (podStateManager.podStatus == PodStatus.RUNNING_ABOVE_MIN_VOLUME) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Unexpected Pod status")) + } + }) + } + + private fun observeSendProgramAlertsCommand(alertConfigurations: List, multiCommandFlag: Boolean = false): Observable { + return Observable.defer { + bleManager.sendCommand( + ProgramAlertsCommand.Builder() + .setUniqueId(podStateManager.uniqueId!!.toInt()) + .setSequenceNumber(podStateManager.messageSequenceNumber) + .setNonce(1229869870) // TODO + .setAlertConfigurations(alertConfigurations) + .build() + ) + } + } + + private fun observeProgramBasalCommand(basalProgram: BasalProgram): Observable { + return Observable.defer { + bleManager.sendCommand( + ProgramBasalCommand.Builder() + .setUniqueId(podStateManager.uniqueId!!.toInt()) + .setSequenceNumber(podStateManager.messageSequenceNumber) + .setNonce(1229869870) // TODO + .setProgramReminder(ProgramReminder(atStart = false, atEnd = false, atInterval = 0)) + .setBasalProgram(basalProgram) + .setCurrentTime(Date()) + .build() + ) + } + } + + private val observeVerifyPrime: Observable + get() = Observable.defer { + observeSendGetPodStatusCommand() + .ignoreElements() // + .andThen(Observable.defer { + if (podStateManager.podStatus == PodStatus.CLUTCH_DRIVE_ENGAGED) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Unexpected Pod status")) + } + }) + } + + private val observeSendSetUniqueIdCommand: Observable + get() = Observable.defer { + bleManager.sendCommand(SetUniqueIdCommand.Builder() // + .setSequenceNumber(podStateManager.messageSequenceNumber) // + .setUniqueId(podStateManager.uniqueId!!.toInt()) // + .setLotNumber(podStateManager.lotNumber!!.toInt()) // + .setPodSequenceNumber(podStateManager.podSequenceNumber!!.toInt()) + .setInitializationTime(Date()) + .build()) // + } + private val observeSendGetVersionCommand: Observable get() = Observable.defer { bleManager.sendCommand(GetVersionCommand.Builder() // @@ -53,22 +147,169 @@ class OmnipodDashManagerImpl @Inject constructor( .build()) // } - override fun activatePodPart1(): Observable { + override fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable { return Observable.concat( observePodReadyForActivationPart1, observeConnectToPod, - observeSendGetVersionCommand - // ... Send more commands - ) // + observeActivationPart1Commands(lowReservoirAlertTrigger) + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.PHASE_1_COMPLETED)) // TODO these would be common for any observable returned in a public function in this class .doOnNext(PodEventInterceptor()) // .doOnError(ErrorInterceptor()) .subscribeOn(aapsSchedulers.io) } - override fun activatePodPart2(): Observable { - // TODO - return Observable.empty() + private fun observeActivationPart1Commands(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable { + val observables = createActivationPart1Observables(lowReservoirAlertTrigger) + + return if (observables.isEmpty()) { + Observable.empty() + } else { + Observable.concat(observables) + } + } + + private fun createActivationPart1Observables(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): List> { + val observables = ArrayList>() + + if (podStateManager.activationProgress.isBefore(ActivationProgress.PRIME_COMPLETED)) { + observables.add( + observeVerifyPrime.doOnComplete(ActivationProgressUpdater(ActivationProgress.PRIME_COMPLETED)) + ) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.PRIMING)) { + observables.add( + observeSendProgramBolusCommand( + podStateManager.firstPrimeBolusVolume!! * 0.05, + podStateManager.primePulseRate!!.toByte(), + confirmationBeeps = false, + completionBeeps = false + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.PRIMING)) + ) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.REPROGRAMMED_LUMP_OF_COAL_ALERT)) { + observables.add( + observeSendProgramAlertsCommand( + listOf( + AlertConfiguration( + AlertType.EXPIRATION, + enabled = true, + durationInMinutes = 55, + autoOff = false, + AlertTrigger.TimerTrigger(5), + BeepType.FOUR_TIMES_BIP_BEEP, + BeepRepetitionType.XXX5 + ) + ) + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.REPROGRAMMED_LUMP_OF_COAL_ALERT)) + ) + } + if (lowReservoirAlertTrigger != null && podStateManager.activationProgress.isBefore(ActivationProgress.PROGRAMMED_LOW_RESERVOIR_ALERTS)) { + observables.add( + observeSendProgramAlertsCommand( + listOf( + AlertConfiguration( + AlertType.LOW_RESERVOIR, + enabled = true, + durationInMinutes = 0, + autoOff = false, + lowReservoirAlertTrigger, + BeepType.FOUR_TIMES_BIP_BEEP, + BeepRepetitionType.XXX + ) + ) + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.PROGRAMMED_LOW_RESERVOIR_ALERTS)) + ) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.SET_UNIQUE_ID)) { + observables.add( + observeSendSetUniqueIdCommand.doOnComplete(ActivationProgressUpdater(ActivationProgress.SET_UNIQUE_ID)) + ) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.GOT_POD_VERSION)) { + observables.add( + observeSendGetVersionCommand.doOnComplete(ActivationProgressUpdater(ActivationProgress.GOT_POD_VERSION)) + ) + } + + return observables.reversed() + } + + override fun activatePodPart2(basalProgram: BasalProgram): Observable { + return Observable.concat( + observePodReadyForActivationPart2, + observeConnectToPod, + observeActivationPart2Commands(basalProgram) + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.COMPLETED)) + // TODO these would be common for any observable returned in a public function in this class + .doOnNext(PodEventInterceptor()) // + .doOnError(ErrorInterceptor()) + .subscribeOn(aapsSchedulers.io) + } + + private fun observeActivationPart2Commands(basalProgram: BasalProgram): Observable { + val observables = createActivationPart2Observables(basalProgram) + + return if (observables.isEmpty()) { + Observable.empty() + } else { + Observable.concat(observables) + } + } + + private fun createActivationPart2Observables(basalProgram: BasalProgram): List> { + val observables = ArrayList>() + + if (podStateManager.activationProgress.isBefore(ActivationProgress.CANNULA_INSERTED)) { + observables.add( + observeVerifyCannulaInsertion + .doOnComplete(ActivationProgressUpdater(ActivationProgress.CANNULA_INSERTED)) + ) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.INSERTING_CANNULA)) { + observables.add( + observeSendProgramBolusCommand( + podStateManager.secondPrimeBolusVolume!! * 0.05, + podStateManager.primePulseRate!!.toByte(), + confirmationBeeps = false, + completionBeeps = false + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.INSERTING_CANNULA)) + ) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.UPDATED_EXPIRATION_ALERTS)) { + observables.add(observeSendProgramAlertsCommand( + listOf( + // FIXME use user configured expiration alert + AlertConfiguration( + AlertType.EXPIRATION, + enabled = true, + durationInMinutes = TimeUnit.HOURS.toMinutes(7).toShort(), + autoOff = false, + AlertTrigger.TimerTrigger(TimeUnit.HOURS.toMinutes(73).toShort()), // FIXME use activation time + BeepType.FOUR_TIMES_BIP_BEEP, + BeepRepetitionType.XXX3 + ), + AlertConfiguration( + AlertType.EXPIRATION_IMMINENT, + enabled = true, + durationInMinutes = TimeUnit.HOURS.toMinutes(1).toShort(), + autoOff = false, + AlertTrigger.TimerTrigger(TimeUnit.HOURS.toMinutes(79).toShort()), // FIXME use activation time + BeepType.FOUR_TIMES_BIP_BEEP, + BeepRepetitionType.XXX4 + ) + ), + multiCommandFlag = true + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.UPDATED_EXPIRATION_ALERTS))) + } + if (podStateManager.activationProgress.isBefore(ActivationProgress.PROGRAMMED_BASAL)) { + observables.add( + observeProgramBasalCommand(basalProgram) + .doOnComplete(ActivationProgressUpdater(ActivationProgress.PROGRAMMED_BASAL)) + ) + } + + return observables.reversed() } override fun getStatus(): Observable { @@ -149,6 +390,10 @@ class OmnipodDashManagerImpl @Inject constructor( podStateManager.uniqueId = event.uniqueId } + is PodEvent.CommandSent -> { + podStateManager.increaseMessageSequenceNumber() + } + is PodEvent.ResponseReceived -> { podStateManager.increaseMessageSequenceNumber() handleResponse(event.response) @@ -189,4 +434,12 @@ class OmnipodDashManagerImpl @Inject constructor( } } + + inner class ActivationProgressUpdater(private val value: ActivationProgress) : Action { + + override fun run() { + podStateManager.activationProgress = value + } + + } } \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt index e43a277f2e..f9455e5528 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt @@ -8,10 +8,9 @@ enum class ActivationProgress { REPROGRAMMED_LUMP_OF_COAL_ALERT, PRIMING, PRIME_COMPLETED, - PROGRAMMED_USER_SET_EXPIRATION_ALERT, PHASE_1_COMPLETED, PROGRAMMED_BASAL, - PROGRAMMED_CANCEL_LOC_ETC_ALERT, + UPDATED_EXPIRATION_ALERTS, INSERTING_CANNULA, CANNULA_INSERTED, COMPLETED; diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt index b0a069b5bc..a97cad8974 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt @@ -21,7 +21,7 @@ interface OmnipodDashPodStateManager { val messageSequenceNumber: Short val sequenceNumberOfLastProgrammingCommand: Short? val activationTime: Long? - var uniqueId: Long? + var uniqueId: Long? // TODO make Int var bluetoothAddress: String? val bluetoothVersion: SoftwareVersion? diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index add92d9567..78254c74e8 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state import com.google.gson.Gson import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +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.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse @@ -18,7 +20,8 @@ import javax.inject.Singleton @Singleton class OmnipodDashPodStateManagerImpl @Inject constructor( private val logger: AAPSLogger, - private val sharedPreferences: SP + private val sharedPreferences: SP, + private val rxBus: RxBusWrapper ) : OmnipodDashPodStateManager { private var podState: PodState @@ -158,6 +161,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( podState.lastUpdated = System.currentTimeMillis() store() + rxBus.send(EventOmnipodDashPumpValuesChanged()) } override fun updateFromVersionResponse(response: VersionResponse) { @@ -169,6 +173,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( podState.lastUpdated = System.currentTimeMillis() store() + rxBus.send(EventOmnipodDashPumpValuesChanged()) } override fun updateFromSetUniqueIdResponse(response: SetUniqueIdResponse) { @@ -186,10 +191,15 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( podState.lastUpdated = System.currentTimeMillis() store() + rxBus.send(EventOmnipodDashPumpValuesChanged()) } override fun updateFromAlarmStatusResponse(response: AlarmStatusResponse) { - TODO("Not yet implemented") + // TODO + logger.error(LTag.PUMP, "Not implemented: OmnipodDashPodStateManagerImpl.updateFromAlarmStatusResponse(AlarmStatusResponse)") + + store() + rxBus.send(EventOmnipodDashPumpValuesChanged()) } override fun reset() { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt index dd2daa8e3b..ac3ea5f9d2 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt @@ -8,6 +8,7 @@ import info.nightscout.androidaps.logging.LTag 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.driver.OmnipodDashManager +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger import io.reactivex.Single import io.reactivex.rxkotlin.subscribeBy import javax.inject.Inject @@ -26,7 +27,8 @@ class DashInitializePodViewModel @Inject constructor( override fun doExecuteAction(): Single = Single.create { source -> - val disposable = omnipodManager.activatePodPart1().subscribeBy( + // TODO use configured value for low reservoir trigger + val disposable = omnipodManager.activatePodPart1(AlertTrigger.ReservoirVolumeTrigger(200)).subscribeBy( onNext = { podEvent -> logger.debug(LTag.PUMP, "Received PodEvent in Pod activation part 1: $podEvent") }, onError = { throwable -> logger.error(LTag.PUMP, "Error in Pod activation part 1", throwable) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt index 0b5ef6bc66..fc6c428ca2 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt @@ -5,12 +5,17 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InsertCannulaViewModel import info.nightscout.androidaps.plugins.pump.omnipod.dash.R +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager +import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram import io.reactivex.Single +import io.reactivex.rxkotlin.subscribeBy import javax.inject.Inject class DashInsertCannulaViewModel @Inject constructor( + private val omnipodManager: OmnipodDashManager, private val profileFunction: ProfileFunction, injector: HasAndroidInjector, logger: AAPSLogger @@ -22,7 +27,24 @@ class DashInsertCannulaViewModel @Inject constructor( override fun isPodDeactivatable(): Boolean = true // TODO - override fun doExecuteAction(): Single = Single.just(PumpEnactResult(injector).success(false).comment("TODO")) // TODO + override fun doExecuteAction(): Single = Single.create { source -> + val profile = profileFunction.getProfile() + if (profile == null) { + source.onError(IllegalStateException("No profile set")) + } else { + val disposable = omnipodManager.activatePodPart2(mapProfileToBasalProgram(profile)).subscribeBy( + onNext = { podEvent -> logger.debug(LTag.PUMP, "Received PodEvent in Pod activation part 2: $podEvent") }, + onError = { throwable -> + logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable) + source.onSuccess(PumpEnactResult(injector).success(false).comment(throwable.message)) + }, + onComplete = { + logger.debug("Pod activation part 2 completed") + source.onSuccess(PumpEnactResult(injector).success(true)) + } + ) + } + } @StringRes override fun getTitleId(): Int = R.string.omnipod_common_pod_activation_wizard_insert_cannula_title From 070ba1cfc2722323df85d984d68a78de2b0acb30 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 1 Mar 2021 12:34:47 +0100 Subject: [PATCH 2/7] add ktlint and detekt --- build.gradle | 5 + gradle/wrapper/gradle-wrapper.properties | 2 +- omnipod-dash/build.gradle | 7 + omnipod-dash/detekt-config.yml | 689 +++++++++++++++++++++++ 4 files changed, 702 insertions(+), 1 deletion(-) create mode 100644 omnipod-dash/detekt-config.yml diff --git a/build.gradle b/build.gradle index fd870b3ad6..c335d90c7a 100644 --- a/build.gradle +++ b/build.gradle @@ -58,6 +58,11 @@ buildscript { } } +plugins { + id "io.gitlab.arturbosch.detekt" version "1.15.0-RC2" + id "org.jlleitschuh.gradle.ktlint" version "9.4.1" +} + allprojects { repositories { google() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9a5b8e899d..a4d9e76064 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip diff --git a/omnipod-dash/build.gradle b/omnipod-dash/build.gradle index bf7d1c99c1..9d48cfa1c1 100644 --- a/omnipod-dash/build.gradle +++ b/omnipod-dash/build.gradle @@ -2,6 +2,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'com.hiya.jacoco-android' +apply plugin: "io.gitlab.arturbosch.detekt" // TODO move to `subprojects` section in global build.gradle +apply plugin: "org.jlleitschuh.gradle.ktlint" // TODO move to `subprojects` section in global build.gradle apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle" @@ -14,6 +16,11 @@ android { } } +detekt { // TODO move to `subprojects` section in global build.gradle + toolVersion = "1.15.0-RC2" + config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml" +} + dependencies { implementation project(':core') implementation project(':omnipod-common') diff --git a/omnipod-dash/detekt-config.yml b/omnipod-dash/detekt-config.yml new file mode 100644 index 0000000000..60e3fee286 --- /dev/null +++ b/omnipod-dash/detekt-config.yml @@ -0,0 +1,689 @@ +build: + maxIssues: 0 + excludeCorrectable: false + weights: + # complexity: 2 + # LongParameterList: 1 + # style: 1 + # comments: 1 + +config: + validation: true + warningsAsErrors: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' + +processors: + active: true + exclude: + - 'DetektProgressListener' + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ClassCountProcessor' + # - 'PackageCountProcessor' + # - 'KtFileCountProcessor' + +console-reports: + active: true + exclude: + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + # - 'FindingsReport' + - 'FileBasedFindingsReport' + +output-reports: + active: true + exclude: + # - 'TxtOutputReport' + # - 'XmlOutputReport' + # - 'HtmlOutputReport' + +comments: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + AbsentOrWrongFileLicense: + active: false + licenseTemplateFile: 'license.template' + CommentOverPrivateFunction: + active: false + CommentOverPrivateProperty: + active: false + EndOfSentenceFormat: + active: false + endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + UndocumentedPublicClass: + active: false + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + UndocumentedPublicFunction: + active: false + UndocumentedPublicProperty: + active: false + +complexity: + active: true + ComplexCondition: + active: true + threshold: 4 + ComplexInterface: + active: false + threshold: 10 + includeStaticDeclarations: false + includePrivateDeclarations: false + ComplexMethod: + active: true + threshold: 15 + ignoreSingleWhenExpression: false + ignoreSimpleWhenEntries: false + ignoreNestingFunctions: false + nestingFunctions: [run, let, apply, with, also, use, forEach, isNotNull, ifNull] + LabeledExpression: + active: false + ignoredLabels: [] + LargeClass: + active: true + threshold: 600 + LongMethod: + active: true + threshold: 60 + LongParameterList: + active: true + functionThreshold: 6 + constructorThreshold: 7 + ignoreDefaultParameters: false + ignoreDataClasses: true + ignoreAnnotated: [] + MethodOverloading: + active: false + threshold: 6 + NamedArguments: + active: false + threshold: 3 + NestedBlockDepth: + active: true + threshold: 4 + ReplaceSafeCallChainWithRun: + active: false + StringLiteralDuplication: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + threshold: 3 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + TooManyFunctions: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + thresholdInFiles: 11 + thresholdInClasses: 11 + thresholdInInterfaces: 11 + thresholdInObjects: 11 + thresholdInEnums: 11 + ignoreDeprecated: false + ignorePrivate: false + ignoreOverridden: false + +coroutines: + active: true + GlobalCoroutineUsage: + active: false + RedundantSuspendModifier: + active: false + SuspendFunWithFlowReturnType: + active: false + +empty-blocks: + active: true + EmptyCatchBlock: + active: true + allowedExceptionNameRegex: '_|(ignore|expected).*' + EmptyClassBlock: + active: true + EmptyDefaultConstructor: + active: true + EmptyDoWhileBlock: + active: true + EmptyElseBlock: + active: true + EmptyFinallyBlock: + active: true + EmptyForBlock: + active: true + EmptyFunctionBlock: + active: true + ignoreOverridden: false + EmptyIfBlock: + active: true + EmptyInitBlock: + active: true + EmptyKtFile: + active: true + EmptySecondaryConstructor: + active: true + EmptyTryBlock: + active: true + EmptyWhenBlock: + active: true + EmptyWhileBlock: + active: true + +exceptions: + active: true + ExceptionRaisedInUnexpectedLocation: + active: false + methodNames: [toString, hashCode, equals, finalize] + InstanceOfCheckForException: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + NotImplementedDeclaration: + active: false + PrintStackTrace: + active: false + RethrowCaughtException: + active: false + ReturnFromFinally: + active: false + ignoreLabeled: false + SwallowedException: + active: false + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException + allowedExceptionNameRegex: '_|(ignore|expected).*' + ThrowingExceptionFromFinally: + active: false + ThrowingExceptionInMain: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptions: + - IllegalArgumentException + - IllegalStateException + - IOException + ThrowingNewInstanceOfSameException: + active: false + TooGenericExceptionCaught: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptionNames: + - ArrayIndexOutOfBoundsException + - Error + - Exception + - IllegalMonitorStateException + - NullPointerException + - IndexOutOfBoundsException + - RuntimeException + - Throwable + allowedExceptionNameRegex: '_|(ignore|expected).*' + TooGenericExceptionThrown: + active: true + exceptionNames: + - Error + - Exception + - Throwable + - RuntimeException + +formatting: + active: true + android: false + autoCorrect: true + AnnotationOnSeparateLine: + active: false + autoCorrect: true + AnnotationSpacing: + active: false + autoCorrect: true + ArgumentListWrapping: + active: false + autoCorrect: true + ChainWrapping: + active: true + autoCorrect: true + CommentSpacing: + active: true + autoCorrect: true + EnumEntryNameCase: + active: false + autoCorrect: true + Filename: + active: true + FinalNewline: + active: true + autoCorrect: true + insertFinalNewLine: true + ImportOrdering: + active: false + autoCorrect: true + layout: 'idea' + Indentation: + active: false + autoCorrect: true + indentSize: 4 + continuationIndentSize: 4 + MaximumLineLength: + active: true + maxLineLength: 120 + ModifierOrdering: + active: true + autoCorrect: true + MultiLineIfElse: + active: true + autoCorrect: true + NoBlankLineBeforeRbrace: + active: true + autoCorrect: true + NoConsecutiveBlankLines: + active: true + autoCorrect: true + NoEmptyClassBody: + active: true + autoCorrect: true + NoEmptyFirstLineInMethodBlock: + active: false + autoCorrect: true + NoLineBreakAfterElse: + active: true + autoCorrect: true + NoLineBreakBeforeAssignment: + active: true + autoCorrect: true + NoMultipleSpaces: + active: true + autoCorrect: true + NoSemicolons: + active: true + autoCorrect: true + NoTrailingSpaces: + active: true + autoCorrect: true + NoUnitReturn: + active: true + autoCorrect: true + NoUnusedImports: + active: true + autoCorrect: true + NoWildcardImports: + active: true + PackageName: + active: true + autoCorrect: true + ParameterListWrapping: + active: true + autoCorrect: true + indentSize: 4 + SpacingAroundColon: + active: true + autoCorrect: true + SpacingAroundComma: + active: true + autoCorrect: true + SpacingAroundCurly: + active: true + autoCorrect: true + SpacingAroundDot: + active: true + autoCorrect: true + SpacingAroundDoubleColon: + active: false + autoCorrect: true + SpacingAroundKeyword: + active: true + autoCorrect: true + SpacingAroundOperators: + active: true + autoCorrect: true + SpacingAroundParens: + active: true + autoCorrect: true + SpacingAroundRangeOperator: + active: true + autoCorrect: true + SpacingBetweenDeclarationsWithAnnotations: + active: false + autoCorrect: true + SpacingBetweenDeclarationsWithComments: + active: false + autoCorrect: true + StringTemplate: + active: true + autoCorrect: true + +naming: + active: true + ClassNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + classPattern: '[A-Z][a-zA-Z0-9]*' + ConstructorParameterNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + parameterPattern: '[a-z][A-Za-z0-9]*' + privateParameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + ignoreOverridden: true + EnumNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' + ForbiddenClassName: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + forbiddenName: [] + FunctionMaxLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + maximumFunctionNameLength: 30 + FunctionMinLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + minimumFunctionNameLength: 3 + FunctionNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' + excludeClassPattern: '$^' + ignoreOverridden: true + ignoreAnnotated: ['Composable'] + FunctionParameterNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + parameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + ignoreOverridden: true + InvalidPackageDeclaration: + active: false + rootPackage: '' + MatchingDeclarationName: + active: true + mustBeFirst: true + MemberNameEqualsClassName: + active: true + ignoreOverridden: true + NonBooleanPropertyPrefixedWithIs: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + ObjectPropertyNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + constantPattern: '[A-Za-z][_A-Za-z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' + PackageNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' + TopLevelPropertyNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' + VariableMaxLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + maximumVariableNameLength: 64 + VariableMinLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + minimumVariableNameLength: 1 + VariableNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + ignoreOverridden: true + +performance: + active: true + ArrayPrimitive: + active: true + ForEachOnRange: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + SpreadOperator: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + Deprecation: + active: false + DuplicateCaseInWhenExpression: + active: true + EqualsAlwaysReturnsTrueOrFalse: + active: true + EqualsWithHashCodeExist: + active: true + ExplicitGarbageCollectionCall: + active: true + HasPlatformType: + active: false + IgnoredReturnValue: + active: false + restrictToAnnotatedMethods: true + returnValueAnnotations: ['*.CheckReturnValue', '*.CheckResult'] + ImplicitDefaultLocale: + active: false + ImplicitUnitReturnType: + active: false + allowExplicitReturnType: true + InvalidRange: + active: true + IteratorHasNextCallsNextMethod: + active: true + IteratorNotThrowingNoSuchElementException: + active: true + LateinitUsage: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + excludeAnnotatedProperties: [] + ignoreOnClassesPattern: '' + MapGetWithNotNullAssertionOperator: + active: false + MissingWhenCase: + active: true + allowElseExpression: true + NullableToStringCall: + active: false + RedundantElseInWhen: + active: true + UnconditionalJumpStatementInLoop: + active: false + UnnecessaryNotNullOperator: + active: false + UnnecessarySafeCall: + active: false + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: true + UnsafeCast: + active: false + UselessPostfixExpression: + active: false + WrongEqualsTypeParameter: + active: true + +style: + active: true + ClassOrdering: + active: false + CollapsibleIfStatements: + active: false + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: 'to' + DataClassShouldBeImmutable: + active: false + EqualsNullCall: + active: true + EqualsOnSignatureLine: + active: false + ExplicitCollectionElementAccessMethod: + active: false + ExplicitItLambdaParameter: + active: false + ExpressionBodySyntax: + active: false + includeLineWrapping: false + ForbiddenComment: + active: true + values: ['TODO:', 'FIXME:', 'STOPSHIP:'] + allowedPatterns: '' + ForbiddenImport: + active: false + imports: [] + forbiddenPatterns: '' + ForbiddenMethodCall: + active: false + methods: ['kotlin.io.println', 'kotlin.io.print'] + ForbiddenPublicDataClass: + active: false + ignorePackages: ['*.internal', '*.internal.*'] + ForbiddenVoid: + active: false + ignoreOverridden: false + ignoreUsageInGenerics: false + FunctionOnlyReturningConstant: + active: true + ignoreOverridableFunction: true + excludedFunctions: 'describeContents' + excludeAnnotatedFunction: ['dagger.Provides'] + LibraryCodeMustSpecifyReturnType: + active: true + LibraryEntitiesShouldNotBePublic: + active: false + LoopWithTooManyJumpStatements: + active: true + maxJumpCount: 1 + MagicNumber: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + ignoreNumbers: ['-1', '0', '1', '2'] + ignoreHashCodeFunction: true + ignorePropertyDeclaration: false + ignoreLocalVariableDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: true + ignoreEnums: false + ignoreRanges: false + MandatoryBracesIfStatements: + active: false + MandatoryBracesLoops: + active: false + MaxLineLength: + active: true + maxLineLength: 120 + excludePackageStatements: true + excludeImportStatements: true + excludeCommentStatements: false + MayBeConst: + active: true + ModifierOrder: + active: true + NestedClassesVisibility: + active: false + NewLineAtEndOfFile: + active: false + NoTabs: + active: false + OptionalAbstractKeyword: + active: true + OptionalUnit: + active: false + OptionalWhenBraces: + active: false + PreferToOverPairSyntax: + active: false + ProtectedMemberInFinalClass: + active: true + RedundantExplicitType: + active: false + RedundantHigherOrderMapUsage: + active: false + RedundantVisibilityModifierRule: + active: false + ReturnCount: + active: true + max: 2 + excludedFunctions: 'equals' + excludeLabeled: false + excludeReturnFromLambda: true + excludeGuardClauses: false + SafeCast: + active: true + SerialVersionUIDInSerializableClass: + active: false + SpacingBetweenPackageAndImports: + active: false + ThrowsCount: + active: true + max: 2 + TrailingWhitespace: + active: false + UnderscoresInNumericLiterals: + active: false + acceptableDecimalLength: 5 + UnnecessaryAbstractClass: + active: true + excludeAnnotatedClasses: ['dagger.Module'] + UnnecessaryAnnotationUseSiteTarget: + active: false + UnnecessaryApply: + active: false + UnnecessaryInheritance: + active: true + UnnecessaryLet: + active: false + UnnecessaryParentheses: + active: false + UntilInsteadOfRangeTo: + active: false + UnusedImports: + active: false + UnusedPrivateClass: + active: true + UnusedPrivateMember: + active: false + allowedNames: '(_|ignored|expected|serialVersionUID)' + UseArrayLiteralsInAnnotations: + active: false + UseCheckNotNull: + active: false + UseCheckOrError: + active: false + UseDataClass: + active: false + excludeAnnotatedClasses: [] + allowVars: false + UseEmptyCounterpart: + active: false + UseIfEmptyOrIfBlank: + active: false + UseIfInsteadOfWhen: + active: false + UseRequire: + active: false + UseRequireNotNull: + active: false + UselessCallOnNotNull: + active: true + UtilityClassWithPublicConstructor: + active: true + VarCouldBeVal: + active: false + WildcardImport: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + excludeImports: ['java.util.*', 'kotlinx.android.synthetic.*'] \ No newline at end of file From 3ebcc1c71e0243b1347b659d4b22cdb0b1cd868c Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 1 Mar 2021 13:34:34 +0100 Subject: [PATCH 3/7] make detekt work --- .editorconfig | 5 +++++ build.gradle | 7 +++++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..4ce4a9be35 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true + + +[*{kt,kts}] +disabled_rules=no-wildcard-imports \ No newline at end of file diff --git a/build.gradle b/build.gradle index c335d90c7a..3b9caa5038 100644 --- a/build.gradle +++ b/build.gradle @@ -44,9 +44,10 @@ buildscript { } } maven { url "https://plugins.gradle.org/m2/" } // jacoco 0.2 + maven { url "https://dl.bintray.com/kotlin/kotlinx" } } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.2' classpath 'com.google.gms:google-services:4.3.4' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1' @@ -59,7 +60,7 @@ buildscript { } plugins { - id "io.gitlab.arturbosch.detekt" version "1.15.0-RC2" + id "io.gitlab.arturbosch.detekt" version "1.16.0-RC2" id "org.jlleitschuh.gradle.ktlint" version "9.4.1" } @@ -83,6 +84,8 @@ allprojects { includeModule("org.jetbrains.trove4j", "trove4j") } } + maven { url "https://dl.bintray.com/kotlin/kotlinx" } + } //Support @JvmDefault tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4d9e76064..e53b7051f9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip From 77c816e8135cd3a21fe16731cec23f5962eb4783 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 1 Mar 2021 13:39:02 +0100 Subject: [PATCH 4/7] ktlint format --- .../omnipod/dash/history/DashHistoryTest.kt | 6 +- .../omnipod/dash/history/RxSchedulerRule.kt | 3 +- .../dash/EventOmnipodDashPumpValuesChanged.kt | 2 +- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 2 +- .../dash/dagger/OmnipodDashHistoryModule.kt | 3 +- .../omnipod/dash/dagger/OmnipodDashModule.kt | 2 +- .../OmnipodDashWizardViewModelsModule.kt | 2 +- .../omnipod/dash/driver/OmnipodDashManager.kt | 2 +- .../dash/driver/OmnipodDashManagerImpl.kt | 126 ++++++++++-------- .../pump/omnipod/dash/driver/comm/Id.kt | 3 +- .../dash/driver/comm/OmnipodDashBleManager.kt | 2 +- .../driver/comm/OmnipodDashBleManagerImpl.kt | 9 +- .../dash/driver/comm/ServiceDiscoverer.kt | 7 +- .../driver/comm/callbacks/BleCommCallbacks.kt | 31 +++-- .../CharacteristicWriteConfirmation.kt | 2 +- .../callbacks/DescriptorWriteConfirmation.kt | 2 +- .../driver/comm/command/BleCommandHello.kt | 5 +- .../driver/comm/command/BleCommandType.kt | 2 +- .../comm/exceptions/BleIOBusyException.kt | 2 +- .../CharacteristicNotFoundException.kt | 2 +- ...CouldNotConfirmDescriptorWriteException.kt | 6 +- .../CouldNotConfirmWriteException.kt | 6 +- .../exceptions/CouldNotEnableNotifications.kt | 2 +- .../CouldNotParseMessageException.kt | 2 +- .../exceptions/CouldNotSendBleException.kt | 2 +- .../exceptions/DescriptorNotFoundException.kt | 2 +- .../DiscoveredInvalidPodException.kt | 2 +- .../exceptions/FailedToConnectException.kt | 2 +- .../comm/exceptions/MessageIOException.kt | 2 +- .../comm/exceptions/ScanFailException.kt | 2 +- .../ScanFailFoundTooManyException.kt | 2 +- .../exceptions/ScanFailNotFoundException.kt | 2 +- .../exceptions/ServiceNotFoundException.kt | 2 +- .../exceptions/UnexpectedCommandException.kt | 2 +- .../pump/omnipod/dash/driver/comm/io/BleIO.kt | 2 +- .../dash/driver/comm/io/CharacteristicType.kt | 2 +- .../omnipod/dash/driver/comm/io/IOState.kt | 2 +- .../comm/message/CrcMismatchException.kt | 2 +- .../comm/message/IncorrectPacketException.kt | 2 +- .../dash/driver/comm/message/MessageIO.kt | 2 +- .../dash/driver/comm/message/MessagePacket.kt | 6 +- .../dash/driver/comm/message/MessageType.kt | 2 +- .../dash/driver/comm/message/PayloadJoiner.kt | 13 +- .../driver/comm/message/PayloadSplitter.kt | 72 +++++----- .../message/StringLengthPrefixEncoding.kt | 16 +-- .../dash/driver/comm/packet/BlePacket.kt | 1 - .../dash/driver/comm/pair/LTKExchanger.kt | 2 +- .../dash/driver/comm/pair/PairMessage.kt | 2 +- .../driver/comm/scan/BleDiscoveredDevice.kt | 3 +- .../dash/driver/comm/scan/PodScanner.kt | 2 +- .../dash/driver/comm/scan/ScanCollector.kt | 3 +- .../driver/comm/status/ConnectionStatus.kt | 2 +- .../omnipod/dash/driver/event/PodEvent.kt | 1 - .../driver/pod/command/DeactivateCommand.kt | 16 ++- .../driver/pod/command/GetStatusCommand.kt | 17 +-- .../driver/pod/command/GetVersionCommand.kt | 16 ++- .../pod/command/ProgramAlertsCommand.kt | 2 +- .../driver/pod/command/ProgramBasalCommand.kt | 26 ++-- .../driver/pod/command/ProgramBeepsCommand.kt | 22 +-- .../driver/pod/command/ProgramBolusCommand.kt | 34 +++-- .../pod/command/ProgramInsulinCommand.kt | 7 +- .../pod/command/ProgramTempBasalCommand.kt | 20 +-- .../driver/pod/command/SetUniqueIdCommand.kt | 34 ++--- .../pod/command/SilenceAlertsCommand.kt | 18 +-- .../driver/pod/command/StopDeliveryCommand.kt | 18 +-- .../dash/driver/pod/command/base/Command.kt | 2 +- .../driver/pod/command/base/CommandType.kt | 10 +- .../pod/command/base/NonceEnabledCommand.kt | 2 +- .../command/base/builder/CommandBuilder.kt | 2 +- .../builder/HeaderEnabledCommandBuilder.kt | 2 +- .../builder/NonceEnabledCommandBuilder.kt | 2 +- .../program/BasalInsulinProgramElement.kt | 2 +- .../BasalShortInsulinProgramElement.kt | 12 +- .../BolusShortInsulinProgramElement.kt | 2 +- .../CurrentBasalInsulinProgramElement.kt | 2 +- .../command/insulin/program/CurrentSlot.kt | 2 +- .../program/ShortInsulinProgramElement.kt | 2 +- .../program/TempBasalInsulinProgramElement.kt | 2 +- .../insulin/program/util/ProgramBasalUtil.kt | 2 +- .../program/util/ProgramTempBasalUtil.kt | 2 +- .../pod/definition/ActivationProgress.kt | 2 +- .../dash/driver/pod/definition/AlarmType.kt | 3 +- .../pod/definition/AlertConfiguration.kt | 18 +-- .../driver/pod/definition/AlertTrigger.kt | 2 +- .../dash/driver/pod/definition/AlertType.kt | 2 +- .../driver/pod/definition/BasalProgram.kt | 2 +- .../pod/definition/BeepRepetitionType.kt | 3 +- .../dash/driver/pod/definition/BeepType.kt | 2 +- .../driver/pod/definition/DeliveryStatus.kt | 2 +- .../dash/driver/pod/definition/Encodable.kt | 2 +- .../driver/pod/definition/NakErrorType.kt | 2 +- .../dash/driver/pod/definition/PodStatus.kt | 2 +- .../driver/pod/definition/ProgramReminder.kt | 12 +- .../pod/response/ActivationResponseBase.kt | 2 +- .../response/AdditionalStatusResponseBase.kt | 2 +- .../pod/response/AlarmStatusResponse.kt | 3 +- .../pod/response/DefaultStatusResponse.kt | 1 - .../dash/driver/pod/response/NakResponse.kt | 2 +- .../dash/driver/pod/response/Response.kt | 2 +- .../dash/driver/pod/response/ResponseBase.kt | 3 +- .../dash/driver/pod/response/ResponseType.kt | 2 +- .../pod/response/SetUniqueIdResponse.kt | 3 +- .../driver/pod/response/VersionResponse.kt | 3 +- .../pod/state/OmnipodDashPodStateManager.kt | 2 +- .../state/OmnipodDashPodStateManagerImpl.kt | 2 +- .../omnipod/dash/driver/pod/util/AlertUtil.kt | 5 +- .../omnipod/dash/driver/pod/util/HasValue.kt | 2 +- .../dash/driver/pod/util/MessageUtil.kt | 2 +- .../pump/omnipod/dash/history/DashHistory.kt | 27 ++-- .../pump/omnipod/dash/history/data/Record.kt | 6 +- .../omnipod/dash/history/data/ResultStates.kt | 2 +- .../dash/history/database/Converters.kt | 2 +- .../history/database/DashHistoryDatabase.kt | 6 +- .../dash/history/database/HistoryRecordDao.kt | 3 +- .../history/database/HistoryRecordEntity.kt | 4 +- .../dash/history/mapper/HistoryMapper.kt | 6 +- .../dash/ui/DashPodManagementActivity.kt | 24 ++-- .../dash/ui/OmnipodDashOverviewFragment.kt | 85 +++++++----- .../DashPodActivationWizardActivity.kt | 2 +- .../action/DashInsertCannulaViewModel.kt | 2 +- .../viewmodel/info/DashAttachPodViewModel.kt | 2 +- .../info/DashPodActivatedViewModel.kt | 2 +- .../info/DashStartPodActivationViewModel.kt | 2 +- .../DashPodDeactivationWizardActivity.kt | 2 +- .../action/DashDeactivatePodViewModel.kt | 2 +- .../info/DashPodDeactivatedViewModel.kt | 3 +- .../info/DashPodDiscardedViewModel.kt | 2 +- .../info/DashStartPodDeactivationViewModel.kt | 2 +- .../pump/omnipod/dash/util/Functions.kt | 2 +- .../pod/command/DeactivateCommandTest.kt | 2 +- .../pod/command/GetStatusCommandTest.kt | 2 +- .../pod/command/GetVersionCommandTest.kt | 2 +- .../pod/command/ProgramAlertsCommandTest.kt | 4 +- .../pod/command/ProgramBasalCommandTest.kt | 2 +- .../pod/command/ProgramBeepsCommandTest.kt | 2 +- .../pod/command/ProgramBolusCommandTest.kt | 2 +- .../command/ProgramTempBasalCommandTest.kt | 2 +- .../pod/command/SetUniqueIdCommandTest.kt | 2 +- .../pod/command/SilenceAlertsCommandTest.kt | 2 +- .../pod/command/StopDeliveryCommandTest.kt | 2 +- .../pod/response/AlarmStatusResponseTest.kt | 2 +- .../pod/response/DefaultStatusResponseTest.kt | 2 +- .../driver/pod/response/NakResponseTest.kt | 3 +- .../pod/response/SetUniqueIdResponseTest.kt | 2 +- .../pod/response/VersionResponseTest.kt | 2 +- .../pump/omnipod/dash/util/FunctionsTest.kt | 45 ++++--- 146 files changed, 557 insertions(+), 467 deletions(-) diff --git a/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt b/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt index 9edd38f85e..df9b08ef74 100644 --- a/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt +++ b/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt @@ -30,7 +30,9 @@ class DashHistoryTest { fun setUp() { val context = ApplicationProvider.getApplicationContext() database = Room.inMemoryDatabaseBuilder( - context, DashHistoryDatabase::class.java).build() + context, + DashHistoryDatabase::class.java + ).build() dao = database.historyRecordDao() dashHistory = DashHistory(dao, HistoryMapper()) } @@ -69,4 +71,4 @@ class DashHistoryTest { fun tearDown() { database.close() } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/RxSchedulerRule.kt b/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/RxSchedulerRule.kt index 6073957e5f..a649da837d 100644 --- a/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/RxSchedulerRule.kt +++ b/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/RxSchedulerRule.kt @@ -26,7 +26,6 @@ class RxSchedulerRule(val scheduler: Scheduler) : TestRule { RxJavaPlugins.reset() RxAndroidPlugins.reset() } - } } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/EventOmnipodDashPumpValuesChanged.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/EventOmnipodDashPumpValuesChanged.kt index 953819cad3..7aa04163dd 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/EventOmnipodDashPumpValuesChanged.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/EventOmnipodDashPumpValuesChanged.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash import info.nightscout.androidaps.events.Event -class EventOmnipodDashPumpValuesChanged : Event() \ No newline at end of file +class EventOmnipodDashPumpValuesChanged : Event() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 4f6b4e7e8c..48cb6d25f4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -207,4 +207,4 @@ class OmnipodDashPumpPlugin @Inject constructor( override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) { // TODO } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt index 172dd497b0..16ab403d63 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt @@ -29,5 +29,4 @@ class OmnipodDashHistoryModule { @Singleton internal fun provideDashHistory(dao: HistoryRecordDao, historyMapper: HistoryMapper) = DashHistory(dao, historyMapper) - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashModule.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashModule.kt index 98780b10d9..cbd7e42804 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashModule.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashModule.kt @@ -47,4 +47,4 @@ abstract class OmnipodDashModule { @Binds abstract fun bindsOmnipodDashManagerImpl(omnipodManager: OmnipodDashManagerImpl): OmnipodDashManager -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashWizardViewModelsModule.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashWizardViewModelsModule.kt index 1b1aaf6f13..fc0f0f4e52 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashWizardViewModelsModule.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashWizardViewModelsModule.kt @@ -86,4 +86,4 @@ abstract class OmnipodDashWizardViewModelsModule { @OmnipodPluginQualifier @ViewModelKey(PodDiscardedViewModel::class) internal abstract fun podDiscardedViewModel(viewModel: DashPodDiscardedViewModel): ViewModel -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt index 4d7523eff6..aa5879f898 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt @@ -37,4 +37,4 @@ interface OmnipodDashManager { fun silenceAlerts(alerts: EnumSet): Observable fun deactivatePod(): Observable -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt index 884e755db7..7f115860cf 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt @@ -50,14 +50,15 @@ class OmnipodDashManagerImpl @Inject constructor( private fun observeSendProgramBolusCommand(units: Double, rateInEighthPulsesPerSeconds: Byte, confirmationBeeps: Boolean, completionBeeps: Boolean): Observable { return Observable.defer { - bleManager.sendCommand(ProgramBolusCommand.Builder() - .setUniqueId(podStateManager.uniqueId!!.toInt()) - .setSequenceNumber(podStateManager.messageSequenceNumber) - .setNonce(1229869870) // TODO - .setNumberOfUnits(units) - .setDelayBetweenPulsesInEighthSeconds(rateInEighthPulsesPerSeconds) - .setProgramReminder(ProgramReminder(confirmationBeeps, completionBeeps, 0)) - .build() + bleManager.sendCommand( + ProgramBolusCommand.Builder() + .setUniqueId(podStateManager.uniqueId!!.toInt()) + .setSequenceNumber(podStateManager.messageSequenceNumber) + .setNonce(1229869870) // TODO + .setNumberOfUnits(units) + .setDelayBetweenPulsesInEighthSeconds(rateInEighthPulsesPerSeconds) + .setProgramReminder(ProgramReminder(confirmationBeeps, completionBeeps, 0)) + .build() ) } } @@ -78,13 +79,15 @@ class OmnipodDashManagerImpl @Inject constructor( get() = Observable.defer { observeSendGetPodStatusCommand() .ignoreElements() // - .andThen(Observable.defer { - if (podStateManager.podStatus == PodStatus.RUNNING_ABOVE_MIN_VOLUME) { - Observable.empty() - } else { - Observable.error(IllegalStateException("Unexpected Pod status")) + .andThen( + Observable.defer { + if (podStateManager.podStatus == PodStatus.RUNNING_ABOVE_MIN_VOLUME) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Unexpected Pod status")) + } } - }) + ) } private fun observeSendProgramAlertsCommand(alertConfigurations: List, multiCommandFlag: Boolean = false): Observable { @@ -119,32 +122,38 @@ class OmnipodDashManagerImpl @Inject constructor( get() = Observable.defer { observeSendGetPodStatusCommand() .ignoreElements() // - .andThen(Observable.defer { - if (podStateManager.podStatus == PodStatus.CLUTCH_DRIVE_ENGAGED) { - Observable.empty() - } else { - Observable.error(IllegalStateException("Unexpected Pod status")) + .andThen( + Observable.defer { + if (podStateManager.podStatus == PodStatus.CLUTCH_DRIVE_ENGAGED) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Unexpected Pod status")) + } } - }) + ) } private val observeSendSetUniqueIdCommand: Observable get() = Observable.defer { - bleManager.sendCommand(SetUniqueIdCommand.Builder() // - .setSequenceNumber(podStateManager.messageSequenceNumber) // - .setUniqueId(podStateManager.uniqueId!!.toInt()) // - .setLotNumber(podStateManager.lotNumber!!.toInt()) // - .setPodSequenceNumber(podStateManager.podSequenceNumber!!.toInt()) - .setInitializationTime(Date()) - .build()) // + bleManager.sendCommand( + SetUniqueIdCommand.Builder() // + .setSequenceNumber(podStateManager.messageSequenceNumber) // + .setUniqueId(podStateManager.uniqueId!!.toInt()) // + .setLotNumber(podStateManager.lotNumber!!.toInt()) // + .setPodSequenceNumber(podStateManager.podSequenceNumber!!.toInt()) + .setInitializationTime(Date()) + .build() + ) // } private val observeSendGetVersionCommand: Observable get() = Observable.defer { - bleManager.sendCommand(GetVersionCommand.Builder() // - .setSequenceNumber(podStateManager.messageSequenceNumber) // - .setUniqueId(DEFAULT_UNIQUE_ID) // - .build()) // + bleManager.sendCommand( + GetVersionCommand.Builder() // + .setSequenceNumber(podStateManager.messageSequenceNumber) // + .setUniqueId(DEFAULT_UNIQUE_ID) // + .build() + ) // } override fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable { @@ -277,30 +286,32 @@ class OmnipodDashManagerImpl @Inject constructor( ) } if (podStateManager.activationProgress.isBefore(ActivationProgress.UPDATED_EXPIRATION_ALERTS)) { - observables.add(observeSendProgramAlertsCommand( - listOf( - // FIXME use user configured expiration alert - AlertConfiguration( - AlertType.EXPIRATION, - enabled = true, - durationInMinutes = TimeUnit.HOURS.toMinutes(7).toShort(), - autoOff = false, - AlertTrigger.TimerTrigger(TimeUnit.HOURS.toMinutes(73).toShort()), // FIXME use activation time - BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.XXX3 + observables.add( + observeSendProgramAlertsCommand( + listOf( + // FIXME use user configured expiration alert + AlertConfiguration( + AlertType.EXPIRATION, + enabled = true, + durationInMinutes = TimeUnit.HOURS.toMinutes(7).toShort(), + autoOff = false, + AlertTrigger.TimerTrigger(TimeUnit.HOURS.toMinutes(73).toShort()), // FIXME use activation time + BeepType.FOUR_TIMES_BIP_BEEP, + BeepRepetitionType.XXX3 + ), + AlertConfiguration( + AlertType.EXPIRATION_IMMINENT, + enabled = true, + durationInMinutes = TimeUnit.HOURS.toMinutes(1).toShort(), + autoOff = false, + AlertTrigger.TimerTrigger(TimeUnit.HOURS.toMinutes(79).toShort()), // FIXME use activation time + BeepType.FOUR_TIMES_BIP_BEEP, + BeepRepetitionType.XXX4 + ) ), - AlertConfiguration( - AlertType.EXPIRATION_IMMINENT, - enabled = true, - durationInMinutes = TimeUnit.HOURS.toMinutes(1).toShort(), - autoOff = false, - AlertTrigger.TimerTrigger(TimeUnit.HOURS.toMinutes(79).toShort()), // FIXME use activation time - BeepType.FOUR_TIMES_BIP_BEEP, - BeepRepetitionType.XXX4 - ) - ), - multiCommandFlag = true - ).doOnComplete(ActivationProgressUpdater(ActivationProgress.UPDATED_EXPIRATION_ALERTS))) + multiCommandFlag = true + ).doOnComplete(ActivationProgressUpdater(ActivationProgress.UPDATED_EXPIRATION_ALERTS)) + ) } if (podStateManager.activationProgress.isBefore(ActivationProgress.PROGRAMMED_BASAL)) { observables.add( @@ -399,7 +410,7 @@ class OmnipodDashManagerImpl @Inject constructor( handleResponse(event.response) } - else -> { + else -> { // Do nothing } } @@ -424,7 +435,6 @@ class OmnipodDashManagerImpl @Inject constructor( } } } - } inner class ErrorInterceptor : Consumer { @@ -432,7 +442,6 @@ class OmnipodDashManagerImpl @Inject constructor( override fun accept(throwable: Throwable) { logger.debug(LTag.PUMP, "Intercepted error in OmnipodDashManagerImpl: ${throwable.javaClass.simpleName}") } - } inner class ActivationProgressUpdater(private val value: ActivationProgress) : Action { @@ -440,6 +449,5 @@ class OmnipodDashManagerImpl @Inject constructor( override fun run() { podStateManager.activationProgress = value } - } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/Id.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/Id.kt index 866c65b922..3ca97e76b4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/Id.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/Id.kt @@ -22,7 +22,7 @@ data class Id(val address: ByteArray) { override fun toString(): String { val asInt = ByteBuffer.wrap(address).int - return "${asInt}/${address.toHex()}" + return "$asInt/${address.toHex()}" } companion object { @@ -33,5 +33,4 @@ data class Id(val address: ByteArray) { return Id(ByteBuffer.allocate(4).putInt(v).array()) } } - } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt index aa0b64e641..11e808ba73 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt @@ -14,4 +14,4 @@ interface OmnipodDashBleManager { fun connect(): Observable fun disconnect() -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt index be03f69525..1f4c92bbf5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt @@ -39,8 +39,10 @@ class OmnipodDashBleManagerImpl @Inject constructor(private val context: Context // TODO: locking? val podDevice = bluetoothAdapter.getRemoteDevice(podAddress) val incomingPackets: Map> = - mapOf(CharacteristicType.CMD to LinkedBlockingDeque(), - CharacteristicType.DATA to LinkedBlockingDeque()) + mapOf( + CharacteristicType.CMD to LinkedBlockingDeque(), + CharacteristicType.DATA to LinkedBlockingDeque() + ) val bleCommCallbacks = BleCommCallbacks(aapsLogger, incomingPackets) aapsLogger.debug(LTag.PUMPBTCOMM, "Connecting to $podAddress") var autoConnect = true @@ -118,5 +120,4 @@ class OmnipodDashBleManagerImpl @Inject constructor(private val context: Context private const val CONNECT_TIMEOUT_MS = 7000 const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else. } - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt index 8ebde34478..ceb471cabb 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt @@ -4,7 +4,6 @@ import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGattCharacteristic 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.exceptions.CharacteristicNotFoundException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ServiceNotFoundException @@ -29,8 +28,10 @@ class ServiceDiscoverer(private val logger: AAPSLogger, private val gatt: Blueto ?: throw CharacteristicNotFoundException(CharacteristicType.CMD.value) val dataChar = service.getCharacteristic(CharacteristicType.DATA.uuid) // TODO: this is never used ?: throw CharacteristicNotFoundException(CharacteristicType.DATA.value) - var chars = mapOf(CharacteristicType.CMD to cmdChar, - CharacteristicType.DATA to dataChar) + var chars = mapOf( + CharacteristicType.CMD to cmdChar, + CharacteristicType.DATA to dataChar + ) return chars } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt index 451a723296..49094d7d3b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt @@ -77,8 +77,11 @@ class BleCommCallbacks(private val aapsLogger: AAPSLogger, private val incomingP } else { CharacteristicWriteConfirmationError(status) } - aapsLogger.debug(LTag.PUMPBTCOMM, "OnCharacteristicWrite with status/char/value " + - status + "/" + byValue(characteristic.uuid.toString()) + "/" + characteristic.value.toHex()) + aapsLogger.debug( + LTag.PUMPBTCOMM, + "OnCharacteristicWrite with status/char/value " + + status + "/" + byValue(characteristic.uuid.toString()) + "/" + characteristic.value.toHex() + ) try { if (writeQueue.size > 0) { aapsLogger.warn(LTag.PUMPBTCOMM, "Write confirm queue should be empty. found: " + writeQueue.size) @@ -97,9 +100,12 @@ class BleCommCallbacks(private val aapsLogger: AAPSLogger, private val incomingP super.onCharacteristicChanged(gatt, characteristic) val payload = characteristic.value val characteristicType = byValue(characteristic.uuid.toString()) - aapsLogger.debug(LTag.PUMPBTCOMM, "OnCharacteristicChanged with char/value " + - characteristicType + "/" + - payload.toHex()) + aapsLogger.debug( + LTag.PUMPBTCOMM, + "OnCharacteristicChanged with char/value " + + characteristicType + "/" + + payload.toHex() + ) incomingPackets[characteristicType]!!.add(payload) } @@ -109,12 +115,13 @@ class BleCommCallbacks(private val aapsLogger: AAPSLogger, private val incomingP ?: throw TimeoutException() when (confirmed) { is DescriptorWriteConfirmationError -> throw CouldNotConfirmWriteException(confirmed.status) - is DescriptorWriteConfirmationUUID -> if (confirmed.uuid != descriptorUUID) { - aapsLogger.warn(LTag.PUMPBTCOMM, "Could not confirm descriptor write. Got ${confirmed.uuid}. Expected: $descriptorUUID") - throw CouldNotConfirmDescriptorWriteException(descriptorUUID, confirmed.uuid) - } else { - aapsLogger.debug(LTag.PUMPBTCOMM, "Confirmed descriptor write : " + confirmed.uuid) - } + is DescriptorWriteConfirmationUUID -> + if (confirmed.uuid != descriptorUUID) { + aapsLogger.warn(LTag.PUMPBTCOMM, "Could not confirm descriptor write. Got ${confirmed.uuid}. Expected: $descriptorUUID") + throw CouldNotConfirmDescriptorWriteException(descriptorUUID, confirmed.uuid) + } else { + aapsLogger.debug(LTag.PUMPBTCOMM, "Confirmed descriptor write : " + confirmed.uuid) + } } } @@ -144,4 +151,4 @@ class BleCommCallbacks(private val aapsLogger: AAPSLogger, private val incomingP private const val WRITE_CONFIRM_TIMEOUT_MS = 10 // the confirmation queue should be empty anyway } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/CharacteristicWriteConfirmation.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/CharacteristicWriteConfirmation.kt index 31e3595050..575bd19c0f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/CharacteristicWriteConfirmation.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/CharacteristicWriteConfirmation.kt @@ -4,4 +4,4 @@ sealed class CharacteristicWriteConfirmation data class CharacteristicWriteConfirmationPayload(val payload: ByteArray) : CharacteristicWriteConfirmation() -data class CharacteristicWriteConfirmationError(val status: Int) : CharacteristicWriteConfirmation() \ No newline at end of file +data class CharacteristicWriteConfirmationError(val status: Int) : CharacteristicWriteConfirmation() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/DescriptorWriteConfirmation.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/DescriptorWriteConfirmation.kt index fbbb5b7f1b..83fc9d41c8 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/DescriptorWriteConfirmation.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/DescriptorWriteConfirmation.kt @@ -4,4 +4,4 @@ sealed class DescriptorWriteConfirmation data class DescriptorWriteConfirmationUUID(val uuid: String) : DescriptorWriteConfirmation() -data class DescriptorWriteConfirmationError(val status: Int) : DescriptorWriteConfirmation() \ No newline at end of file +data class DescriptorWriteConfirmationError(val status: Int) : DescriptorWriteConfirmation() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandHello.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandHello.kt index 03414989b2..d10ae85aa1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandHello.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandHello.kt @@ -2,9 +2,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command import java.nio.ByteBuffer -class BleCommandHello(controllerId: Int) : BleCommand(BleCommandType.HELLO, +class BleCommandHello(controllerId: Int) : BleCommand( + BleCommandType.HELLO, ByteBuffer.allocate(6) .put(1.toByte()) // TODO find the meaning of this constant .put(4.toByte()) // TODO find the meaning of this constant .putInt(controllerId).array() -) \ No newline at end of file +) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt index 5c096d4410..8557bfb4e9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt @@ -10,4 +10,4 @@ enum class BleCommandType(val value: Byte) { values().firstOrNull { it.value == value } ?: throw IllegalArgumentException("Unknown BleCommandType: $value") } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BleIOBusyException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BleIOBusyException.kt index 6029d66998..1fa748a391 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BleIOBusyException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BleIOBusyException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class BleIOBusyException : Exception() \ No newline at end of file +class BleIOBusyException : Exception() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CharacteristicNotFoundException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CharacteristicNotFoundException.kt index 730b6eeda0..dedd9399ab 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CharacteristicNotFoundException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CharacteristicNotFoundException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class CharacteristicNotFoundException(cmdCharacteristicUuid: String) : FailedToConnectException("characteristic not found: $cmdCharacteristicUuid") \ No newline at end of file +class CharacteristicNotFoundException(cmdCharacteristicUuid: String) : FailedToConnectException("characteristic not found: $cmdCharacteristicUuid") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmDescriptorWriteException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmDescriptorWriteException.kt index 75c9f82344..ffc37a29da 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmDescriptorWriteException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmDescriptorWriteException.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions class CouldNotConfirmDescriptorWriteException(override val message: String?) : Exception(message) { - constructor(sent: String, confirmed: String) : this("Could not confirm write. Sent: {$sent} .Received: ${confirmed}") - constructor(status: Int) : this("Could not confirm write. Write status: ${status}") -} \ No newline at end of file + constructor(sent: String, confirmed: String) : this("Could not confirm write. Sent: {$sent} .Received: $confirmed") + constructor(status: Int) : this("Could not confirm write. Write status: $status") +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmWriteException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmWriteException.kt index 9217668e77..7e5573d1ca 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmWriteException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotConfirmWriteException.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions class CouldNotConfirmWriteException(override val message: String?) : Exception(message) { - constructor(sent: ByteArray, confirmed: ByteArray) : this("Could not confirm write. Sent: {$sent} .Received: ${confirmed}") - constructor(status: Int) : this("Could not confirm write. Write status: ${status}") -} \ No newline at end of file + constructor(sent: ByteArray, confirmed: ByteArray) : this("Could not confirm write. Sent: {$sent} .Received: $confirmed") + constructor(status: Int) : this("Could not confirm write. Write status: $status") +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotEnableNotifications.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotEnableNotifications.kt index b9987da037..1e982d21a0 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotEnableNotifications.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotEnableNotifications.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType -class CouldNotEnableNotifications(cmd: CharacteristicType) : Exception(cmd.value) \ No newline at end of file +class CouldNotEnableNotifications(cmd: CharacteristicType) : Exception(cmd.value) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotParseMessageException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotParseMessageException.kt index 5e10a0bb1e..816d062636 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotParseMessageException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotParseMessageException.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti import info.nightscout.androidaps.utils.extensions.toHex -class CouldNotParseMessageException(val payload: ByteArray) : Exception("Could not parse message payload: ${payload.toHex()}") \ No newline at end of file +class CouldNotParseMessageException(val payload: ByteArray) : Exception("Could not parse message payload: ${payload.toHex()}") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendBleException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendBleException.kt index 63abcb9a68..83680ec002 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendBleException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendBleException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class CouldNotSendBleException(msg: String?) : Exception(msg) \ No newline at end of file +class CouldNotSendBleException(msg: String?) : Exception(msg) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DescriptorNotFoundException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DescriptorNotFoundException.kt index 202fcaf3b1..4a87e667e9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DescriptorNotFoundException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DescriptorNotFoundException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class DescriptorNotFoundException : Exception() \ No newline at end of file +class DescriptorNotFoundException : Exception() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DiscoveredInvalidPodException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DiscoveredInvalidPodException.kt index a4f7b52f75..5606ceb3ad 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DiscoveredInvalidPodException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/DiscoveredInvalidPodException.kt @@ -5,4 +5,4 @@ import android.os.ParcelUuid class DiscoveredInvalidPodException : Exception { constructor(message: String) : super(message) constructor(message: String, serviceUUIds: List) : super("$message service UUIDs: $serviceUUIds") -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt index 8d6782aadb..4c138d0b2e 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti open class FailedToConnectException : Exception { constructor() : super() constructor(message: String?) : super(message) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/MessageIOException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/MessageIOException.kt index 5645cb009b..1deed2f63c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/MessageIOException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/MessageIOException.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti class MessageIOException : Exception { constructor(msg: String) : super(msg) constructor(cause: Throwable) : super("Caught Exception during Message I/O", cause) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailException.kt index 396cdffcf4..15b3432ec3 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailException.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti open class ScanFailException : Exception { constructor(message: String) : super(message) constructor(errorCode: Int) : super("errorCode$errorCode") -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailFoundTooManyException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailFoundTooManyException.kt index 002ecabf3d..88d678ab88 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailFoundTooManyException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailFoundTooManyException.kt @@ -8,4 +8,4 @@ class ScanFailFoundTooManyException(devices: List) : ScanFa private val devices: List = ArrayList(devices) val discoveredDevices: List get() = Collections.unmodifiableList(devices) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailNotFoundException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailNotFoundException.kt index 55b189baff..848331257a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailNotFoundException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ScanFailNotFoundException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class ScanFailNotFoundException : ScanFailException("No Pod found") \ No newline at end of file +class ScanFailNotFoundException : ScanFailException("No Pod found") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ServiceNotFoundException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ServiceNotFoundException.kt index dc792f5825..16c19f65a9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ServiceNotFoundException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/ServiceNotFoundException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class ServiceNotFoundException(serviceUuid: String) : FailedToConnectException("service not found: $serviceUuid") \ No newline at end of file +class ServiceNotFoundException(serviceUuid: String) : FailedToConnectException("service not found: $serviceUuid") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/UnexpectedCommandException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/UnexpectedCommandException.kt index 149909032d..82a2950f2d 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/UnexpectedCommandException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/UnexpectedCommandException.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommand -class UnexpectedCommandException(val cmd: BleCommand) : Exception("Unexpected command: ${cmd}") \ No newline at end of file +class UnexpectedCommandException(val cmd: BleCommand) : Exception("Unexpected command: $cmd") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt index 3340d1daf1..de2125a2b5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt @@ -97,4 +97,4 @@ class BleIO(private val aapsLogger: AAPSLogger, private val chars: Map throw IncorrectPacketException(0, firstPacket) - fullFragments == 0 -> { + fullFragments == 0 -> { crc = ByteBuffer.wrap(firstPacket.copyOfRange(2, 6)).int.toUnsignedLong() val rest = firstPacket[6] val end = min(rest + FirstBlePacket.HEADER_SIZE_WITHOUT_MIDDLE_PACKETS, BlePacket.MAX_SIZE) @@ -41,10 +41,10 @@ class PayloadJoiner(private val firstPacket: ByteArray) { } // With middle packets - firstPacket.size < BlePacket.MAX_SIZE -> + firstPacket.size < BlePacket.MAX_SIZE -> throw IncorrectPacketException(0, firstPacket) - else -> { + else -> { fragments.add(firstPacket.copyOfRange(FirstBlePacket.HEADER_SIZE_WITH_MIDDLE_PACKETS, BlePacket.MAX_SIZE)) } } @@ -60,7 +60,7 @@ class PayloadJoiner(private val firstPacket: ByteArray) { } expectedIndex++ when { - idx < fullFragments -> { // this is a middle fragment + idx < fullFragments -> { // this is a middle fragment if (packet.size < BlePacket.MAX_SIZE) { throw IncorrectPacketException(idx.toByte(), packet) } @@ -81,7 +81,7 @@ class PayloadJoiner(private val firstPacket: ByteArray) { fragments.add(packet.copyOfRange(LastBlePacket.HEADER_SIZE, packet.size)) } - idx > fullFragments -> { // this is the extra fragment + idx > fullFragments -> { // this is the extra fragment val size = packet[1].toInt() if (packet.size < LastOptionalPlusOneBlePacket.HEADER_SIZE + size) { throw IncorrectPacketException(idx.toByte(), packet) @@ -103,7 +103,6 @@ class PayloadJoiner(private val firstPacket: ByteArray) { } return bytes.copyOfRange(0, bytes.size) } - } -internal fun Int.toUnsignedLong() = this.toLong() and 0xffffffffL \ No newline at end of file +internal fun Int.toUnsignedLong() = this.toLong() and 0xffffffffL diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitter.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitter.kt index bd5e5811db..efee6a52ae 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitter.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitter.kt @@ -15,51 +15,63 @@ internal class PayloadSplitter(private val payload: ByteArray) { val crc32 = payload.crc32() if (payload.size <= FirstBlePacket.CAPACITY_WITH_THE_OPTIONAL_PLUS_ONE_PACKET) { val end = min(FirstBlePacket.CAPACITY_WITHOUT_MIDDLE_PACKETS, payload.size) - ret.add(FirstBlePacket( - totalFragments = 0, - payload = payload.copyOfRange(0, end), - size = payload.size.toByte(), - crc32 = crc32, - )) + ret.add( + FirstBlePacket( + totalFragments = 0, + payload = payload.copyOfRange(0, end), + size = payload.size.toByte(), + crc32 = crc32, + ) + ) if (payload.size > FirstBlePacket.CAPACITY_WITHOUT_MIDDLE_PACKETS) { - ret.add(LastOptionalPlusOneBlePacket( - index = 1, - payload = payload.copyOfRange(end, payload.size), - size = (payload.size - end).toByte(), - )) + ret.add( + LastOptionalPlusOneBlePacket( + index = 1, + payload = payload.copyOfRange(end, payload.size), + size = (payload.size - end).toByte(), + ) + ) } return ret } val middleFragments = (payload.size - FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS) / MiddleBlePacket.CAPACITY val rest = ((payload.size - middleFragments * MiddleBlePacket.CAPACITY) - FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS).toByte() - ret.add(FirstBlePacket( - totalFragments = (middleFragments + 1).toByte(), - payload = payload.copyOfRange(0, FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS), - )) + ret.add( + FirstBlePacket( + totalFragments = (middleFragments + 1).toByte(), + payload = payload.copyOfRange(0, FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS), + ) + ) for (i in 1..middleFragments) { val p = if (i == 1) { payload.copyOfRange(FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS, FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + MiddleBlePacket.CAPACITY) } else { payload.copyOfRange(FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + (i - 1) * MiddleBlePacket.CAPACITY, FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + i * MiddleBlePacket.CAPACITY) } - ret.add(MiddleBlePacket( - index = i.toByte(), - payload = p, - )) + ret.add( + MiddleBlePacket( + index = i.toByte(), + payload = p, + ) + ) } val end = min(LastBlePacket.CAPACITY, rest.toInt()) - ret.add(LastBlePacket( - index = (middleFragments + 1).toByte(), - size = rest, - payload = payload.copyOfRange(middleFragments * MiddleBlePacket.CAPACITY + FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS, middleFragments * MiddleBlePacket.CAPACITY + FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + end), - crc32 = crc32, - )) + ret.add( + LastBlePacket( + index = (middleFragments + 1).toByte(), + size = rest, + payload = payload.copyOfRange(middleFragments * MiddleBlePacket.CAPACITY + FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS, middleFragments * MiddleBlePacket.CAPACITY + FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + end), + crc32 = crc32, + ) + ) if (rest > LastBlePacket.CAPACITY) { - ret.add(LastOptionalPlusOneBlePacket( - index = (middleFragments + 2).toByte(), - size = (rest - LastBlePacket.CAPACITY).toByte(), - payload = payload.copyOfRange(middleFragments * MiddleBlePacket.CAPACITY + FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + LastBlePacket.CAPACITY, payload.size), - )) + ret.add( + LastOptionalPlusOneBlePacket( + index = (middleFragments + 2).toByte(), + size = (rest - LastBlePacket.CAPACITY).toByte(), + payload = payload.copyOfRange(middleFragments * MiddleBlePacket.CAPACITY + FirstBlePacket.CAPACITY_WITH_MIDDLE_PACKETS + LastBlePacket.CAPACITY, payload.size), + ) + ) } return ret } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt index 7ec6048aed..786a210bfb 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt @@ -18,21 +18,21 @@ class StringLengthPrefixEncoding { var remaining = payload for ((index, key) in keys.withIndex()) { when { - remaining.size < key.length -> - throw MessageIOException("Payload too short: ${payload.toHex()} for key: ${key}") + remaining.size < key.length -> + throw MessageIOException("Payload too short: ${payload.toHex()} for key: $key") !(remaining.copyOfRange(0, key.length).decodeToString() == key) -> - throw MessageIOException("Key not found: ${key} in ${payload.toHex()}") + throw MessageIOException("Key not found: $key in ${payload.toHex()}") // last key can be empty, no length - index == keys.size - 1 && remaining.size == key.length -> + index == keys.size - 1 && remaining.size == key.length -> return ret - remaining.size < key.length + LENGTH_BYTES -> - throw MessageIOException("Length not found: for ${key} in ${payload.toHex()}") + remaining.size < key.length + LENGTH_BYTES -> + throw MessageIOException("Length not found: for $key in ${payload.toHex()}") } remaining = remaining.copyOfRange(key.length, remaining.size) val length = (remaining[0].toUnsignedInt() shl 1) or remaining[1].toUnsignedInt() if (length > remaining.size) { - throw MessageIOException("Payload too short, looking for length ${length} for ${key} in ${payload.toHex()}") + throw MessageIOException("Payload too short, looking for length $length for $key in ${payload.toHex()}") } ret[index] = remaining.copyOfRange(LENGTH_BYTES, LENGTH_BYTES + length) remaining = remaining.copyOfRange(LENGTH_BYTES + length, remaining.size) @@ -60,4 +60,4 @@ class StringLengthPrefixEncoding { return ret } } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt index eb020c5b28..7bb51c2789 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt @@ -92,4 +92,3 @@ data class LastOptionalPlusOneBlePacket(val index: Byte, val payload: ByteArray, internal const val HEADER_SIZE = 2 } } - diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt index cc76bd232f..a6cc8b3bb5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt @@ -253,4 +253,4 @@ private fun aesCmac(key: ByteArray, data: ByteArray, result: ByteArray) { mac.init(KeyParameter(key)) mac.update(data, 0, data.size) mac.doFinal(result, 0) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/PairMessage.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/PairMessage.kt index f36baea723..af705fd720 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/PairMessage.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/PairMessage.kt @@ -17,4 +17,4 @@ data class PairMessage( sequenceNumber = sequenceNumber, sas = true // TODO: understand why this is true for PairMessages ), -) \ No newline at end of file +) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/BleDiscoveredDevice.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/BleDiscoveredDevice.kt index bf3d3dd74c..4439eecf95 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/BleDiscoveredDevice.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/BleDiscoveredDevice.kt @@ -15,7 +15,6 @@ class BleDiscoveredDevice(val scanResult: ScanResult, private val scanRecord: Sc val serviceUuids = scanRecord.serviceUuids if (serviceUuids.size != 9) { throw DiscoveredInvalidPodException("Expected 9 service UUIDs, got" + serviceUuids.size, serviceUuids) - } if (extractUUID16(serviceUuids[0]) != MAIN_SERVICE_UUID) { // this is the service that we filtered for @@ -79,4 +78,4 @@ class BleDiscoveredDevice(val scanResult: ScanResult, private val scanRecord: Sc lotNo = parseLotNo() sequenceNo = parseSeqNo() } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt index e898b755fe..4a9932a4de 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt @@ -45,4 +45,4 @@ class PodScanner(private val logger: AAPSLogger, private val bluetoothAdapter: B const val POD_ID_NOT_ACTIVATED = 0xFFFFFFFFL private const val SCAN_DURATION_MS = 5000 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt index 658f3b69ff..82c249d492 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt @@ -45,5 +45,4 @@ class ScanCollector(private val logger: AAPSLogger, private val podID: Long) : S } return Collections.unmodifiableList(ret) } - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt index 3f11ca87b5..8343887516 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.status enum class ConnectionStatus { CONNECTED, NOT_CONNECTED; -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/event/PodEvent.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/event/PodEvent.kt index 0bc6bf5125..b0429dd1d5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/event/PodEvent.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/event/PodEvent.kt @@ -20,4 +20,3 @@ sealed class PodEvent { class CommandSent(val command: Command) : PodEvent() class ResponseReceived(val response: Response) : PodEvent() } - diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommand.kt index ec122495bc..da35042d78 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommand.kt @@ -13,12 +13,14 @@ class DeactivateCommand private constructor( ) : NonceEnabledCommand(CommandType.DEACTIVATE, uniqueId, sequenceNumber, multiCommandFlag, nonce) { override val encoded: ByteArray - get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .putInt(nonce) // - .array()) + get() = appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .putInt(nonce) // + .array() + ) override fun toString(): String = "DeactivateCommand{" + "nonce=" + nonce + @@ -39,4 +41,4 @@ class DeactivateCommand private constructor( private const val LENGTH: Short = 6 private const val BODY_LENGTH: Byte = 4 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt index ac9228125a..b5f262da17 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt @@ -14,12 +14,14 @@ class GetStatusCommand private constructor( ) : HeaderEnabledCommand(CommandType.GET_STATUS, uniqueId, sequenceNumber, multiCommandFlag) { override val encoded: ByteArray - get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .put(statusResponseType.value) // - .array()) + get() = appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .put(statusResponseType.value) // + .array() + ) class Builder : HeaderEnabledCommandBuilder() { @@ -35,7 +37,6 @@ class GetStatusCommand private constructor( return GetStatusCommand(uniqueId!!, sequenceNumber!!, multiCommandFlag, statusResponseType!!) } - } companion object { @@ -43,4 +44,4 @@ class GetStatusCommand private constructor( private const val LENGTH: Short = 3 private const val BODY_LENGTH: Byte = 1 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt index a06a3624e6..26c480e999 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt @@ -12,12 +12,14 @@ class GetVersionCommand private constructor( ) : HeaderEnabledCommand(CommandType.GET_VERSION, uniqueId, sequenceNumber, multiCommandFlag) { override val encoded: ByteArray - get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .putInt(uniqueId) // - .array()) + get() = appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .putInt(uniqueId) // + .array() + ) override fun toString(): String { return "GetVersionCommand{" + @@ -41,4 +43,4 @@ class GetVersionCommand private constructor( private const val LENGTH: Short = 6 private const val BODY_LENGTH: Byte = 4 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommand.kt index 44c8505a49..11191e8812 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommand.kt @@ -67,4 +67,4 @@ class ProgramAlertsCommand private constructor( init { this.alertConfigurations = ArrayList(alertConfigurations) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt index 9e9afdd3d3..17d83d3e5a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt @@ -49,11 +49,13 @@ class ProgramBasalCommand private constructor( val basalCommand = buffer.array() val interlockCommand = interlockCommand.encoded val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (basalCommand.size + interlockCommand.size).toShort(), multiCommandFlag) - return appendCrc(ByteBuffer.allocate(basalCommand.size + interlockCommand.size + header.size) // - .put(header) // - .put(interlockCommand) // - .put(basalCommand) // - .array()) + return appendCrc( + ByteBuffer.allocate(basalCommand.size + interlockCommand.size + header.size) // + .put(header) // + .put(interlockCommand) // + .put(basalCommand) // + .array() + ) } override fun toString(): String { @@ -102,12 +104,16 @@ class ProgramBasalCommand private constructor( val longInsulinProgramElements: List = mapTenthPulsesPerSlotToLongInsulinProgramElements(ProgramBasalUtil.mapBasalProgramToTenthPulsesPerSlot(basalProgram!!)) val shortInsulinProgramElements = ProgramBasalUtil.mapPulsesPerSlotToShortInsulinProgramElements(pulsesPerSlot) val currentBasalInsulinProgramElement = ProgramBasalUtil.calculateCurrentLongInsulinProgramElement(longInsulinProgramElements, currentTime) - val interlockCommand = ProgramInsulinCommand(uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, + val interlockCommand = ProgramInsulinCommand( + uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, shortInsulinProgramElements, checksum, currentSlot.index, currentSlot.eighthSecondsRemaining, - currentSlot.pulsesRemaining, ProgramInsulinCommand.DeliveryType.BASAL) - return ProgramBasalCommand(interlockCommand, uniqueId!!, sequenceNumber!!, multiCommandFlag, + currentSlot.pulsesRemaining, ProgramInsulinCommand.DeliveryType.BASAL + ) + return ProgramBasalCommand( + interlockCommand, uniqueId!!, sequenceNumber!!, multiCommandFlag, longInsulinProgramElements, programReminder!!, currentBasalInsulinProgramElement.index, - currentBasalInsulinProgramElement.remainingTenthPulses, currentBasalInsulinProgramElement.delayUntilNextTenthPulseInUsec) + currentBasalInsulinProgramElement.remainingTenthPulses, currentBasalInsulinProgramElement.delayUntilNextTenthPulseInUsec + ) } } @@ -118,4 +124,4 @@ class ProgramBasalCommand private constructor( this.remainingTenthPulsesInCurrentInsulinProgramElement = remainingTenthPulsesInCurrentInsulinProgramElement this.delayUntilNextTenthPulseInUsec = delayUntilNextTenthPulseInUsec } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt index d9412e7363..a6f2efd180 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt @@ -18,15 +18,17 @@ class ProgramBeepsCommand private constructor( ) : HeaderEnabledCommand(CommandType.PROGRAM_BEEPS, uniqueId, sequenceNumber, multiCommandFlag) { override val encoded: ByteArray - get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .put(immediateBeepType.value) // - .put(basalReminder.encoded) // - .put(tempBasalReminder.encoded) // - .put(bolusReminder.encoded) // - .array()) + get() = appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .put(immediateBeepType.value) // + .put(basalReminder.encoded) // + .put(tempBasalReminder.encoded) // + .put(bolusReminder.encoded) // + .array() + ) class Builder : HeaderEnabledCommandBuilder() { @@ -70,4 +72,4 @@ class ProgramBeepsCommand private constructor( private const val LENGTH: Short = 6 private const val BODY_LENGTH: Byte = 4 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt index c02f1d3ef0..c16533501f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt @@ -32,11 +32,13 @@ class ProgramBolusCommand private constructor( .array() val interlockCommand = interlockCommand.encoded val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (bolusCommand.size + interlockCommand.size).toShort(), multiCommandFlag) - return appendCrc(ByteBuffer.allocate(header.size + interlockCommand.size + bolusCommand.size) // - .put(header) // - .put(interlockCommand) // - .put(bolusCommand) // - .array()) + return appendCrc( + ByteBuffer.allocate(header.size + interlockCommand.size + bolusCommand.size) // + .put(header) // + .put(interlockCommand) // + .put(bolusCommand) // + .array() + ) } override fun toString(): String { @@ -82,8 +84,10 @@ class ProgramBolusCommand private constructor( val numberOfPulses = Math.round(numberOfUnits!! * 20).toShort() val byte10And11 = (numberOfPulses * delayBetweenPulsesInEighthSeconds!!).toShort() - val interlockCommand = ProgramInsulinCommand(uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, listOf(BolusShortInsulinProgramElement(numberOfPulses)), calculateChecksum(0x01.toByte(), byte10And11, numberOfPulses), - 0x01.toByte(), byte10And11, numberOfPulses, ProgramInsulinCommand.DeliveryType.BOLUS) + val interlockCommand = ProgramInsulinCommand( + uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, listOf(BolusShortInsulinProgramElement(numberOfPulses)), calculateChecksum(0x01.toByte(), byte10And11, numberOfPulses), + 0x01.toByte(), byte10And11, numberOfPulses, ProgramInsulinCommand.DeliveryType.BOLUS + ) val delayUntilFirstTenthPulseInUsec = delayBetweenPulsesInEighthSeconds!! / 8 * 100000 return ProgramBolusCommand(interlockCommand, uniqueId!!, sequenceNumber!!, multiCommandFlag, programReminder!!, (numberOfPulses * 10).toShort(), delayUntilFirstTenthPulseInUsec) } @@ -94,12 +98,14 @@ class ProgramBolusCommand private constructor( private const val LENGTH: Short = 15 private const val BODY_LENGTH: Byte = 13 private fun calculateChecksum(numberOfSlots: Byte, byte10And11: Short, numberOfPulses: Short): Short { - return MessageUtil.calculateChecksum(ByteBuffer.allocate(7) // - .put(numberOfSlots) // - .putShort(byte10And11) // - .putShort(numberOfPulses) // - .putShort(numberOfPulses) // - .array()) + return MessageUtil.calculateChecksum( + ByteBuffer.allocate(7) // + .put(numberOfSlots) // + .putShort(byte10And11) // + .putShort(numberOfPulses) // + .putShort(numberOfPulses) // + .array() + ) } } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramInsulinCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramInsulinCommand.kt index 0020407056..437d52029c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramInsulinCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramInsulinCommand.kt @@ -11,8 +11,9 @@ class ProgramInsulinCommand internal constructor( uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, - nonce: Int, insulinProgramElements: - List, + nonce: Int, + insulinProgramElements: + List, private val checksum: Short, private val byte9: Byte, private val byte10And11: Short, @@ -66,4 +67,4 @@ class ProgramInsulinCommand internal constructor( ", multiCommandFlag=" + multiCommandFlag + '}' } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt index c0179ed62e..987cd0cca8 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt @@ -59,9 +59,11 @@ class ProgramTempBasalCommand private constructor( val tenthPulsesPerSlot = ProgramTempBasalUtil.mapTempBasalToTenthPulsesPerSlot(durationInSlots.toInt(), rateInUnitsPerHour!!) val shortInsulinProgramElements = ProgramTempBasalUtil.mapPulsesPerSlotToShortInsulinProgramElements(pulsesPerSlot) val insulinProgramElements = ProgramTempBasalUtil.mapTenthPulsesPerSlotToLongInsulinProgramElements(tenthPulsesPerSlot) - val interlockCommand = ProgramInsulinCommand(uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, shortInsulinProgramElements, + val interlockCommand = ProgramInsulinCommand( + uniqueId!!, sequenceNumber!!, multiCommandFlag, nonce!!, shortInsulinProgramElements, ProgramTempBasalUtil.calculateChecksum(durationInSlots, pulsesPerSlot[0], pulsesPerSlot), durationInSlots, - 0x3840.toShort(), pulsesPerSlot[0], ProgramInsulinCommand.DeliveryType.TEMP_BASAL) + 0x3840.toShort(), pulsesPerSlot[0], ProgramInsulinCommand.DeliveryType.TEMP_BASAL + ) return ProgramTempBasalCommand(interlockCommand, uniqueId!!, sequenceNumber!!, multiCommandFlag, programReminder!!, insulinProgramElements) } } @@ -91,10 +93,12 @@ class ProgramTempBasalCommand private constructor( val tempBasalCommand = buffer.array() val interlockCommand = interlockCommand.encoded val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (tempBasalCommand.size + interlockCommand.size).toShort(), multiCommandFlag) - return appendCrc(ByteBuffer.allocate(header.size + interlockCommand.size + tempBasalCommand.size) // - .put(header) // - .put(interlockCommand) // - .put(tempBasalCommand) // - .array()) + return appendCrc( + ByteBuffer.allocate(header.size + interlockCommand.size + tempBasalCommand.size) // + .put(header) // + .put(interlockCommand) // + .put(tempBasalCommand) // + .array() + ) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt index 04d62e99ac..e70b7629dc 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt @@ -16,17 +16,19 @@ class SetUniqueIdCommand private constructor( ) : HeaderEnabledCommand(CommandType.SET_UNIQUE_ID, uniqueId, sequenceNumber, multiCommandFlag) { override val encoded: ByteArray - get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(DEFAULT_UNIQUE_ID, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .putInt(uniqueId) // - .put(0x14.toByte()) // FIXME ?? - .put(0x04.toByte()) // FIXME ?? - .put(encodeInitializationTime(initializationTime)) // - .putInt(lotNumber) // - .putInt(podSequenceNumber) // - .array()) + get() = appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(DEFAULT_UNIQUE_ID, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .putInt(uniqueId) // + .put(0x14.toByte()) // FIXME ?? + .put(0x04.toByte()) // FIXME ?? + .put(encodeInitializationTime(initializationTime)) // + .putInt(lotNumber) // + .putInt(podSequenceNumber) // + .array() + ) override fun toString(): String { return "SetUniqueIdCommand{" + @@ -78,12 +80,12 @@ class SetUniqueIdCommand private constructor( val instance = Calendar.getInstance() instance.time = date return byteArrayOf( // - (instance[Calendar.MONTH] + 1).toByte(), // - instance[Calendar.DATE].toByte(), // - (instance[Calendar.YEAR] % 100).toByte(), // - instance[Calendar.HOUR_OF_DAY].toByte(), // + (instance[Calendar.MONTH] + 1).toByte(), // + instance[Calendar.DATE].toByte(), // + (instance[Calendar.YEAR] % 100).toByte(), // + instance[Calendar.HOUR_OF_DAY].toByte(), // instance[Calendar.MINUTE].toByte() // ) } } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt index 1b3c531ee9..68d2738c89 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt @@ -18,13 +18,15 @@ class SilenceAlertsCommand private constructor( override val encoded: ByteArray get() = - appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .putInt(nonce) // - .put(AlertUtil.encodeAlertSet(alertTypes)) // - .array()) + appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .putInt(nonce) // + .put(AlertUtil.encodeAlertSet(alertTypes)) // + .array() + ) override fun toString(): String { return "SilenceAlertsCommand{" + @@ -57,4 +59,4 @@ class SilenceAlertsCommand private constructor( private const val LENGTH = 7.toShort() private const val BODY_LENGTH = 5.toByte() } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt index 603a7ff09d..17ee811b30 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt @@ -19,13 +19,15 @@ class StopDeliveryCommand private constructor( override val encoded: ByteArray get() { - return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // - .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // - .put(commandType.value) // - .put(BODY_LENGTH) // - .putInt(nonce) // - .put((beepType.value.toInt() shl 4 or deliveryType.encoded[0].toInt()).toByte()) // - .array()) + return appendCrc( + ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .putInt(nonce) // + .put((beepType.value.toInt() shl 4 or deliveryType.encoded[0].toInt()).toByte()) // + .array() + ) } override fun toString(): String { @@ -81,4 +83,4 @@ class StopDeliveryCommand private constructor( private const val LENGTH: Short = 7 private const val BODY_LENGTH: Byte = 5 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/Command.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/Command.kt index bbe29cb2e5..0b509a8ae1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/Command.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/Command.kt @@ -6,4 +6,4 @@ import java.io.Serializable interface Command : Encodable, Serializable { val commandType: CommandType -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/CommandType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/CommandType.kt index 1cc50ff135..1cbcf8ae97 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/CommandType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/CommandType.kt @@ -6,12 +6,12 @@ enum class CommandType(val value: Byte) { GET_VERSION(0x07.toByte()), GET_STATUS(0x0e.toByte()), SILENCE_ALERTS(0x11.toByte()), - PROGRAM_BASAL(0x13.toByte()), // Always preceded by 0x1a - PROGRAM_TEMP_BASAL(0x16.toByte()), // Always preceded by 0x1a - PROGRAM_BOLUS(0x17.toByte()), // Always preceded by 0x1a + PROGRAM_BASAL(0x13.toByte()), // Always preceded by 0x1a + PROGRAM_TEMP_BASAL(0x16.toByte()), // Always preceded by 0x1a + PROGRAM_BOLUS(0x17.toByte()), // Always preceded by 0x1a PROGRAM_ALERTS(0x19.toByte()), - PROGRAM_INSULIN(0x1a.toByte()), // Always followed by one of: 0x13, 0x16, 0x17 + PROGRAM_INSULIN(0x1a.toByte()), // Always followed by one of: 0x13, 0x16, 0x17 DEACTIVATE(0x1c.toByte()), PROGRAM_BEEPS(0x1e.toByte()), STOP_DELIVERY(0x1f.toByte()); -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/NonceEnabledCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/NonceEnabledCommand.kt index ef905673e9..5d943a777f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/NonceEnabledCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/NonceEnabledCommand.kt @@ -6,4 +6,4 @@ abstract class NonceEnabledCommand protected constructor( sequenceNumber: Short, multiCommandFlag: Boolean, protected val nonce: Int -) : HeaderEnabledCommand(commandType, uniqueId, sequenceNumber, multiCommandFlag) \ No newline at end of file +) : HeaderEnabledCommand(commandType, uniqueId, sequenceNumber, multiCommandFlag) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/CommandBuilder.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/CommandBuilder.kt index 1798f08ca8..3e7aa921de 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/CommandBuilder.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/CommandBuilder.kt @@ -5,4 +5,4 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b interface CommandBuilder { fun build(): R -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/HeaderEnabledCommandBuilder.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/HeaderEnabledCommandBuilder.kt index f6fc7151b8..046d990b5e 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/HeaderEnabledCommandBuilder.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/HeaderEnabledCommandBuilder.kt @@ -31,4 +31,4 @@ abstract class HeaderEnabledCommandBuilder } protected abstract fun buildCommand(): R -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/NonceEnabledCommandBuilder.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/NonceEnabledCommandBuilder.kt index 04ee98a2d3..04e14ac856 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/NonceEnabledCommandBuilder.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/base/builder/NonceEnabledCommandBuilder.kt @@ -15,4 +15,4 @@ abstract class NonceEnabledCommandBuilder, this.nonce = nonce return this as T } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalInsulinProgramElement.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalInsulinProgramElement.kt index cb700d64f2..8e9f2eabb9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalInsulinProgramElement.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalInsulinProgramElement.kt @@ -31,4 +31,4 @@ open class BasalInsulinProgramElement( ", delayBetweenTenthPulsesInUsec=" + delayBetweenTenthPulsesInUsec + '}' } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalShortInsulinProgramElement.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalShortInsulinProgramElement.kt index f30c4a8170..5d84e12ca3 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalShortInsulinProgramElement.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BasalShortInsulinProgramElement.kt @@ -5,15 +5,17 @@ import kotlin.experimental.and class BasalShortInsulinProgramElement( private val numberOfSlots: Byte, // 4 bits - private val pulsesPerSlot: Short, //10 bits + private val pulsesPerSlot: Short, // 10 bits private val extraAlternatePulse: Boolean ) : ShortInsulinProgramElement { override val encoded: ByteArray get() { - val firstByte = (numberOfSlots - 1 and 0x0f shl 4 // - or ((if (extraAlternatePulse) 1 else 0) shl 3) // - or (pulsesPerSlot.toInt() ushr 8 and 0x03)).toByte() + val firstByte = ( + numberOfSlots - 1 and 0x0f shl 4 // + or ((if (extraAlternatePulse) 1 else 0) shl 3) // + or (pulsesPerSlot.toInt() ushr 8 and 0x03) + ).toByte() return ByteBuffer.allocate(2) // .put(firstByte) // .put((pulsesPerSlot and 0xff).toByte()) // @@ -27,4 +29,4 @@ class BasalShortInsulinProgramElement( ", extraAlternatePulse=" + extraAlternatePulse + '}' } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BolusShortInsulinProgramElement.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BolusShortInsulinProgramElement.kt index 6a2948404b..6527662b3c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BolusShortInsulinProgramElement.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/BolusShortInsulinProgramElement.kt @@ -8,4 +8,4 @@ class BolusShortInsulinProgramElement( override val encoded: ByteArray get() = ByteBuffer.allocate(2).putShort(numberOfPulses).array() -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentBasalInsulinProgramElement.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentBasalInsulinProgramElement.kt index 04f27cf9bf..66d8efe3d7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentBasalInsulinProgramElement.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentBasalInsulinProgramElement.kt @@ -13,4 +13,4 @@ class CurrentBasalInsulinProgramElement( ", delayUntilNextTenthPulseInUsec=" + delayUntilNextTenthPulseInUsec + ", remainingTenthPulses=" + remainingTenthPulses + '}' -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentSlot.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentSlot.kt index 49b2af59dc..077318299d 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentSlot.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/CurrentSlot.kt @@ -13,4 +13,4 @@ class CurrentSlot( ", eighthSecondsRemaining=" + eighthSecondsRemaining + ", pulsesRemaining=" + pulsesRemaining + '}' -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/ShortInsulinProgramElement.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/ShortInsulinProgramElement.kt index 2ff92c2c24..ac7e66a81a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/ShortInsulinProgramElement.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/ShortInsulinProgramElement.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.Encodable import java.io.Serializable -interface ShortInsulinProgramElement : Encodable, Serializable \ No newline at end of file +interface ShortInsulinProgramElement : Encodable, Serializable diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/TempBasalInsulinProgramElement.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/TempBasalInsulinProgramElement.kt index 4c58755591..a1b5f9310b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/TempBasalInsulinProgramElement.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/TempBasalInsulinProgramElement.kt @@ -21,4 +21,4 @@ class TempBasalInsulinProgramElement( } return buffer.array() } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt index 93b144787f..6c789796a0 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt @@ -205,4 +205,4 @@ object ProgramBasalUtil { } return MessageUtil.calculateChecksum(buffer.array()) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramTempBasalUtil.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramTempBasalUtil.kt index 8c66abc626..3cdf5299ed 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramTempBasalUtil.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramTempBasalUtil.kt @@ -59,4 +59,4 @@ object ProgramTempBasalUtil { fun mapPulsesPerSlotToShortInsulinProgramElements(pulsesPerSlot: ShortArray?): List = ProgramBasalUtil.mapPulsesPerSlotToShortInsulinProgramElements(pulsesPerSlot) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt index f9455e5528..fc7f1f33fc 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ActivationProgress.kt @@ -18,4 +18,4 @@ enum class ActivationProgress { fun isBefore(other: ActivationProgress): Boolean = ordinal < other.ordinal fun isAtLeast(other: ActivationProgress): Boolean = ordinal >= other.ordinal -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlarmType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlarmType.kt index 90f794a3cb..fdb6729124 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlarmType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlarmType.kt @@ -159,5 +159,4 @@ enum class AlarmType(override val value: Byte) : HasValue { ALARM_BLE_QN_EXCEED_MAX_RETRY(0xc1.toByte()), ALARM_BLE_QN_CRIT_VAR_FAIL(0xc2.toByte()), UNKNOWN(0xff.toByte()); - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt index 4040ac5831..aab7cde138 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertConfiguration.kt @@ -29,15 +29,17 @@ class AlertConfiguration( return ByteBuffer.allocate(6) // .put(firstByte) .put(durationInMinutes.toByte()) // - .putShort(when (trigger) { - is AlertTrigger.ReservoirVolumeTrigger -> { - trigger.thresholdInMicroLiters - } + .putShort( + when (trigger) { + is AlertTrigger.ReservoirVolumeTrigger -> { + trigger.thresholdInMicroLiters + } - is AlertTrigger.TimerTrigger -> { - trigger.offsetInMinutes + is AlertTrigger.TimerTrigger -> { + trigger.offsetInMinutes + } } - }) // + ) // .put(beepRepetition.value) // .put(beepType.value) // .array() @@ -54,4 +56,4 @@ class AlertConfiguration( ", beepRepetition=" + beepRepetition + '}' } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertTrigger.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertTrigger.kt index 48df9b25bf..7c76903127 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertTrigger.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertTrigger.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definiti sealed class AlertTrigger { class TimerTrigger(val offsetInMinutes: Short) : AlertTrigger() class ReservoirVolumeTrigger(val thresholdInMicroLiters: Short) : AlertTrigger() -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertType.kt index ec6d472066..8ee60d2568 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/AlertType.kt @@ -20,4 +20,4 @@ enum class AlertType(val index: Byte) : HasValue { } else { (1 shl index.toInt()).toByte() } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BasalProgram.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BasalProgram.kt index ef8f764f91..b003fba0d1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BasalProgram.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BasalProgram.kt @@ -87,4 +87,4 @@ class BasalProgram( override fun hashCode(): Int { return segments.hashCode() } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt index 402141e875..0668852456 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepRepetitionType.kt @@ -10,5 +10,4 @@ enum class BeepRepetitionType( XXX3(0x05.toByte()), // Used in user pod expiration alert XXX4(0x06.toByte()), // Used in pod expiration alert XXX5(0x08.toByte()); // Used in imminent pod expiration alert - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepType.kt index d997663b6f..ad41a53654 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/BeepType.kt @@ -5,4 +5,4 @@ enum class BeepType(val value: Byte) { SILENT(0x00.toByte()), FOUR_TIMES_BIP_BEEP(0x02.toByte()), // Used in low reservoir alert, user expiration alert, expiration alert, imminent expiration alert, lump of coal alert LONG_SINGLE_BEEP(0x06.toByte()); // Used in stop delivery command -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/DeliveryStatus.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/DeliveryStatus.kt index daaedab7db..db2a6b3710 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/DeliveryStatus.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/DeliveryStatus.kt @@ -11,4 +11,4 @@ enum class DeliveryStatus(override val value: Byte) : HasValue { BOLUS_AND_BASAL_ACTIVE(0x05.toByte()), BOLUS_AND_TEMP_BASAL_ACTIVE(0x06.toByte()), UNKNOWN(0xff.toByte()); -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/Encodable.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/Encodable.kt index 28276e2abf..94f5798175 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/Encodable.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/Encodable.kt @@ -3,4 +3,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definiti interface Encodable { val encoded: ByteArray -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/NakErrorType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/NakErrorType.kt index e3f110e565..c700c11388 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/NakErrorType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/NakErrorType.kt @@ -34,4 +34,4 @@ enum class NakErrorType(override val value: Byte) : HasValue { IGNORE_COMMAND(0x1c.toByte()), INVALID_CRC(0x1d.toByte()), UNKNOWN(0xff.toByte()); -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodStatus.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodStatus.kt index b5d0dadacf..9dca9d1c57 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodStatus.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodStatus.kt @@ -23,4 +23,4 @@ enum class PodStatus(override val value: Byte) : HasValue { UNKNOWN(0xff.toByte()); fun isRunning(): Boolean = this == RUNNING_ABOVE_MIN_VOLUME || this == RUNNING_BELOW_MIN_VOLUME -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ProgramReminder.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ProgramReminder.kt index 09a63370f0..371f90d9e4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ProgramReminder.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/ProgramReminder.kt @@ -10,7 +10,11 @@ class ProgramReminder( ) : Encodable, Serializable { override val encoded: ByteArray - get() = byteArrayOf(((if (atStart) 1 else 0) shl 7 - or ((if (atEnd) 1 else 0) shl 6) - or ((atInterval and 0x3f).toInt())).toByte()) -} \ No newline at end of file + get() = byteArrayOf( + ( + (if (atStart) 1 else 0) shl 7 + or ((if (atEnd) 1 else 0) shl 6) + or ((atInterval and 0x3f).toInt()) + ).toByte() + ) +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ActivationResponseBase.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ActivationResponseBase.kt index 676bc85c07..d12ce055ea 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ActivationResponseBase.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ActivationResponseBase.kt @@ -5,4 +5,4 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response. abstract class ActivationResponseBase( val activationResponseType: ActivationResponseType, encoded: ByteArray -) : ResponseBase(ResponseType.ACTIVATION_RESPONSE, encoded) \ No newline at end of file +) : ResponseBase(ResponseType.ACTIVATION_RESPONSE, encoded) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt index 0ce01d962d..501033468a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt @@ -5,4 +5,4 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response. open class AdditionalStatusResponseBase internal constructor( val statusResponseType: StatusResponseType, encoded: ByteArray -) : ResponseBase(ResponseType.ADDITIONAL_STATUS_RESPONSE, encoded) \ No newline at end of file +) : ResponseBase(ResponseType.ADDITIONAL_STATUS_RESPONSE, encoded) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt index 847eaa903c..333af17c03 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt @@ -84,5 +84,4 @@ class AlarmStatusResponse( } infix fun Byte.shr(i: Int): Int = toInt() shr i - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt index fde2951b31..c0424c5822 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt @@ -34,7 +34,6 @@ class DefaultStatusResponse( ", minutesSinceActivation=$minutesSinceActivation" + ", reservoirPulsesRemaining=$reservoirPulsesRemaining)" } - } infix fun Byte.ushr(i: Int) = toInt() ushr i diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt index 0cde181a8d..f2a6cfb1cd 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt @@ -46,4 +46,4 @@ class NakResponse( ", encoded=" + encoded.contentToString() + '}' } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/Response.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/Response.kt index 0f1a0f06a0..f64cca766c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/Response.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/Response.kt @@ -6,4 +6,4 @@ interface Response : Serializable { val responseType: ResponseType val encoded: ByteArray -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseBase.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseBase.kt index 1df5c6f988..9eacc0d1ef 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseBase.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseBase.kt @@ -6,5 +6,4 @@ abstract class ResponseBase( ) : Response { override val encoded: ByteArray = encoded.copyOf(encoded.size) - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt index 10d355f380..283a1cd284 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt @@ -30,4 +30,4 @@ enum class ResponseType(override val value: Byte) : HasValue { SET_UNIQUE_ID_RESPONSE(0x1b.toByte()), UNKNOWN(0xff.toByte()); } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponse.kt index e91b750a6a..f0153ef5e7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponse.kt @@ -55,5 +55,4 @@ class SetUniqueIdResponse( ", encoded=" + encoded.contentToString() + '}' } - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponse.kt index 243c191efb..59165eb0f4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponse.kt @@ -49,5 +49,4 @@ class VersionResponse( ", encoded=" + Arrays.toString(encoded) + '}' } - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt index a97cad8974..8270e1cd18 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt @@ -53,4 +53,4 @@ interface OmnipodDashPodStateManager { fun reset() data class TempBasal(val startTime: Long, val rate: Double, val durationInMinutes: Short) : Serializable -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index 78254c74e8..fb528cc1ec 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -261,4 +261,4 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( var basalProgram: BasalProgram? = null var tempBasal: OmnipodDashPodStateManager.TempBasal? = null } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/AlertUtil.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/AlertUtil.kt index 4a63fd91fa..9d5db05579 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/AlertUtil.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/AlertUtil.kt @@ -20,9 +20,10 @@ object AlertUtil { } fun encodeAlertSet(alertSet: EnumSet): Byte = - alertSet.fold(0, + alertSet.fold( + 0, { out, slot -> out or (slot.value.toInt() and 0xff) } ).toByte() -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/HasValue.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/HasValue.kt index 3794ddf850..0976efd028 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/HasValue.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/HasValue.kt @@ -7,4 +7,4 @@ interface HasValue { inline fun byValue(value: Byte, default: T): T where T : Enum, T : HasValue { return enumValues().firstOrNull { it.value == value } ?: default -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/MessageUtil.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/MessageUtil.kt index b9ff49d4b3..5699d004be 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/MessageUtil.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/MessageUtil.kt @@ -42,4 +42,4 @@ object MessageUtil { } return sum } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt index b5c1c5367d..d8c9bf36c1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt @@ -38,22 +38,24 @@ class DashHistory @Inject constructor( val id = ULID.random() when { - commandType == SET_BOLUS && bolusRecord == null -> + commandType == SET_BOLUS && bolusRecord == null -> return Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS")) commandType == SET_TEMPORARY_BASAL && tempBasalRecord == null -> return Single.error(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL")) } - return dao.save(HistoryRecordEntity( - id = id, - date = date, - createdAt = currentTimeMillis(), - commandType = commandType, - tempBasalRecord = tempBasalRecord, - bolusRecord = bolusRecord, - initialResult = initialResult, - resolvedResult = resolveResult, - resolvedAt = resolvedAt) + return dao.save( + HistoryRecordEntity( + id = id, + date = date, + createdAt = currentTimeMillis(), + commandType = commandType, + tempBasalRecord = tempBasalRecord, + bolusRecord = bolusRecord, + initialResult = initialResult, + resolvedResult = resolveResult, + resolvedAt = resolvedAt + ) ).toSingle { id } } @@ -61,5 +63,4 @@ class DashHistory @Inject constructor( dao.all().map { list -> list.map(historyMapper::entityToDomain) } fun getRecordsAfter(time: Long): Single> = dao.allSince(time) - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/Record.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/Record.kt index 6344c9fcd7..a4f636c497 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/Record.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/Record.kt @@ -2,10 +2,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data sealed class Record -data class BolusRecord(val amout: Double, val bolusType: BolusType): Record() +data class BolusRecord(val amout: Double, val bolusType: BolusType) : Record() -data class TempBasalRecord(val duration: Long, val rate: Double): Record() +data class TempBasalRecord(val duration: Long, val rate: Double) : Record() enum class BolusType { DEFAULT, SMB -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/ResultStates.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/ResultStates.kt index 53dc608e60..8f0c353763 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/ResultStates.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/ResultStates.kt @@ -6,4 +6,4 @@ enum class InitialResult { enum class ResolvedResult { SUCCESS, FAILURE -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/Converters.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/Converters.kt index 2395695f1e..8d21ea751a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/Converters.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/Converters.kt @@ -31,4 +31,4 @@ class Converters { @TypeConverter fun fromOmnipodCommandType(omnipodCommandType: OmnipodCommandType) = omnipodCommandType.name -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt index 75b21716ba..c018328a9b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt @@ -5,7 +5,6 @@ import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase import androidx.room.TypeConverters -import androidx.room.migration.Migration @Database( entities = [HistoryRecordEntity::class], @@ -15,7 +14,7 @@ import androidx.room.migration.Migration @TypeConverters(Converters::class) abstract class DashHistoryDatabase : RoomDatabase() { - abstract fun historyRecordDao() : HistoryRecordDao + abstract fun historyRecordDao(): HistoryRecordDao companion object { @@ -26,5 +25,4 @@ abstract class DashHistoryDatabase : RoomDatabase() { .fallbackToDestructiveMigration() .build() } - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt index e5c425dd24..93b292c067 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt @@ -32,5 +32,4 @@ abstract class HistoryRecordDao { @Query("UPDATE historyrecords SET resolvedResult = :resolvedResult, resolvedAt = :resolvedAt WHERE id = :id ") abstract fun markResolved(id: String, resolvedResult: ResolvedResult, resolvedAt: Long): Completable - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt index 4eea309c5a..18ff9c14d2 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt @@ -19,5 +19,5 @@ data class HistoryRecordEntity( @Embedded(prefix = "tempBasalRecord_") val tempBasalRecord: TempBasalRecord?, @Embedded(prefix = "bolusRecord_") val bolusRecord: BolusRecord?, val resolvedResult: ResolvedResult?, - val resolvedAt: Long?) - + val resolvedAt: Long? +) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt index e3eeb39320..57df60dfa3 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt @@ -21,7 +21,8 @@ class HistoryMapper { ) fun entityToDomain(entity: HistoryRecordEntity): HistoryRecord = - HistoryRecord(id = entity.id, + HistoryRecord( + id = entity.id, createdAt = entity.createdAt, date = entity.date, initialResult = entity.initialResult, @@ -30,5 +31,4 @@ class HistoryMapper { resolvedResult = entity.resolvedResult, resolvedAt = entity.resolvedAt ) - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt index 26aa52b5df..86ec8ff628 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt @@ -66,10 +66,13 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() { } binding.buttonDiscardPod.setOnClickListener { - OKDialog.showConfirmation(this, - resourceHelper.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation), Thread { - // TODO discard Pod - }) + OKDialog.showConfirmation( + this, + resourceHelper.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation), + Thread { + // TODO discard Pod + } + ) } binding.buttonPlayTestBeep.setOnClickListener { @@ -77,13 +80,16 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() { binding.buttonPlayTestBeep.isEnabled = false binding.buttonPlayTestBeep.setText(R.string.omnipod_common_pod_management_button_playing_test_beep) - commandQueue.customCommand(CommandPlayTestBeep(), object : Callback() { - override fun run() { - if (!result.success) { - displayErrorDialog(resourceHelper.gs(R.string.omnipod_common_warning), resourceHelper.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, resourceHelper.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment), false) + commandQueue.customCommand( + CommandPlayTestBeep(), + object : Callback() { + override fun run() { + if (!result.success) { + displayErrorDialog(resourceHelper.gs(R.string.omnipod_common_warning), resourceHelper.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, resourceHelper.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment), false) + } } } - }) + ) } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index 223547e68a..6e4c959799 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -107,38 +107,47 @@ class OmnipodDashOverviewFragment : DaggerFragment() { buttonBinding.buttonResumeDelivery.setOnClickListener { disablePodActionButtons() - commandQueue.customCommand(CommandResumeDelivery(), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_resume_delivery), true).messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_delivery_resumed))) + commandQueue.customCommand( + CommandResumeDelivery(), + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_resume_delivery), true).messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_delivery_resumed)) + ) } buttonBinding.buttonRefreshStatus.setOnClickListener { disablePodActionButtons() - commandQueue.readStatus("REQUESTED BY USER", - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_refresh_status), false)) + commandQueue.readStatus( + "REQUESTED BY USER", + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_refresh_status), false) + ) } buttonBinding.buttonSilenceAlerts.setOnClickListener { disablePodActionButtons() - commandQueue.customCommand(CommandAcknowledgeAlerts(), + commandQueue.customCommand( + CommandAcknowledgeAlerts(), DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_silence_alerts), false) .messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_silenced_alerts)) - .actionOnSuccess { rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_ALERTS)) }) + .actionOnSuccess { rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_ALERTS)) } + ) } buttonBinding.buttonSuspendDelivery.setOnClickListener { disablePodActionButtons() - commandQueue.customCommand(CommandSuspendDelivery(), + commandQueue.customCommand( + CommandSuspendDelivery(), DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_suspend_delivery), true) - .messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_suspended_delivery))) + .messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_suspended_delivery)) + ) } buttonBinding.buttonSetTime.setOnClickListener { disablePodActionButtons() - commandQueue.customCommand(CommandHandleTimeChange(true), + commandQueue.customCommand( + CommandHandleTimeChange(true), DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_common_error_failed_to_set_time), true) - .messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_time_on_pod_updated))) + .messageOnSuccess(resourceHelper.gs(R.string.omnipod_common_confirmation_time_on_pod_updated)) + ) } - } override fun onResume() { @@ -147,23 +156,32 @@ class OmnipodDashOverviewFragment : DaggerFragment() { disposables += rxBus .toObservable(EventOmnipodDashPumpValuesChanged::class.java) .observeOn(aapsSchedulers.main) - .subscribe({ - updateOmnipodStatus() - updatePodActionButtons() - }, fabricPrivacy::logException) + .subscribe( + { + updateOmnipodStatus() + updatePodActionButtons() + }, + fabricPrivacy::logException + ) disposables += rxBus .toObservable(EventQueueChanged::class.java) .observeOn(aapsSchedulers.main) - .subscribe({ - updateQueueStatus() - updatePodActionButtons() - }, fabricPrivacy::logException) + .subscribe( + { + updateQueueStatus() + updatePodActionButtons() + }, + fabricPrivacy::logException + ) disposables += rxBus .toObservable(EventPreferenceChange::class.java) .observeOn(aapsSchedulers.main) - .subscribe({ - updatePodActionButtons() - }, fabricPrivacy::logException) + .subscribe( + { + updatePodActionButtons() + }, + fabricPrivacy::logException + ) updateUi() } @@ -267,16 +285,18 @@ class OmnipodDashOverviewFragment : DaggerFragment() { podInfoBinding.reservoir.setTextColor(Color.WHITE) } else { // TODO - //val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits + // val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits // ?: OmnipodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD).toDouble() val lowReservoirThreshold: Short = 20 podInfoBinding.reservoir.text = resourceHelper.gs(R.string.omnipod_common_overview_reservoir_value, podStateManager.pulsesRemaining) - podInfoBinding.reservoir.setTextColor(if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) { - Color.RED - } else { - Color.WHITE - }) + podInfoBinding.reservoir.setTextColor( + if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) { + Color.RED + } else { + Color.WHITE + } + ) } podInfoBinding.podActiveAlerts.text = if (podStateManager.activeAlerts!!.size > 0) { @@ -345,7 +365,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } } - val podStatusColor = if (!podStateManager.isActivationCompleted ||/* TODO podStateManager.isPodDead || */ podStateManager.isSuspended) { + val podStatusColor = if (!podStateManager.isActivationCompleted || /* TODO podStateManager.isPodDead || */ podStateManager.isSuspended) { Color.RED } else { Color.WHITE @@ -417,8 +437,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } private fun updateRefreshStatusButton() { - buttonBinding.buttonRefreshStatus.isEnabled = podStateManager.isUniqueIdSet && podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) - && isQueueEmpty() + buttonBinding.buttonRefreshStatus.isEnabled = podStateManager.isUniqueIdSet && podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) && + isQueueEmpty() } private fun updateResumeDeliveryButton() { @@ -576,5 +596,4 @@ class OmnipodDashOverviewFragment : DaggerFragment() { return this } } - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt index 6f87bfd8f6..ad340053bf 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activatio import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity -class DashPodActivationWizardActivity : PodActivationWizardActivity() \ No newline at end of file +class DashPodActivationWizardActivity : PodActivationWizardActivity() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt index fc6c428ca2..1ed9dd45fe 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt @@ -51,4 +51,4 @@ class DashInsertCannulaViewModel @Inject constructor( @StringRes override fun getTextId() = R.string.omnipod_common_pod_activation_wizard_insert_cannula_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashAttachPodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashAttachPodViewModel.kt index dfad36eb91..36b00e5738 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashAttachPodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashAttachPodViewModel.kt @@ -12,4 +12,4 @@ class DashAttachPodViewModel @Inject constructor() : AttachPodViewModel() { @StringRes override fun getTextId() = R.string.omnipod_common_pod_activation_wizard_attach_pod_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashPodActivatedViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashPodActivatedViewModel.kt index 88721268a9..de6d558662 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashPodActivatedViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashPodActivatedViewModel.kt @@ -12,4 +12,4 @@ class DashPodActivatedViewModel @Inject constructor() : PodActivatedViewModel() @StringRes override fun getTextId() = R.string.omnipod_common_pod_activation_wizard_pod_activated_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashStartPodActivationViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashStartPodActivationViewModel.kt index 0e7538b621..1bb7ae1a22 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashStartPodActivationViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/info/DashStartPodActivationViewModel.kt @@ -12,4 +12,4 @@ class DashStartPodActivationViewModel @Inject constructor() : StartPodActivation @StringRes override fun getTextId(): Int = R.string.omnipod_dash_pod_activation_wizard_start_pod_activation_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/DashPodDeactivationWizardActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/DashPodDeactivationWizardActivity.kt index 0a45f38be8..adce6f5806 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/DashPodDeactivationWizardActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/DashPodDeactivationWizardActivity.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.deactivat import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.deactivation.PodDeactivationWizardActivity -class DashPodDeactivationWizardActivity : PodDeactivationWizardActivity() \ No newline at end of file +class DashPodDeactivationWizardActivity : PodDeactivationWizardActivity() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt index 8d7c393cf4..cc2e867599 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt @@ -25,4 +25,4 @@ class DashDeactivatePodViewModel @Inject constructor( @StringRes override fun getTextId(): Int = R.string.omnipod_common_pod_deactivation_wizard_deactivating_pod_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDeactivatedViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDeactivatedViewModel.kt index 3496076606..a848db0bd6 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDeactivatedViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDeactivatedViewModel.kt @@ -12,5 +12,4 @@ class DashPodDeactivatedViewModel @Inject constructor() : PodDeactivatedViewMode @StringRes override fun getTextId() = R.string.omnipod_common_pod_deactivation_wizard_pod_deactivated_text - -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDiscardedViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDiscardedViewModel.kt index 27fb8fd625..a7cce31cce 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDiscardedViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashPodDiscardedViewModel.kt @@ -12,4 +12,4 @@ class DashPodDiscardedViewModel @Inject constructor() : PodDiscardedViewModel() @StringRes override fun getTextId() = R.string.omnipod_common_pod_deactivation_wizard_pod_discarded_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashStartPodDeactivationViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashStartPodDeactivationViewModel.kt index 099ce1f53c..1f929af9ae 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashStartPodDeactivationViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/info/DashStartPodDeactivationViewModel.kt @@ -12,4 +12,4 @@ class DashStartPodDeactivationViewModel @Inject constructor() : StartPodDeactiva @StringRes override fun getTextId() = R.string.omnipod_common_pod_deactivation_wizard_start_pod_deactivation_text -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/Functions.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/Functions.kt index 54ad9b345f..baa0ecf7c9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/Functions.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/Functions.kt @@ -60,4 +60,4 @@ fun mapProfileToBasalProgram(profile: Profile): BasalProgram { ) return BasalProgram(entries) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt index 55dc2ff96e..45cb0d9d97 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt @@ -17,4 +17,4 @@ class DeactivateCommandTest { Assert.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt index 4a73a9ebb4..e0ab87267d 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt @@ -18,4 +18,4 @@ class GetStatusCommandTest { Assert.assertArrayEquals(Hex.decodeHex("024200023C030E0100024C"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt index c092142361..9c4e963df8 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt @@ -16,4 +16,4 @@ class GetVersionCommandTest { Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt index 63c5063c0e..b3bb3ba60d 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType import org.apache.commons.codec.DecoderException @@ -75,4 +75,4 @@ class ProgramAlertsCommandTest { Assert.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt index ce33402475..93fba68a72 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt @@ -29,4 +29,4 @@ class ProgramBasalCommandTest { Assert.assertArrayEquals(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt index cd5d06c451..8030767ab9 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt @@ -22,4 +22,4 @@ class ProgramBeepsCommandTest { Assert.assertArrayEquals(Hex.decodeHex("024200022C061E0402000000800F"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt index ce9ea9c24e..daface569f 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt @@ -21,4 +21,4 @@ class ProgramBolusCommandTest { Assert.assertArrayEquals(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt index f7875cf2b4..e4f8079b24 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt @@ -33,4 +33,4 @@ class ProgramTempBasalCommandTest { Assert.assertArrayEquals(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000AEB49D20001DE"), command.encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt index 4dda5f9a38..f98387cdbb 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt @@ -20,4 +20,4 @@ class SetUniqueIdCommandTest { Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt index 0f9c267578..63bf3e18cb 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt @@ -22,4 +22,4 @@ class SilenceAlertsCommandTest { } // TODO capture more silence alerts commands -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt index a9463e1785..ffa5737246 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt @@ -35,4 +35,4 @@ class StopDeliveryCommandTest { } // TODO test cancel bolus -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt index 06e6337afd..c57fb20a82 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt @@ -41,4 +41,4 @@ class AlarmStatusResponseTest { Assert.assertEquals(PodStatus.UNINITIALIZED, response.podStatusWhenAlarmOccurred2) Assert.assertEquals(26378.toShort(), response.returnAddressOfPodAlarmHandlerCaller) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt index f925642d38..f24e02e87c 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt @@ -25,4 +25,4 @@ class DefaultStatusResponseTest { Assert.assertEquals(280.toShort(), response.minutesSinceActivation) Assert.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt index 206ac491aa..b5254eca1d 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.NakErrorType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType import org.apache.commons.codec.DecoderException import org.apache.commons.codec.binary.Hex import org.junit.Assert @@ -24,4 +23,4 @@ class NakResponseTest { Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) Assert.assertEquals(0x00.toShort(), response.securityNakSyncCount) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt index 6f627c5d80..311be2c08b 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt @@ -36,4 +36,4 @@ class SetUniqueIdResponseTest { Assert.assertEquals(611540L, response.podSequenceNumber) Assert.assertEquals(37879809L, response.uniqueIdReceivedInCommand) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt index 2ae37834d1..58e3585cae 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt @@ -32,4 +32,4 @@ class VersionResponseTest { Assert.assertEquals(0.toByte(), response.receiverLowerGain) Assert.assertEquals(4294967295L, response.uniqueIdReceivedInCommand) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt index a046e21e17..0febb3f35a 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt @@ -26,11 +26,13 @@ class FunctionsTest { val value3 = Mockito.mock(ProfileValue::class.java) value3.timeAsSeconds = 50400 value3.value = 3.05 - PowerMockito.`when`(profile.basalValues).thenReturn(arrayOf( - value1, - value2, - value3 - )) + PowerMockito.`when`(profile.basalValues).thenReturn( + arrayOf( + value1, + value2, + value3 + ) + ) val basalProgram: BasalProgram = mapProfileToBasalProgram(profile) val entries: List = basalProgram.segments assertEquals(3, entries.size) @@ -69,8 +71,11 @@ class FunctionsTest { val value = Mockito.mock(ProfileValue::class.java) value.timeAsSeconds = 1800 value.value = 0.5 - PowerMockito.`when`(profile.basalValues).thenReturn(arrayOf( - value)) + PowerMockito.`when`(profile.basalValues).thenReturn( + arrayOf( + value + ) + ) mapProfileToBasalProgram(profile) } @@ -85,10 +90,12 @@ class FunctionsTest { val value2 = Mockito.mock(ProfileValue::class.java) value2.timeAsSeconds = 86400 value2.value = 0.5 - PowerMockito.`when`(profile.basalValues).thenReturn(arrayOf( - value1, - value2 - )) + PowerMockito.`when`(profile.basalValues).thenReturn( + arrayOf( + value1, + value2 + ) + ) mapProfileToBasalProgram(profile) } @@ -99,8 +106,11 @@ class FunctionsTest { val value = Mockito.mock(ProfileValue::class.java) value.timeAsSeconds = -1 value.value = 0.5 - PowerMockito.`when`(profile.basalValues).thenReturn(arrayOf( - value)) + PowerMockito.`when`(profile.basalValues).thenReturn( + arrayOf( + value + ) + ) mapProfileToBasalProgram(profile) } @@ -109,10 +119,13 @@ class FunctionsTest { val value = Mockito.mock(ProfileValue::class.java) value.timeAsSeconds = 0 value.value = 0.04 - PowerMockito.`when`(profile.basalValues).thenReturn(arrayOf( - value)) + PowerMockito.`when`(profile.basalValues).thenReturn( + arrayOf( + value + ) + ) val basalProgram: BasalProgram = mapProfileToBasalProgram(profile) val basalProgramElement: BasalProgram.Segment = basalProgram.segments[0] assertEquals(5, basalProgramElement.basalRateInHundredthUnitsPerHour) } -} \ No newline at end of file +} From e7b3d85639ca92d85fc6aa2a8f00d0232d2a0290 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 1 Mar 2021 13:49:39 +0100 Subject: [PATCH 5/7] detekt resolve a few --- omnipod-dash/detekt-config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/omnipod-dash/detekt-config.yml b/omnipod-dash/detekt-config.yml index 60e3fee286..850cd898e5 100644 --- a/omnipod-dash/detekt-config.yml +++ b/omnipod-dash/detekt-config.yml @@ -567,7 +567,8 @@ style: maxJumpCount: 1 MagicNumber: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + # TODO: re-enable omnipod-dash + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/omnipod-dash/**'] ignoreNumbers: ['-1', '0', '1', '2'] ignoreHashCodeFunction: true ignorePropertyDeclaration: false From 5ef07dd0beea8845d8a76b312f23c11101db230b Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 1 Mar 2021 13:52:43 +0100 Subject: [PATCH 6/7] detekt resolve a few more --- .../pump/omnipod/dash/driver/comm/io/BleIO.kt | 1 + .../dash/driver/comm/pair/LTKExchanger.kt | 22 +++++++++---------- .../pump/omnipod/dash/history/DashHistory.kt | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt index de2125a2b5..dbfc1ff344 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt @@ -1,3 +1,4 @@ +@file:Suppress("WildcardImport") package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io import android.bluetooth.BluetoothGatt diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt index a6cc8b3bb5..d43b8e0479 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt @@ -225,24 +225,24 @@ internal class LTKExchanger(private val aapsLogger: AAPSLogger, private val msgI companion object { - private val PUBLIC_KEY_SIZE = 32 - private val NONCE_SIZE = 16 - private val CONF_SIZE = 16 + private const val PUBLIC_KEY_SIZE = 32 + private const val NONCE_SIZE = 16 + private const val CONF_SIZE = 16 - private val CMAC_SIZE = 16 + private const val CMAC_SIZE = 16 private val INTERMEDIAR_KEY_MAGIC_STRING = "TWIt".toByteArray() private val PDM_CONF_MAGIC_PREFIX = "KC_2_U".toByteArray() private val POD_CONF_MAGIC_PREFIX = "KC_2_V".toByteArray() - private val GET_POD_STATUS_HEX_COMMAND = "ffc32dbd08030e0100008a" // TODO for now we are assuming this command is build out of constant parameters, use a proper command builder for that. + private const val GET_POD_STATUS_HEX_COMMAND = "ffc32dbd08030e0100008a" // TODO for now we are assuming this command is build out of constant parameters, use a proper command builder for that. - private val SP1 = "SP1=" - private val SP2 = ",SP2=" - private val SPS1 = "SPS1=" - private val SPS2 = "SPS2=" - private val SP0GP0 = "SP0,GP0" - private val P0 = "P0=" + private const val SP1 = "SP1=" + private const val SP2 = ",SP2=" + private const val SPS1 = "SPS1=" + private const val SPS2 = "SPS2=" + private const val SP0GP0 = "SP0,GP0" + private const val P0 = "P0=" private val UNKNOWN_P0_PAYLOAD = byteArrayOf(0xa5.toByte()) } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt index d8c9bf36c1..81cfa6475c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt @@ -26,6 +26,7 @@ class DashHistory @Inject constructor( fun markFailure(id: String, date: Long): Completable = dao.markResolved(id, ResolvedResult.FAILURE, currentTimeMillis()) + @Suppress("ReturnCount") fun createRecord( commandType: OmnipodCommandType, date: Long, From 89ff502518e8878e2989e8d3a4b76e6d0c870853 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 1 Mar 2021 14:35:50 +0100 Subject: [PATCH 7/7] a bit more formatting --- .idea/codeStyles/Project.xml | 17 +- omnipod-dash/detekt-config.yml | 2 +- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 26 +- .../dash/dagger/OmnipodDashHistoryModule.kt | 3 +- .../dash/driver/OmnipodDashManagerImpl.kt | 30 +- .../driver/comm/OmnipodDashBleManagerImpl.kt | 38 ++- .../dash/driver/comm/ServiceDiscoverer.kt | 6 +- .../driver/comm/callbacks/BleCommCallbacks.kt | 31 ++- .../driver/comm/command/BleCommandType.kt | 10 +- .../CouldNotConfirmWriteException.kt | 6 +- .../pump/omnipod/dash/driver/comm/io/BleIO.kt | 25 +- .../comm/message/IncorrectPacketException.kt | 5 +- .../dash/driver/comm/message/MessagePacket.kt | 3 +- .../dash/driver/comm/message/PayloadJoiner.kt | 24 +- .../driver/comm/message/PayloadSplitter.kt | 23 +- .../message/StringLengthPrefixEncoding.kt | 6 +- .../dash/driver/comm/packet/BlePacket.kt | 13 +- .../dash/driver/comm/pair/LTKExchanger.kt | 8 +- .../driver/comm/scan/BleDiscoveredDevice.kt | 16 +- .../driver/pod/command/DeactivateCommand.kt | 7 +- .../driver/pod/command/ProgramBasalCommand.kt | 33 ++- .../driver/pod/command/ProgramBeepsCommand.kt | 10 +- .../driver/pod/command/ProgramBolusCommand.kt | 29 +- .../pod/command/ProgramInsulinCommand.kt | 2 +- .../pod/command/ProgramTempBasalCommand.kt | 50 +++- .../driver/pod/command/SetUniqueIdCommand.kt | 9 +- .../driver/pod/command/StopDeliveryCommand.kt | 16 +- .../pod/command/base/HeaderEnabledCommand.kt | 7 +- .../insulin/program/util/ProgramBasalUtil.kt | 73 ++++- .../program/util/ProgramTempBasalUtil.kt | 8 +- .../pod/definition/AlertConfiguration.kt | 2 +- .../pod/response/DefaultStatusResponse.kt | 9 +- .../pod/response/SetUniqueIdResponse.kt | 39 ++- .../driver/pod/response/VersionResponse.kt | 39 ++- .../state/OmnipodDashPodStateManagerImpl.kt | 34 ++- .../dash/driver/pod/util/MessageUtil.kt | 259 +++++++++++++++++- .../pump/omnipod/dash/history/DashHistory.kt | 14 +- .../history/database/DashHistoryDatabase.kt | 6 +- .../dash/ui/DashPodManagementActivity.kt | 10 +- .../dash/ui/OmnipodDashOverviewFragment.kt | 114 ++++++-- .../action/DashInitializePodViewModel.kt | 7 +- .../action/DashInsertCannulaViewModel.kt | 7 +- .../action/DashDeactivatePodViewModel.kt | 4 +- 43 files changed, 927 insertions(+), 153 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 3542887fac..3a7ab749b3 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -22,6 +22,7 @@