diff --git a/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothDevice.kt b/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothDevice.kt index ae154d22e0..662e5e3b35 100644 --- a/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothDevice.kt +++ b/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothDevice.kt @@ -1,8 +1,5 @@ package info.nightscout.comboctl.android -import android.bluetooth.BluetoothAdapter as SystemBluetoothAdapter -import android.bluetooth.BluetoothDevice as SystemBluetoothDevice -import android.bluetooth.BluetoothSocket as SystemBluetoothSocket import android.content.Context import info.nightscout.comboctl.base.BluetoothAddress import info.nightscout.comboctl.base.BluetoothDevice @@ -12,11 +9,14 @@ import info.nightscout.comboctl.base.ComboIOException import info.nightscout.comboctl.base.LogLevel import info.nightscout.comboctl.base.Logger import info.nightscout.comboctl.utils.retryBlocking +import kotlinx.coroutines.Dispatchers import java.io.IOException import java.io.InputStream import java.io.OutputStream import java.util.Locale -import kotlinx.coroutines.Dispatchers +import android.bluetooth.BluetoothAdapter as SystemBluetoothAdapter +import android.bluetooth.BluetoothDevice as SystemBluetoothDevice +import android.bluetooth.BluetoothSocket as SystemBluetoothSocket private val logger = Logger.get("AndroidBluetoothDevice") diff --git a/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothInterface.kt b/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothInterface.kt index e1dfee66dc..a0ff751adb 100644 --- a/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothInterface.kt +++ b/pump/combov2/comboctl/src/androidMain/kotlin/info/nightscout/comboctl/android/AndroidBluetoothInterface.kt @@ -1,11 +1,6 @@ package info.nightscout.comboctl.android import android.annotation.SuppressLint -import android.bluetooth.BluetoothAdapter as SystemBluetoothAdapter -import android.bluetooth.BluetoothDevice as SystemBluetoothDevice -import android.bluetooth.BluetoothManager as SystemBluetoothManager -import android.bluetooth.BluetoothServerSocket as SystemBluetoothServerSocket -import android.bluetooth.BluetoothSocket as SystemBluetoothSocket import android.content.BroadcastReceiver import android.content.Context import android.content.Intent @@ -20,6 +15,11 @@ import info.nightscout.comboctl.base.toBluetoothAddress import java.io.IOException import java.util.concurrent.locks.ReentrantLock import kotlin.concurrent.thread +import android.bluetooth.BluetoothAdapter as SystemBluetoothAdapter +import android.bluetooth.BluetoothDevice as SystemBluetoothDevice +import android.bluetooth.BluetoothManager as SystemBluetoothManager +import android.bluetooth.BluetoothServerSocket as SystemBluetoothServerSocket +import android.bluetooth.BluetoothSocket as SystemBluetoothSocket private val logger = Logger.get("AndroidBluetoothInterface") diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/DisplayFrameAssembler.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/DisplayFrameAssembler.kt index e0674f292b..98dc046288 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/DisplayFrameAssembler.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/DisplayFrameAssembler.kt @@ -138,7 +138,7 @@ class DisplayFrameAssembler { // frame, this means it contains 8 pixel rows. This in turn means that this // layout stores one byte per column. So, the first byte in the display frame row // contains the pixels from (x 95 y 0) to (x 95 y 7). The second byte contains - // pixels from (x 94 y 0) to (x 94 y 7) etc. + // pixels from (x 94 y 0) to (x 94 y 7) etc. for (row in 0 until 4) { val rtDisplayFrameRow = rtDisplayFrameRows[row]!! for (column in 0 until DISPLAY_FRAME_WIDTH) { diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ProgressReporter.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ProgressReporter.kt index 5bd6403934..40ff1db96e 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ProgressReporter.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/ProgressReporter.kt @@ -1,8 +1,8 @@ package info.nightscout.comboctl.base -import kotlin.reflect.KClassifier import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow +import kotlin.reflect.KClassifier private val logger = Logger.get("Pump") diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/Utility.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/Utility.kt index b0ed0dae3e..a3f2f3e1c0 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/Utility.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/base/Utility.kt @@ -1,11 +1,11 @@ package info.nightscout.comboctl.base -import kotlin.math.max -import kotlin.math.min import kotlinx.datetime.Clock import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.atTime +import kotlin.math.max +import kotlin.math.min // Utility function for cases when only the time and no date is known. // monthNumber and dayOfMonth are set to 1 instead of 0 since 0 is diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt index 68c7de77eb..effc2d4a7e 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt @@ -29,10 +29,6 @@ import info.nightscout.comboctl.parser.BatteryState import info.nightscout.comboctl.parser.MainScreenContent import info.nightscout.comboctl.parser.ParsedScreen import info.nightscout.comboctl.parser.ReservoirState -import kotlin.math.absoluteValue -import kotlin.time.Duration -import kotlin.time.DurationUnit -import kotlin.time.toDuration import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.NonCancellable @@ -53,6 +49,10 @@ import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.offsetAt import kotlinx.datetime.toInstant import kotlinx.datetime.toLocalDateTime +import kotlin.math.absoluteValue +import kotlin.time.Duration +import kotlin.time.DurationUnit +import kotlin.time.toDuration private val logger = Logger.get("Pump") @@ -1747,7 +1747,10 @@ class Pump( // the button, meaning that it will always press the button at least initially, // moving to entry #2 in the TDD history. Thus, if we don't look at the screen now, // we miss entry #1, which is the current day. - val firstTDDScreen = navigateToRTScreen(rtNavigationContext, ParsedScreen.MyDataDailyTotalsScreen::class, pumpSuspended) as ParsedScreen.MyDataDailyTotalsScreen + val firstTDDScreen = navigateToRTScreen( + rtNavigationContext, + ParsedScreen.MyDataDailyTotalsScreen::class, + pumpSuspended) as ParsedScreen.MyDataDailyTotalsScreen processTDDScreen(firstTDDScreen) longPressRTButtonUntil(rtNavigationContext, RTNavigationButton.DOWN) { parsedScreen -> @@ -2523,7 +2526,8 @@ class Pump( val expectedCurrentTbrPercentage = currentTbrState.tbr.percentage val actualCurrentTbrPercentage = status.tbrPercentage val elapsedTimeSinceTbrStart = now - currentTbrState.tbr.timestamp - val expectedRemainingDurationInMinutes = currentTbrState.tbr.durationInMinutes - elapsedTimeSinceTbrStart.inWholeMinutes.toInt() + val expectedRemainingDurationInMinutes = + currentTbrState.tbr.durationInMinutes - elapsedTimeSinceTbrStart.inWholeMinutes.toInt() val actualRemainingDurationInMinutes = status.remainingTbrDurationInMinutes // The remaining duration check uses a tolerance range of 10 minutes, since @@ -2765,7 +2769,8 @@ class Pump( numRetrievedFactors++ logger(LogLevel.DEBUG) { - "Got basal profile factor #$factorIndexOnScreen : $factor; $numRetrievedFactors factor(s) read and $numObservedScreens screen(s) observed thus far" + "Got basal profile factor #$factorIndexOnScreen : $factor; $numRetrievedFactors " + + "factor(s) read and $numObservedScreens screen(s) observed thus far" } getBasalProfileReporter.setCurrentProgressStage( diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt index 7e6dfa89d7..1789e916d1 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt @@ -422,7 +422,7 @@ suspend fun longPressRTButtonUntil( // that is documented in TransportLayer.IO.sendInternal().) val elapsedTime = getElapsedTimeInMs() - timestampBeforeDisplayFrameRetrieval if (elapsedTime < MINIMUM_WAIT_PERIOD_DURING_LONG_RT_BUTTON_PRESS_IN_MS) { - val waitingPeriodInMs = MINIMUM_WAIT_PERIOD_DURING_LONG_RT_BUTTON_PRESS_IN_MS - elapsedTime + val waitingPeriodInMs = MINIMUM_WAIT_PERIOD_DURING_LONG_RT_BUTTON_PRESS_IN_MS - elapsedTime logger(LogLevel.VERBOSE) { "Waiting $waitingPeriodInMs milliseconds before continuing button long-press" } delay(timeMillis = waitingPeriodInMs) } @@ -449,8 +449,7 @@ suspend fun longPressRTButtonUntil( // Record the screen we just saw so we can return it. lastParsedScreen = parsedScreen return@startLongButtonPress false - } - else + } else return@startLongButtonPress true } diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt index 26bf417185..16654eefbc 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt @@ -4,10 +4,10 @@ import info.nightscout.comboctl.base.ComboException import info.nightscout.comboctl.base.DisplayFrame import info.nightscout.comboctl.base.combinedDateTime import info.nightscout.comboctl.base.timeWithoutDate -import kotlin.reflect.KClassifier import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.atTime +import kotlin.reflect.KClassifier /***************************************** *** Screen and screen content classes *** diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PairingSessionTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PairingSessionTest.kt index 2fd989153b..c7ffec41ff 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PairingSessionTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PairingSessionTest.kt @@ -3,11 +3,11 @@ package info.nightscout.comboctl.base import info.nightscout.comboctl.base.testUtils.TestBluetoothDevice import info.nightscout.comboctl.base.testUtils.TestPumpStateStore import info.nightscout.comboctl.base.testUtils.runBlockingWithWatchdog +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.channels.Channel import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.fail -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.channels.Channel class PairingSessionTest { enum class PacketDirection { diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PumpIOTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PumpIOTest.kt index 60ee33a5e4..14ff8db3b1 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PumpIOTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/PumpIOTest.kt @@ -7,12 +7,12 @@ import info.nightscout.comboctl.base.testUtils.TestRefPacketItem import info.nightscout.comboctl.base.testUtils.checkTestPacketSequence import info.nightscout.comboctl.base.testUtils.produceTpLayerPacket import info.nightscout.comboctl.base.testUtils.runBlockingWithWatchdog -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue import kotlinx.coroutines.delay import kotlinx.datetime.LocalDateTime import kotlinx.datetime.UtcOffset +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue class PumpIOTest { // Common test code. diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/TransportLayerTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/TransportLayerTest.kt index a48ff86aca..e78f8a3a9f 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/TransportLayerTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/TransportLayerTest.kt @@ -5,6 +5,8 @@ import info.nightscout.comboctl.base.testUtils.TestPumpStateStore import info.nightscout.comboctl.base.testUtils.WatchdogTimeoutException import info.nightscout.comboctl.base.testUtils.coroutineScopeWithWatchdog import info.nightscout.comboctl.base.testUtils.runBlockingWithWatchdog +import kotlinx.coroutines.Job +import kotlinx.datetime.UtcOffset import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -13,8 +15,6 @@ import kotlin.test.assertIs import kotlin.test.assertNotEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue -import kotlinx.coroutines.Job -import kotlinx.datetime.UtcOffset class TransportLayerTest { @Test diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestBluetoothDevice.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestBluetoothDevice.kt index 2f65a90411..2c4a4e8859 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestBluetoothDevice.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestBluetoothDevice.kt @@ -4,7 +4,6 @@ import info.nightscout.comboctl.base.BluetoothAddress import info.nightscout.comboctl.base.BluetoothDevice import info.nightscout.comboctl.base.ComboFrameParser import info.nightscout.comboctl.base.ComboIO -import info.nightscout.comboctl.base.ProgressReporter import info.nightscout.comboctl.base.byteArrayListOfInts import info.nightscout.comboctl.base.toComboFrame import kotlinx.coroutines.CoroutineScope diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestComboIO.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestComboIO.kt index 7e5985a6ea..48f0fe036f 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestComboIO.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/TestComboIO.kt @@ -6,8 +6,8 @@ import info.nightscout.comboctl.base.ComboIO import info.nightscout.comboctl.base.TransportLayer import info.nightscout.comboctl.base.byteArrayListOfInts import info.nightscout.comboctl.base.toTransportLayerPacket -import kotlin.test.assertNotNull import kotlinx.coroutines.channels.Channel +import kotlin.test.assertNotNull class TestComboIO : ComboIO { val sentPacketData = newTestPacketSequence() diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/UtilityFunctions.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/UtilityFunctions.kt index c552f6edd5..d49418082b 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/UtilityFunctions.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/base/testUtils/UtilityFunctions.kt @@ -4,14 +4,14 @@ import info.nightscout.comboctl.base.Cipher import info.nightscout.comboctl.base.ComboException import info.nightscout.comboctl.base.Nonce import info.nightscout.comboctl.base.TransportLayer -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.test.fail import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext +import kotlin.test.fail // Utility function to combine runBlocking() with a watchdog. // A coroutine is started with runBlocking(), and inside that diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/ParsedDisplayFrameStreamTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/ParsedDisplayFrameStreamTest.kt index c602150952..0afd398ceb 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/ParsedDisplayFrameStreamTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/ParsedDisplayFrameStreamTest.kt @@ -20,17 +20,17 @@ import info.nightscout.comboctl.parser.testFrameW6CancelTbrWarningScreen import info.nightscout.comboctl.parser.testTimeAndDateSettingsHourPolishScreen import info.nightscout.comboctl.parser.testTimeAndDateSettingsHourRussianScreen import info.nightscout.comboctl.parser.testTimeAndDateSettingsHourTurkishScreen +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.BeforeAll import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertIs import kotlin.test.assertNotNull import kotlin.test.assertNull -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll class ParsedDisplayFrameStreamTest { companion object { diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/RTNavigationTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/RTNavigationTest.kt index 1ce48e48b6..387fd7cd8b 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/RTNavigationTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/main/RTNavigationTest.kt @@ -13,13 +13,6 @@ import info.nightscout.comboctl.parser.MainScreenContent import info.nightscout.comboctl.parser.ParsedScreen import info.nightscout.comboctl.parser.Quickinfo import info.nightscout.comboctl.parser.ReservoirState -import kotlin.reflect.KClassifier -import kotlin.test.Test -import kotlin.test.assertContentEquals -import kotlin.test.assertEquals -import kotlin.test.assertIs -import kotlin.test.assertNotNull -import kotlin.test.assertTrue import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob @@ -29,7 +22,14 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.datetime.LocalDateTime import org.junit.jupiter.api.BeforeAll +import kotlin.reflect.KClassifier +import kotlin.test.Test +import kotlin.test.assertContentEquals +import kotlin.test.assertEquals import kotlin.test.assertFailsWith +import kotlin.test.assertIs +import kotlin.test.assertNotNull +import kotlin.test.assertTrue class RTNavigationTest { /* RTNavigationContext implementation for testing out RTNavigation functionality. @@ -360,7 +360,6 @@ class RTNavigationTest { decrementButton = RTNavigationButton.DOWN ) assertEquals(Pair(0, RTNavigationButton.CHECK), result) - } @Test diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt index ed37965c2b..3d342a7599 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt @@ -2,12 +2,12 @@ package info.nightscout.comboctl.parser import info.nightscout.comboctl.base.DisplayFrame import info.nightscout.comboctl.base.timeWithoutDate +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.fail -import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime class ParserTest { class TestContext(displayFrame: DisplayFrame, tokenOffset: Int, skipTitleString: Boolean = false, parseTopLeftTime: Boolean = false) {