diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index c560e0a38b..545364ac3f 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -20,6 +20,7 @@ import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugi import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils +import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage @@ -51,7 +52,7 @@ import java.util.* ConstraintChecker::class, SP::class, Context::class, OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class, VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class, GlimpPlugin::class, Profiler::class, - UserEntryLogger::class, LoggerUtils::class, AppRepository::class, InsightDatabaseDao::class) + UserEntryLogger::class, PrefFileListProvider::class, AppRepository::class, InsightDatabaseDao::class) class ConstraintsCheckerTest : TestBaseWithProfile() { @Mock lateinit var activePlugin: ActivePlugin @@ -64,7 +65,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { @Mock lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @Mock lateinit var profiler: Profiler @Mock lateinit var uel: UserEntryLogger - @Mock lateinit var loggerUtils: LoggerUtils + @Mock lateinit var fileListProvider: PrefFileListProvider @Mock lateinit var repository: AppRepository @Mock lateinit var pumpSync: PumpSync @Mock lateinit var insightDatabaseDao: InsightDatabaseDao @@ -145,7 +146,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, sp, commandQueue, profileFunction, context, ConfigImpl(), dateUtil, insightDbHelper, pumpSync) openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, iobCobCalculator, hardLimits, profiler, sp, dateUtil, repository, glucoseStatusProvider) openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, iobCobCalculator, hardLimits, profiler, fabricPrivacy, dateUtil, repository, glucoseStatusProvider) - safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, BuildHelper(ConfigImpl(), loggerUtils), iobCobCalculator, ConfigImpl(), dateUtil) + safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, BuildHelper(ConfigImpl(), fileListProvider), iobCobCalculator, ConfigImpl(), dateUtil) val constraintsPluginsList = ArrayList() constraintsPluginsList.add(safetyPlugin) constraintsPluginsList.add(objectivesPlugin) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt index d0d965961b..c05b26a7a4 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt @@ -19,7 +19,7 @@ import org.powermock.modules.junit4.PowerMockRunner import java.io.File @RunWith(PowerMockRunner::class) -@PrepareForTest(NSSettingsStatus::class, BuildHelper::class, LoggerUtils::class) +@PrepareForTest(NSSettingsStatus::class, BuildHelper::class, LoggerUtils::class, PrefFileListProvider::class) class MaintenancePluginTest : TestBase() { @Mock lateinit var injector: HasAndroidInjector @@ -29,14 +29,16 @@ class MaintenancePluginTest : TestBase() { @Mock lateinit var nsSettingsStatus: NSSettingsStatus @Mock lateinit var buildHelper: BuildHelper @Mock lateinit var loggerUtils: LoggerUtils + @Mock lateinit var fileListProvider: PrefFileListProvider lateinit var sut: MaintenancePlugin @Before fun mock() { - sut = MaintenancePlugin(injector, context, resourceHelper, sp, nsSettingsStatus, aapsLogger, buildHelper, ConfigImpl(), loggerUtils) + sut = MaintenancePlugin(injector, context, resourceHelper, sp, nsSettingsStatus, aapsLogger, buildHelper, ConfigImpl(), fileListProvider, loggerUtils) `when`(loggerUtils.suffix).thenReturn(".log.zip") `when`(loggerUtils.logDirectory).thenReturn("src/test/res/logger") + `when`(fileListProvider.ensureExportDirExists()).thenReturn(File("src/test/res/logger")) } @Test fun logFilesTest() { diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt index ba57bfa9d1..3d64fc8b3a 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt @@ -18,7 +18,7 @@ import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils +import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.queue.commands.* import info.nightscout.androidaps.utils.DateUtil @@ -44,16 +44,16 @@ import java.util.* @RunWith(PowerMockRunner::class) @PrepareForTest( ConstraintChecker::class, VirtualPumpPlugin::class, ToastUtils::class, Context::class, - FabricPrivacy::class, LoggerUtils::class, PowerManager::class, + FabricPrivacy::class, PrefFileListProvider::class, PowerManager::class, AppRepository::class) class CommandQueueTest : TestBaseWithProfile() { @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var sp: SP - @Mock lateinit var loggerUtils: LoggerUtils @Mock lateinit var powerManager: PowerManager @Mock lateinit var repository: AppRepository + @Mock lateinit var fileListProvider: PrefFileListProvider class CommandQueueMocked( injector: HasAndroidInjector, @@ -106,7 +106,7 @@ class CommandQueueTest : TestBaseWithProfile() { @Before fun prepare() { - commandQueue = CommandQueueMocked(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, BuildHelper(ConfigImpl(), loggerUtils), dateUtil, repository, fabricPrivacy) + commandQueue = CommandQueueMocked(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, BuildHelper(ConfigImpl(), fileListProvider), dateUtil, repository, fabricPrivacy) testPumpPlugin = TestPumpPlugin(injector) testPumpPlugin.pumpDescription.basalMinimumRate = 0.1 @@ -137,7 +137,7 @@ class CommandQueueTest : TestBaseWithProfile() { @Test fun commandIsPickedUp() { - val commandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, BuildHelper(ConfigImpl(), loggerUtils), dateUtil, repository, fabricPrivacy) + val commandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, BuildHelper(ConfigImpl(), fileListProvider), dateUtil, repository, fabricPrivacy) // start with empty queue Assert.assertEquals(0, commandQueue.size()) diff --git a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt index 5dd203a40d..000d1e9015 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils +import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.queue.commands.Command import info.nightscout.androidaps.queue.commands.CommandTempBasalAbsolute @@ -33,13 +34,13 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) @PrepareForTest( ConstraintChecker::class, VirtualPumpPlugin::class, ToastUtils::class, Context::class, - FabricPrivacy::class, LoggerUtils::class, PowerManager::class) + FabricPrivacy::class, PrefFileListProvider::class, PowerManager::class) class QueueThreadTest : TestBaseWithProfile() { @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var sp: SP - @Mock lateinit var loggerUtils: LoggerUtils + @Mock lateinit var fileListProvider: PrefFileListProvider @Mock lateinit var powerManager: PowerManager @Mock lateinit var repository: AppRepository @@ -62,7 +63,7 @@ class QueueThreadTest : TestBaseWithProfile() { @Before fun prepare() { pumpPlugin = TestPumpPlugin(injector) - commandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, BuildHelper(ConfigImpl(), loggerUtils), dateUtil, repository, fabricPrivacy) + commandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, BuildHelper(ConfigImpl(), fileListProvider), dateUtil, repository, fabricPrivacy) val pumpDescription = PumpDescription() pumpDescription.basalMinimumRate = 0.1 diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt index a89dc204e1..1aedd1dfcb 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt @@ -17,6 +17,7 @@ import javax.inject.Inject import javax.inject.Singleton import kotlin.math.abs +@Suppress("SpellCheckingInspection") @Singleton class PrefFileListProvider @Inject constructor( private val resourceHelper: ResourceHelper, @@ -27,12 +28,13 @@ class PrefFileListProvider @Inject constructor( private val versionCheckerUtils: VersionCheckerUtils ) { + private val path = File(Environment.getExternalStorageDirectory().toString()) + private val aapsPath = File(path, "AAPS" + File.separator + "preferences") + private val exportsPath = File(path, "AAPS" + File.separator + "exports") + private val extraPath = File(path, "AAPS" + File.separator + "extra") + companion object { - private val path = File(Environment.getExternalStorageDirectory().toString()) - private val aapsPath = File(path, "AAPS" + File.separator + "preferences") - private val exportsPath = File(path, "AAPS" + File.separator + "exports") - private val extraPath = File(path, "AAPS" + File.separator + "extra") private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60 } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index e76dc1b2e1..b623b7514b 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -10,7 +10,7 @@ import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding import info.nightscout.androidaps.extensions.toVisibility import java.util.* -class WeekdayPicker @JvmOverloads constructor( +class WeekdayPicker constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt index 7c7466d9e6..4c7eb50294 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt @@ -10,89 +10,73 @@ class DanaRSMessageHashTable @Inject constructor( val injector: HasAndroidInjector ) { - var messages: HashMap = HashMap() + var messages: HashMap = HashMap() - fun put(message: DanaRS_Packet) { + fun put(message: DanaRSPacket) { messages[message.command] = message } - fun findMessage(command: Int): DanaRS_Packet { - return messages[command] ?: DanaRS_Packet(injector) + fun findMessage(command: Int): DanaRSPacket { + return messages[command] ?: DanaRSPacket(injector) } init { - put(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) - put(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) - put(DanaRS_Packet_Basal_Get_Profile_Basal_Rate(injector)) - put(DanaRS_Packet_Basal_Get_Profile_Number(injector)) - put(DanaRS_Packet_Basal_Set_Basal_Rate(injector, arrayOf())) - put(DanaRS_Packet_Basal_Set_Profile_Basal_Rate(injector, 0, arrayOf())) - put(DanaRS_Packet_Basal_Set_Profile_Number(injector)) - put(DanaRS_Packet_Basal_Set_Suspend_Off(injector)) - put(DanaRS_Packet_Basal_Set_Suspend_On(injector)) - put(DanaRS_Packet_Basal_Set_Temporary_Basal(injector)) - put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) - put(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) - put(DanaRS_Packet_Bolus_Get_Initial_Bolus(injector)) - put(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) - put(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(injector)) - put(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) - put(DanaRS_Packet_Bolus_Get_24_CIR_CF_Array(injector)) - put(DanaRS_Packet_Bolus_Get_Dual_Bolus(injector)) - put(DanaRS_Packet_Bolus_Get_Extended_Bolus(injector)) - put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) - put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(injector)) - put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) - put(DanaRS_Packet_Bolus_Set_Bolus_Option(injector)) - put(DanaRS_Packet_Bolus_Set_Initial_Bolus(injector)) - put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(injector)) - put(DanaRS_Packet_Bolus_Set_24_CIR_CF_Array(injector, null)) - put(DanaRS_Packet_Bolus_Set_Dual_Bolus(injector)) - put(DanaRS_Packet_Bolus_Set_Extended_Bolus(injector)) - put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(injector)) - put(DanaRS_Packet_Etc_Keep_Connection(injector)) - put(DanaRS_Packet_Etc_Set_History_Save(injector)) - put(DanaRS_Packet_General_Delivery_Status(injector)) - put(DanaRS_Packet_General_Get_Password(injector)) - put(DanaRS_Packet_General_Initial_Screen_Information(injector)) - put(DanaRS_Packet_Notify_Alarm(injector)) - put(DanaRS_Packet_Notify_Delivery_Complete(injector)) - put(DanaRS_Packet_Notify_Delivery_Rate_Display(injector)) - put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(injector)) - put(DanaRS_Packet_Option_Get_Pump_Time(injector)) - put(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) - put(DanaRS_Packet_Option_Get_User_Option(injector)) - put(DanaRS_Packet_Option_Set_Pump_Time(injector)) - put(DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(injector)) - put(DanaRS_Packet_Option_Set_User_Option(injector)) + put(DanaRSPacketBasalSetCancelTemporaryBasal(injector)) + put(DanaRSPacketBasalGetBasalRate(injector)) + put(DanaRSPacketBasalGetProfileNumber(injector)) + put(DanaRSPacketBasalSetProfileBasalRate(injector, 0, arrayOf())) + put(DanaRSPacketBasalSetProfileNumber(injector)) + put(DanaRSPacketBasalSetSuspendOff(injector)) + put(DanaRSPacketBasalSetSuspendOn(injector)) + put(DanaRSPacketBasalSetTemporaryBasal(injector)) + put(DanaRSPacketBolusGetBolusOption(injector)) + put(DanaRSPacketBolusGetCalculationInformation(injector)) + put(DanaRSPacketBolusGetCIRCFArray(injector)) + put(DanaRSPacketBolusGetStepBolusInformation(injector)) + put(DanaRSPacketBolusSetBolusOption(injector)) + put(DanaRSPacketBolusSet24CIRCFArray(injector, null)) + put(DanaRSPacketBolusGet24CIRCFArray(injector)) + put(DanaRSPacketBolusSetExtendedBolus(injector)) + put(DanaRSPacketBolusSetExtendedBolusCancel(injector)) + put(DanaRSPacketBolusSetStepBolusStart(injector)) + put(DanaRSPacketBolusSetStepBolusStop(injector)) + put(DanaRSPacketEtcKeepConnection(injector)) + put(DanaRSPacketEtcSetHistorySave(injector)) + put(DanaRSPacketGeneralInitialScreenInformation(injector)) + put(DanaRSPacketNotifyAlarm(injector)) + put(DanaRSPacketNotifyDeliveryComplete(injector)) + put(DanaRSPacketNotifyDeliveryRateDisplay(injector)) + put(DanaRSPacketNotifyMissedBolusAlarm(injector)) + put(DanaRSPacketOptionGetPumpTime(injector)) + put(DanaRSPacketOptionGetPumpUTCAndTimeZone(injector)) + put(DanaRSPacketOptionGetUserOption(injector)) + put(DanaRSPacketOptionSetPumpTime(injector)) + put(DanaRSPacketOptionSetPumpUTCAndTimeZone(injector)) + put(DanaRSPacketOptionSetUserOption(injector)) //put(new DanaRS_Packet_History_(injector)); - put(DanaRS_Packet_History_Alarm(injector)) - put(DanaRS_Packet_History_All_History(injector)) - put(DanaRS_Packet_History_Basal(injector)) - put(DanaRS_Packet_History_Blood_Glucose(injector)) - put(DanaRS_Packet_History_Bolus(injector)) - put(DanaRS_Packet_Review_Bolus_Avg(injector)) - put(DanaRS_Packet_History_Carbohydrate(injector)) - put(DanaRS_Packet_History_Daily(injector)) - put(DanaRS_Packet_General_Get_More_Information(injector)) - put(DanaRS_Packet_General_Get_Pump_Check(injector)) - put(DanaRS_Packet_General_Get_Shipping_Information(injector)) - put(DanaRS_Packet_General_Get_Today_Delivery_Total(injector)) - put(DanaRS_Packet_General_Get_User_Time_Change_Flag(injector)) - put(DanaRS_Packet_History_Prime(injector)) - put(DanaRS_Packet_History_Refill(injector)) - put(DanaRS_Packet_General_Set_History_Upload_Mode(injector)) - put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(injector)) - put(DanaRS_Packet_History_Suspend(injector)) - put(DanaRS_Packet_History_Temporary(injector)) + put(DanaRSPacketHistoryAlarm(injector)) + put(DanaRSPacketHistoryAllHistory(injector)) + put(DanaRSPacketHistoryBasal(injector)) + put(DanaRSPacketHistoryBloodGlucose(injector)) + put(DanaRSPacketHistoryBolus(injector)) + put(DanaRSPacketReviewBolusAvg(injector)) + put(DanaRSPacketHistoryCarbohydrate(injector)) + put(DanaRSPacketHistoryDaily(injector)) + put(DanaRSPacketHistoryPrime(injector)) + put(DanaRSPacketHistoryRefill(injector)) + put(DanaRSPacketHistorySuspend(injector)) + put(DanaRSPacketHistoryTemporary(injector)) + put(DanaRSPacketGeneralGetPumpCheck(injector)) + put(DanaRSPacketGeneralGetShippingInformation(injector)) + put(DanaRSPacketGeneralGetUserTimeChangeFlag(injector)) + put(DanaRSPacketGeneralSetHistoryUploadMode(injector)) + put(DanaRSPacketGeneralSetUserTimeChangeFlagClear(injector)) // APS - put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, 0)) - put(DanaRS_Packet_APS_History_Events(injector, 0)) - put(DanaRS_Packet_APS_Set_Event_History(injector, 0, 0, 0, 0)) + put(DanaRSPacketAPSBasalSetTemporaryBasal(injector, 0)) + put(DanaRSPacketAPSHistoryEvents(injector, 0)) + put(DanaRSPacketAPSSetEventHistory(injector, 0, 0, 0, 0)) // v3 - put(DanaRS_Packet_General_Get_Shipping_Version(injector)) - put(DanaRS_Packet_Review_Get_Pump_Dec_Ratio(injector)) + put(DanaRSPacketGeneralGetShippingVersion(injector)) + put(DanaRSPacketReviewGetPumpDecRatio(injector)) } } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacket.kt similarity index 97% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacket.kt index ba0e31ebb9..918bb78207 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacket.kt @@ -8,7 +8,7 @@ import org.joda.time.DateTime import java.nio.charset.StandardCharsets import javax.inject.Inject -open class DanaRS_Packet(protected var injector: HasAndroidInjector) { +open class DanaRSPacket(protected var injector: HasAndroidInjector) { @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var dateUtil: DateUtil @@ -43,7 +43,7 @@ open class DanaRS_Packet(protected var injector: HasAndroidInjector) { failed = true } - open fun getFriendlyName(): String = "UNKNOWN_PACKET" + open val friendlyName: String = "UNKNOWN_PACKET" protected fun getBytes(data: ByteArray, srcStart: Int, srcLength: Int): ByteArray { val ret = ByteArray(srcLength) diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSBasalSetTemporaryBasal.kt similarity index 91% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSBasalSetTemporaryBasal.kt index ab1649f380..bf490138a2 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSBasalSetTemporaryBasal.kt @@ -4,10 +4,10 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_APS_Basal_Set_Temporary_Basal( +class DanaRSPacketAPSBasalSetTemporaryBasal( injector: HasAndroidInjector, private var percent: Int -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { var temporaryBasalRatio = 0 var temporaryBasalDuration = 0 @@ -48,11 +48,10 @@ class DanaRS_Packet_APS_Basal_Set_Temporary_Basal( } } - override fun getFriendlyName(): String { - return "BASAL__APS_SET_TEMPORARY_BASAL" - } + override val friendlyName: String = "BASAL__APS_SET_TEMPORARY_BASAL" companion object { + const val PARAM30MIN = 160 const val PARAM15MIN = 150 } diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSHistoryEvents.kt similarity index 99% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSHistoryEvents.kt index 12d20835fa..ddf8e3b606 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSHistoryEvents.kt @@ -19,10 +19,10 @@ import org.joda.time.DateTime import org.joda.time.DateTimeZone import javax.inject.Inject -open class DanaRS_Packet_APS_History_Events( +open class DanaRSPacketAPSHistoryEvents( injector: HasAndroidInjector, private var from: Long -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -300,7 +300,5 @@ open class DanaRS_Packet_APS_History_Events( rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.processinghistory) + ": " + status)) } - override fun getFriendlyName(): String { - return "APS_HISTORY_EVENTS" - } + override val friendlyName: String = "APS_HISTORY_EVENTS" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSSetEventHistory.kt similarity index 92% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSSetEventHistory.kt index 802eb09b56..cfa51a9d5e 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketAPSSetEventHistory.kt @@ -8,13 +8,13 @@ import org.joda.time.DateTime import org.joda.time.DateTimeZone import javax.inject.Inject -class DanaRS_Packet_APS_Set_Event_History( +class DanaRSPacketAPSSetEventHistory( injector: HasAndroidInjector, private var packetType: Int, private var time: Long, private var param1: Int, private var param2: Int -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -54,7 +54,5 @@ class DanaRS_Packet_APS_Set_Event_History( } } - override fun getFriendlyName(): String { - return "APS_SET_EVENT_HISTORY" - } + override val friendlyName: String = "APS_SET_EVENT_HISTORY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalGetBasalRate.kt similarity index 93% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalGetBasalRate.kt index 64a91766bd..ae9b5a95c9 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalGetBasalRate.kt @@ -13,9 +13,9 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject -class DanaRS_Packet_Basal_Get_Basal_Rate( +class DanaRSPacketBasalGetBasalRate( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -55,7 +55,5 @@ class DanaRS_Packet_Basal_Get_Basal_Rate( } } - override fun getFriendlyName(): String { - return "BASAL__GET_BASAL_RATE" - } + override val friendlyName: String = "BASAL__GET_BASAL_RATE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalGetProfileNumber.kt similarity index 81% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalGetProfileNumber.kt index 399555e09d..5c0bed60a0 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalGetProfileNumber.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Basal_Get_Profile_Number( +class DanaRSPacketBasalGetProfileNumber( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -22,8 +22,5 @@ class DanaRS_Packet_Basal_Get_Profile_Number( aapsLogger.debug(LTag.PUMPCOMM, "Active profile: " + danaPump.activeProfile) } - override fun getFriendlyName(): String { - return "BASAL__GET_PROFILE_NUMBER" - } - + override val friendlyName: String = "BASAL__GET_PROFILE_NUMBER" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetCancelTemporaryBasal.kt similarity index 79% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetCancelTemporaryBasal.kt index e20f2ba80e..e36b027ecb 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetCancelTemporaryBasal.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.danars.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption +import info.nightscout.androidaps.logging.LTag -class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal( +class DanaRSPacketBasalSetCancelTemporaryBasal( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL @@ -24,7 +24,5 @@ class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal( } } - override fun getFriendlyName(): String { - return "BASAL__CANCEL_TEMPORARY_BASAL" - } + override val friendlyName: String = "BASAL__CANCEL_TEMPORARY_BASAL" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetProfileBasalRate.kt similarity index 87% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetProfileBasalRate.kt index 6d397ca86f..d047e76588 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetProfileBasalRate.kt @@ -4,11 +4,11 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Basal_Set_Profile_Basal_Rate( +class DanaRSPacketBasalSetProfileBasalRate( injector: HasAndroidInjector, private var profileNumber: Int, private var profileBasalRate: Array -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE @@ -31,6 +31,7 @@ class DanaRS_Packet_Basal_Set_Profile_Basal_Rate( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -40,7 +41,5 @@ class DanaRS_Packet_Basal_Set_Profile_Basal_Rate( } } - override fun getFriendlyName(): String { - return "BASAL__SET_PROFILE_BASAL_RATE" - } + override val friendlyName: String = "BASAL__SET_PROFILE_BASAL_RATE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetProfileNumber.kt similarity index 83% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetProfileNumber.kt index 2f88623296..f22b90aee9 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetProfileNumber.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.danars.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption +import info.nightscout.androidaps.logging.LTag -class DanaRS_Packet_Basal_Set_Profile_Number( +class DanaRSPacketBasalSetProfileNumber( injector: HasAndroidInjector, private var profileNumber: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER @@ -22,6 +22,7 @@ class DanaRS_Packet_Basal_Set_Profile_Number( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -31,7 +32,5 @@ class DanaRS_Packet_Basal_Set_Profile_Number( } } - override fun getFriendlyName(): String { - return "BASAL__SET_PROFILE_NUMBER" - } + override val friendlyName: String = "BASAL__SET_PROFILE_NUMBER" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetSuspendOff.kt similarity index 80% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetSuspendOff.kt index cdd3b83f2c..644728e2ac 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetSuspendOff.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Basal_Set_Suspend_Off( +class DanaRSPacketBasalSetSuspendOff( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF @@ -15,6 +15,7 @@ class DanaRS_Packet_Basal_Set_Suspend_Off( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -24,7 +25,5 @@ class DanaRS_Packet_Basal_Set_Suspend_Off( } } - override fun getFriendlyName(): String { - return "BASAL__SET_SUSPEND_OFF" - } + override val friendlyName: String = "BASAL__SET_SUSPEND_OFF" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetSuspendOn.kt similarity index 80% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetSuspendOn.kt index 6d0cb88052..a0d1b41f0d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetSuspendOn.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Basal_Set_Suspend_On( +class DanaRSPacketBasalSetSuspendOn( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON @@ -15,6 +15,7 @@ class DanaRS_Packet_Basal_Set_Suspend_On( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -24,7 +25,5 @@ class DanaRS_Packet_Basal_Set_Suspend_On( } } - override fun getFriendlyName(): String { - return "BASAL__SET_SUSPEND_ON" - } + override val friendlyName: String = "BASAL__SET_SUSPEND_ON" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasal.kt similarity index 85% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasal.kt index 3e5725694f..63399a195d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasal.kt @@ -4,11 +4,11 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -open class DanaRS_Packet_Basal_Set_Temporary_Basal( +open class DanaRSPacketBasalSetTemporaryBasal( injector: HasAndroidInjector, private var temporaryBasalRatio: Int = 0, private var temporaryBasalDuration: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL @@ -24,6 +24,7 @@ open class DanaRS_Packet_Basal_Set_Temporary_Basal( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -33,7 +34,5 @@ open class DanaRS_Packet_Basal_Set_Temporary_Basal( } } - override fun getFriendlyName(): String { - return "BASAL__SET_TEMPORARY_BASAL" - } + override val friendlyName: String = "BASAL__SET_TEMPORARY_BASAL" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGet24CIRCFArray.kt similarity index 76% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGet24CIRCFArray.kt index 1d9b752cf9..3f0e2488ba 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGet24CIRCFArray.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.danars.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption +import info.nightscout.androidaps.logging.LTag import javax.inject.Inject -class DanaRS_Packet_Bolus_Get_24_CIR_CF_Array( +class DanaRSPacketBolusGet24CIRCFArray( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -19,9 +19,9 @@ class DanaRS_Packet_Bolus_Get_24_CIR_CF_Array( override fun handleMessage(data: ByteArray) { danaPump.units = byteArrayToInt(getBytes(data, DATA_START, 1)) - for (i in 0 .. 23) { - val cir = byteArrayToInt(getBytes(data, DATA_START + 1 + 2 * i, 2)).toDouble() - val cf = if (danaPump.units == DanaPump.UNITS_MGDL) + for (i in 0..23) { + val cir = byteArrayToInt(getBytes(data, DATA_START + 1 + 2 * i, 2)).toDouble() + val cf = if (danaPump.units == DanaPump.UNITS_MGDL) byteArrayToInt(getBytes(data, DATA_START + 1 + 48 + 2 * i, 2)).toDouble() else byteArrayToInt(getBytes(data, DATA_START + 1 + 48 + 2 * i, 2)) / 100.0 @@ -33,7 +33,5 @@ class DanaRS_Packet_Bolus_Get_24_CIR_CF_Array( aapsLogger.debug(LTag.PUMPCOMM, "Pump units: " + if (danaPump.units == DanaPump.UNITS_MGDL) "MGDL" else "MMOL") } - override fun getFriendlyName(): String { - return "BOLUS__GET_24_ CIR_CF_ARRAY" - } + override val friendlyName = "BOLUS__GET_24_ CIR_CF_ARRAY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetBolusOption.kt similarity index 97% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetBolusOption.kt index 433f782730..9b87c11a19 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetBolusOption.kt @@ -12,9 +12,9 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject -class DanaRS_Packet_Bolus_Get_Bolus_Option( +class DanaRSPacketBolusGetBolusOption( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -110,7 +110,5 @@ class DanaRS_Packet_Bolus_Get_Bolus_Option( aapsLogger.debug(LTag.PUMPCOMM, "missedBolus04EndMin: $missedBolus04EndMin") } - override fun getFriendlyName(): String { - return "BOLUS__GET_BOLUS_OPTION" - } + override val friendlyName: String = "BOLUS__GET_BOLUS_OPTION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetCIRCFArray.kt similarity index 96% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetCIRCFArray.kt index d476115d63..59af61aa30 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetCIRCFArray.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Bolus_Get_CIR_CF_Array( +class DanaRSPacketBolusGetCIRCFArray( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -112,7 +112,5 @@ class DanaRS_Packet_Bolus_Get_CIR_CF_Array( aapsLogger.debug(LTag.PUMPCOMM, "cf06: $cf06") } - override fun getFriendlyName(): String { - return "BOLUS__GET_CIR_CF_ARRAY" - } + override val friendlyName: String = "BOLUS__GET_CIR_CF_ARRAY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetCalculationInformation.kt similarity index 91% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetCalculationInformation.kt index fff895b239..58d6d95eb8 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetCalculationInformation.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Bolus_Get_Calculation_Information( +class DanaRSPacketBolusGetCalculationInformation( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -45,7 +45,7 @@ class DanaRS_Packet_Bolus_Get_Calculation_Information( if (danaPump.units == DanaPump.UNITS_MMOL) { danaPump.currentCF = danaPump.currentCF / 100.0 danaPump.currentTarget = danaPump.currentTarget / 100.0 - currentBG = currentBG / 100.0 + currentBG /= 100.0 } if (error != 0) failed = true aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") @@ -58,7 +58,5 @@ class DanaRS_Packet_Bolus_Get_Calculation_Information( aapsLogger.debug(LTag.PUMPCOMM, "Pump IOB: " + danaPump.iob) } - override fun getFriendlyName(): String { - return "BOLUS__GET_CALCULATION_INFORMATION" - } + override val friendlyName: String = "BOLUS__GET_CALCULATION_INFORMATION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetStepBolusInformation.kt similarity index 91% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetStepBolusInformation.kt index 7cc2d3aa65..992dc7bd40 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusGetStepBolusInformation.kt @@ -8,9 +8,9 @@ import org.joda.time.DateTime import org.joda.time.DateTimeZone import javax.inject.Inject -class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( +class DanaRSPacketBolusGetStepBolusInformation( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -40,7 +40,5 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( aapsLogger.debug(LTag.PUMPCOMM, "Bolus step: " + danaPump.bolusStep + " U") } - override fun getFriendlyName(): String { - return "BOLUS__GET_STEP_BOLUS_INFORMATION" - } + override val friendlyName: String = "BOLUS__GET_STEP_BOLUS_INFORMATION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSet24CIRCFArray.kt similarity index 91% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSet24CIRCFArray.kt index a7a4d573cc..febd8479c7 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSet24CIRCFArray.kt @@ -9,10 +9,10 @@ import info.nightscout.androidaps.logging.LTag import javax.inject.Inject import kotlin.math.round -class DanaRS_Packet_Bolus_Set_24_CIR_CF_Array( +class DanaRSPacketBolusSet24CIRCFArray( injector: HasAndroidInjector, private val profile: Profile? -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -42,6 +42,7 @@ class DanaRS_Packet_Bolus_Set_24_CIR_CF_Array( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -51,7 +52,5 @@ class DanaRS_Packet_Bolus_Set_24_CIR_CF_Array( } } - override fun getFriendlyName(): String { - return "BOLUS__SET_24_CIR_CF_ARRAY" - } + override val friendlyName: String = "BOLUS__SET_24_CIR_CF_ARRAY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetBolusOption.kt similarity index 94% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetBolusOption.kt index ac40d4ef56..cee5a745de 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetBolusOption.kt @@ -4,7 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Bolus_Set_Bolus_Option( +class DanaRSPacketBolusSetBolusOption( injector: HasAndroidInjector, private var extendedBolusOptionOnOff: Int = 0, private var bolusCalculationOption: Int = 0, @@ -26,7 +26,7 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option( private var missedBolus04EndHour: Int = 0, private var missedBolus04EndMin: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION @@ -59,6 +59,7 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -68,7 +69,5 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option( } } - override fun getFriendlyName(): String { - return "BOLUS__SET_BOLUS_OPTION" - } + override val friendlyName: String = "BOLUS__SET_BOLUS_OPTION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetExtendedBolus.kt similarity index 82% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetExtendedBolus.kt index 749b72206c..0afe2df2e0 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetExtendedBolus.kt @@ -4,15 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Bolus_Set_Extended_Bolus( +class DanaRSPacketBolusSetExtendedBolus( injector: HasAndroidInjector, private var extendedAmount: Double = 0.0, private var extendedBolusDurationInHalfHours: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start : $extendedAmount U halfhours: $extendedBolusDurationInHalfHours") + aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start : $extendedAmount U half-hours: $extendedBolusDurationInHalfHours") } override fun getRequestParams(): ByteArray { @@ -26,6 +26,7 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -35,7 +36,5 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus( } } - override fun getFriendlyName(): String { - return "BOLUS__SET_EXTENDED_BOLUS" - } + override val friendlyName: String = "BOLUS__SET_EXTENDED_BOLUS" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetExtendedBolusCancel.kt similarity index 78% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetExtendedBolusCancel.kt index 7bc1cea154..4f0afeb0a0 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetExtendedBolusCancel.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel( +class DanaRSPacketBolusSetExtendedBolusCancel( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL @@ -15,6 +15,7 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -24,7 +25,5 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel( } } - override fun getFriendlyName(): String { - return "BOLUS__SET_EXTENDED_BOLUS_CANCEL" - } + override val friendlyName: String = "BOLUS__SET_EXTENDED_BOLUS_CANCEL" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetStepBolusStart.kt similarity index 90% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetStepBolusStart.kt index 319e294895..0f4afcac1f 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetStepBolusStart.kt @@ -8,11 +8,11 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( +class DanaRSPacketBolusSetStepBolusStart( injector: HasAndroidInjector, private var amount: Double = 0.0, private var speed: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @Inject lateinit var constraintChecker: ConstraintChecker @@ -45,7 +45,5 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( } } - override fun getFriendlyName(): String { - return "BOLUS__SET_STEP_BOLUS_START" - } + override val friendlyName: String = "BOLUS__SET_STEP_BOLUS_START" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetStepBolusStop.kt similarity index 90% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetStepBolusStop.kt index a8f1bc0084..2262a2acde 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBolusSetStepBolusStop.kt @@ -10,9 +10,9 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject -open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( +open class DanaRSPacketBolusSetStepBolusStop( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -24,6 +24,7 @@ open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -44,7 +45,5 @@ open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( rxBus.send(bolusingEvent) } - override fun getFriendlyName(): String { - return "BOLUS__SET_STEP_BOLUS_STOP" - } + override val friendlyName: String = "BOLUS__SET_STEP_BOLUS_STOP" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Etc_Keep_Connection.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketEtcKeepConnection.kt similarity index 80% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Etc_Keep_Connection.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketEtcKeepConnection.kt index 0a5f5f10b4..310a9adcc8 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Etc_Keep_Connection.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketEtcKeepConnection.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Etc_Keep_Connection( +class DanaRSPacketEtcKeepConnection( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION @@ -15,6 +15,7 @@ class DanaRS_Packet_Etc_Keep_Connection( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -24,7 +25,5 @@ class DanaRS_Packet_Etc_Keep_Connection( } } - override fun getFriendlyName(): String { - return "ETC__KEEP_CONNECTION" - } + override val friendlyName: String = "ETC__KEEP_CONNECTION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Etc_Set_History_Save.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketEtcSetHistorySave.kt similarity index 90% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Etc_Set_History_Save.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketEtcSetHistorySave.kt index aa812ca588..a464c2d70d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Etc_Set_History_Save.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketEtcSetHistorySave.kt @@ -4,7 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Etc_Set_History_Save( +class DanaRSPacketEtcSetHistorySave( injector: HasAndroidInjector, private var historyType: Int = 0, private var historyYear: Int = 0, @@ -15,7 +15,7 @@ class DanaRS_Packet_Etc_Set_History_Save( private var historySecond: Int = 0, private var historyCode: Int = 0, private var historyValue: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE @@ -39,6 +39,7 @@ class DanaRS_Packet_Etc_Set_History_Save( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -48,7 +49,5 @@ class DanaRS_Packet_Etc_Set_History_Save( } } - override fun getFriendlyName(): String { - return "ETC__SET_HISTORY_SAVE" - } + override val friendlyName: String = "ETC__SET_HISTORY_SAVE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetPumpCheck.kt similarity index 92% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Pump_Check.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetPumpCheck.kt index 6c55bcee19..8085f4163a 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetPumpCheck.kt @@ -11,9 +11,9 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject -class DanaRS_Packet_General_Get_Pump_Check( +class DanaRSPacketGeneralGetPumpCheck( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -47,7 +47,5 @@ class DanaRS_Packet_General_Get_Pump_Check( } } - override fun getFriendlyName(): String { - return "REVIEW__GET_PUMP_CHECK" - } -} \ No newline at end of file + override val friendlyName: String = "REVIEW__GET_PUMP_CHECK" + } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Shipping_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetShippingInformation.kt similarity index 86% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Shipping_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetShippingInformation.kt index edcb565f6c..c557fcc5c0 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Shipping_Information.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetShippingInformation.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_General_Get_Shipping_Information( +class DanaRSPacketGeneralGetShippingInformation( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -30,7 +30,5 @@ class DanaRS_Packet_General_Get_Shipping_Information( aapsLogger.debug(LTag.PUMPCOMM, "Shipping country: " + danaPump.shippingCountry) } - override fun getFriendlyName(): String { - return "REVIEW__GET_SHIPPING_INFORMATION" - } + override val friendlyName: String = "REVIEW__GET_SHIPPING_INFORMATION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Shipping_Version.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetShippingVersion.kt similarity index 81% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Shipping_Version.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetShippingVersion.kt index 4a83192d39..f69b920458 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Shipping_Version.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetShippingVersion.kt @@ -7,9 +7,9 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import java.nio.charset.Charset import javax.inject.Inject -class DanaRS_Packet_General_Get_Shipping_Version( +class DanaRSPacketGeneralGetShippingVersion( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -24,7 +24,5 @@ class DanaRS_Packet_General_Get_Shipping_Version( aapsLogger.debug(LTag.PUMPCOMM, "BLE Model: " + danaPump.bleModel) } - override fun getFriendlyName(): String { - return "GENERAL__GET_SHIPPING_VERSION" - } + override val friendlyName: String = "GENERAL__GET_SHIPPING_VERSION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetUserTimeChangeFlag.kt similarity index 80% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetUserTimeChangeFlag.kt index eaaecf7f03..4e4db0238c 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralGetUserTimeChangeFlag.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_General_Get_User_Time_Change_Flag( +class DanaRSPacketGeneralGetUserTimeChangeFlag( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG @@ -24,7 +24,5 @@ class DanaRS_Packet_General_Get_User_Time_Change_Flag( aapsLogger.debug(LTag.PUMPCOMM, "UserTimeChangeFlag: $userTimeChangeFlag") } - override fun getFriendlyName(): String { - return "REVIEW__GET_USER_TIME_CHANGE_FLAG" - } + override val friendlyName: String = "REVIEW__GET_USER_TIME_CHANGE_FLAG" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralInitialScreenInformation.kt similarity index 92% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Initial_Screen_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralInitialScreenInformation.kt index 35a0e35487..3c7de5873d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Initial_Screen_Information.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralInitialScreenInformation.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_General_Initial_Screen_Information( +class DanaRSPacketGeneralInitialScreenInformation( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -70,11 +70,9 @@ class DanaRS_Packet_General_Initial_Screen_Information( aapsLogger.debug(LTag.PUMPCOMM, "Reservoir remaining units: " + danaPump.reservoirRemainingUnits) aapsLogger.debug(LTag.PUMPCOMM, "Battery: " + danaPump.batteryRemaining) aapsLogger.debug(LTag.PUMPCOMM, "Current basal: " + danaPump.currentBasal) - aapsLogger.debug(LTag.PUMPCOMM, "Temp basal percent: " + tempBasalPercent) + aapsLogger.debug(LTag.PUMPCOMM, "Temp basal percent: $tempBasalPercent") aapsLogger.debug(LTag.PUMPCOMM, "Extended absolute rate: $extendedBolusAbsoluteRate") } - override fun getFriendlyName(): String { - return "REVIEW__INITIAL_SCREEN_INFORMATION" - } + override val friendlyName: String = "REVIEW__INITIAL_SCREEN_INFORMATION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralSetHistoryUploadMode.kt similarity index 82% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralSetHistoryUploadMode.kt index c695632177..c51ce79577 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralSetHistoryUploadMode.kt @@ -4,10 +4,10 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_General_Set_History_Upload_Mode( +class DanaRSPacketGeneralSetHistoryUploadMode( injector: HasAndroidInjector, private var mode: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE @@ -22,6 +22,7 @@ class DanaRS_Packet_General_Set_History_Upload_Mode( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -31,7 +32,5 @@ class DanaRS_Packet_General_Set_History_Upload_Mode( } } - override fun getFriendlyName(): String { - return "REVIEW__SET_HISTORY_UPLOAD_MODE" - } + override val friendlyName: String = "REVIEW__SET_HISTORY_UPLOAD_MODE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralSetUserTimeChangeFlagClear.kt similarity index 77% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralSetUserTimeChangeFlagClear.kt index 45a5d01962..bac9212f24 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketGeneralSetUserTimeChangeFlagClear.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( +class DanaRSPacketGeneralSetUserTimeChangeFlagClear( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR @@ -15,6 +15,7 @@ class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -24,7 +25,5 @@ class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( } } - override fun getFriendlyName(): String { - return "REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR" - } + override val friendlyName: String = "REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt similarity index 99% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt index 63f0882acf..351e8a413a 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt @@ -15,10 +15,10 @@ import org.joda.time.DateTime import java.util.* import javax.inject.Inject -abstract class DanaRS_Packet_History_( +abstract class DanaRSPacketHistory( injector: HasAndroidInjector, protected val from: Long -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var danaHistoryRecordDao: DanaHistoryRecordDao diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarm.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Alarm.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarm.kt index 23430fab80..b206792378 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Alarm.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarm.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Alarm @JvmOverloads constructor( +class DanaRSPacketHistoryAlarm constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALARM aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__ALARM" - } + override val friendlyName: String = "REVIEW__ALARM" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_All_History.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAllHistory.kt similarity index 69% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_All_History.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAllHistory.kt index c8cbc8e39e..a6c44abce4 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_All_History.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAllHistory.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_All_History( +class DanaRSPacketHistoryAllHistory( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__ALL_HISTORY" - } + override val friendlyName: String = "REVIEW__ALL_HISTORY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt index 5166d9de0c..7c8a521b88 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Basal.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Basal @JvmOverloads constructor( +class DanaRSPacketHistoryBasal @JvmOverloads constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BASAL aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__BASAL" - } + override val friendlyName: String = "REVIEW__BASAL" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Blood_Glucose.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBloodGlucose.kt similarity index 66% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Blood_Glucose.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBloodGlucose.kt index 237006ef4a..e11e7de3e5 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Blood_Glucose.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBloodGlucose.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor( +class DanaRSPacketHistoryBloodGlucose constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__BLOOD_GLUCOSE" - } + override val friendlyName: String = "REVIEW__BLOOD_GLUCOSE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBolus.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBolus.kt index 3b8cec0a6f..55b7d7cf43 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Bolus.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBolus.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Bolus @JvmOverloads constructor( +class DanaRSPacketHistoryBolus constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__BOLUS" - } + override val friendlyName: String = "REVIEW__BOLUS" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Carbohydrate.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryCarbohydrate.kt similarity index 66% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Carbohydrate.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryCarbohydrate.kt index 6ac0f18b17..2f599ed452 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Carbohydrate.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryCarbohydrate.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor( +class DanaRSPacketHistoryCarbohydrate constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__CARBOHYDRATE" - } + override val friendlyName: String = "REVIEW__CARBOHYDRATE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Daily.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryDaily.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Daily.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryDaily.kt index d0b3625e6a..20956e6304 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Daily.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryDaily.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Daily @JvmOverloads constructor( +class DanaRSPacketHistoryDaily constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DAILY aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__DAILY" - } + override val friendlyName: String = "REVIEW__DAILY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Prime.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Prime.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt index 4069f9be0b..b87611ee9b 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Prime.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Prime @JvmOverloads constructor( +class DanaRSPacketHistoryPrime @JvmOverloads constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__PRIME aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__PRIME" - } + override val friendlyName: String = "REVIEW__PRIME" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Refill.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryRefill.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Refill.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryRefill.kt index ba83640f5b..ca59c45876 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Refill.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryRefill.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Refill @JvmOverloads constructor( +class DanaRSPacketHistoryRefill constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__REFILL aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__REFILL" - } + override val friendlyName: String = "REVIEW__REFILL" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Suspend.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistorySuspend.kt similarity index 67% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Suspend.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistorySuspend.kt index fdc4bb7086..ab920b8e5c 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Suspend.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistorySuspend.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Suspend @JvmOverloads constructor( +class DanaRSPacketHistorySuspend constructor( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SUSPEND aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__SUSPEND" - } + override val friendlyName: String = "REVIEW__SUSPEND" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Temporary.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryTemporary.kt similarity index 70% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Temporary.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryTemporary.kt index 534a0f0667..c7c909bf71 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_Temporary.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryTemporary.kt @@ -4,17 +4,15 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_History_Temporary( +class DanaRSPacketHistoryTemporary( injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(injector, from) { +) : DanaRSPacketHistory(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY aapsLogger.debug(LTag.PUMPCOMM, "New message") } - override fun getFriendlyName(): String { - return "REVIEW__TEMPORARY" - } + override val friendlyName: String = "REVIEW__TEMPORARY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyAlarm.kt similarity index 95% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyAlarm.kt index f49f25010a..f46b5581f4 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyAlarm.kt @@ -12,9 +12,9 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject -class DanaRS_Packet_Notify_Alarm( +class DanaRSPacketNotifyAlarm( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -69,7 +69,5 @@ class DanaRS_Packet_Notify_Alarm( pumpSync.insertAnnouncement(errorString, null, danaPump.pumpType(), danaPump.serialNumber) } - override fun getFriendlyName(): String { - return "NOTIFY__ALARM" - } + override val friendlyName: String = "NOTIFY__ALARM" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Delivery_Complete.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryComplete.kt similarity index 90% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Delivery_Complete.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryComplete.kt index fd245226d3..c6b55b2e96 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Delivery_Complete.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryComplete.kt @@ -11,9 +11,9 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import kotlin.math.min -class DanaRS_Packet_Notify_Delivery_Complete( +class DanaRSPacketNotifyDeliveryComplete( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -37,7 +37,5 @@ class DanaRS_Packet_Notify_Delivery_Complete( aapsLogger.debug(LTag.PUMPCOMM, "Delivered insulin: $deliveredInsulin") } - override fun getFriendlyName(): String { - return "NOTIFY__DELIVERY_COMPLETE" - } + override val friendlyName: String = "NOTIFY__DELIVERY_COMPLETE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryRateDisplay.kt similarity index 90% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryRateDisplay.kt index 8c54865d4a..e1a18ddd40 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryRateDisplay.kt @@ -11,9 +11,9 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import kotlin.math.min -class DanaRS_Packet_Notify_Delivery_Rate_Display( +class DanaRSPacketNotifyDeliveryRateDisplay( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @@ -37,7 +37,5 @@ class DanaRS_Packet_Notify_Delivery_Rate_Display( aapsLogger.debug(LTag.PUMPCOMM, "Delivered insulin so far: $deliveredInsulin") } - override fun getFriendlyName(): String { - return "NOTIFY__DELIVERY_RATE_DISPLAY" - } + override val friendlyName: String = "NOTIFY__DELIVERY_RATE_DISPLAY" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyMissedBolusAlarm.kt similarity index 89% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyMissedBolusAlarm.kt index 1fea0135ab..e8799c34e0 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyMissedBolusAlarm.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Notify_Missed_Bolus_Alarm( +class DanaRSPacketNotifyMissedBolusAlarm( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY @@ -38,7 +38,5 @@ class DanaRS_Packet_Notify_Missed_Bolus_Alarm( aapsLogger.debug(LTag.PUMPCOMM, "End min: $endMin") } - override fun getFriendlyName(): String { - return "NOTIFY__MISSED_BOLUS_ALARM" - } + override val friendlyName: String = "NOTIFY__MISSED_BOLUS_ALARM" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetPumpTime.kt similarity index 89% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetPumpTime.kt index ded5b89540..c726b6c8f1 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetPumpTime.kt @@ -7,9 +7,9 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import org.joda.time.DateTime import javax.inject.Inject -class DanaRS_Packet_Option_Get_Pump_Time( +class DanaRSPacketOptionGetPumpTime( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -35,7 +35,5 @@ class DanaRS_Packet_Option_Get_Pump_Time( danaPump.resetPumpTime() } - override fun getFriendlyName(): String { - return "OPTION__GET_PUMP_TIME" - } + override val friendlyName: String = "OPTION__GET_PUMP_TIME" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetPumpUTCAndTimeZone.kt similarity index 88% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetPumpUTCAndTimeZone.kt index 61040521ea..c0015e505d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetPumpUTCAndTimeZone.kt @@ -7,9 +7,9 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import org.joda.time.DateTime import javax.inject.Inject -class DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone( +class DanaRSPacketOptionGetPumpUTCAndTimeZone( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -36,7 +36,5 @@ class DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone( danaPump.resetPumpTime() } - override fun getFriendlyName(): String { - return "OPTION__GET_PUMP_UTC_AND_TIMEZONE" - } + override val friendlyName: String = "OPTION__GET_PUMP_UTC_AND_TIMEZONE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_User_Option.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetUserOption.kt similarity index 95% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_User_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetUserOption.kt index 7c2a9fa16d..f6b88ca139 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_User_Option.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionGetUserOption.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Option_Get_User_Option( +class DanaRSPacketOptionGetUserOption( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -57,7 +57,5 @@ class DanaRS_Packet_Option_Get_User_Option( aapsLogger.debug(LTag.PUMPCOMM, "target: ${if (danaPump.units == DanaPump.UNITS_MGDL) danaPump.target else danaPump.target / 100}") } - override fun getFriendlyName(): String { - return "OPTION__GET_USER_OPTION" - } + override val friendlyName: String = "OPTION__GET_USER_OPTION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetPumpTime.kt similarity index 88% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_Time.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetPumpTime.kt index dc4b6b0efe..e27646403a 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_Time.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetPumpTime.kt @@ -5,10 +5,10 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption import org.joda.time.DateTime -class DanaRS_Packet_Option_Set_Pump_Time( +class DanaRSPacketOptionSetPumpTime( injector: HasAndroidInjector, private var time: Long = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { var error = 0 @@ -31,6 +31,7 @@ class DanaRS_Packet_Option_Set_Pump_Time( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -40,7 +41,5 @@ class DanaRS_Packet_Option_Set_Pump_Time( } } - override fun getFriendlyName(): String { - return "OPTION__SET_PUMP_TIME" - } + override val friendlyName: String = "OPTION__SET_PUMP_TIME" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetPumpUTCAndTimeZone.kt similarity index 88% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetPumpUTCAndTimeZone.kt index 3fbf79a388..afdaba9b5f 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetPumpUTCAndTimeZone.kt @@ -6,11 +6,11 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import org.joda.time.DateTime import org.joda.time.DateTimeZone -class DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone( +class DanaRSPacketOptionSetPumpUTCAndTimeZone( injector: HasAndroidInjector, private var time: Long = 0, private var zoneOffset: Int = 0 -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { var error = 0 @@ -34,6 +34,7 @@ class DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -43,7 +44,5 @@ class DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone( } } - override fun getFriendlyName(): String { - return "OPTION__SET_PUMP_UTC_AND_TIMEZONE" - } + override val friendlyName: String = "OPTION__SET_PUMP_UTC_AND_TIMEZONE" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_User_Option.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOption.kt similarity index 94% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_User_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOption.kt index ae2e0c03ef..e88969ab4f 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_User_Option.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOption.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Option_Set_User_Option( +class DanaRSPacketOptionSetUserOption( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -54,6 +54,7 @@ class DanaRS_Packet_Option_Set_User_Option( override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) + @Suppress("LiftReturnOrAssignment") if (result == 0) { aapsLogger.debug(LTag.PUMPCOMM, "Result OK") failed = false @@ -63,7 +64,5 @@ class DanaRS_Packet_Option_Set_User_Option( } } - override fun getFriendlyName(): String { - return "OPTION__SET_USER_OPTION" - } + override val friendlyName: String = "OPTION__SET_USER_OPTION" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Review_Bolus_Avg.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketReviewBolusAvg.kt similarity index 91% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Review_Bolus_Avg.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketReviewBolusAvg.kt index 6e0af1260f..5a1577f208 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Review_Bolus_Avg.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketReviewBolusAvg.kt @@ -4,9 +4,9 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRS_Packet_Review_Bolus_Avg( +class DanaRSPacketReviewBolusAvg( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG @@ -38,7 +38,5 @@ class DanaRS_Packet_Review_Bolus_Avg( aapsLogger.debug(LTag.PUMPCOMM, "Bolus average 28d: $bolusAvg28 U") } - override fun getFriendlyName(): String { - return "REVIEW__BOLUS_AVG" - } + override val friendlyName: String = "REVIEW__BOLUS_AVG" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketReviewGetPumpDecRatio.kt similarity index 80% rename from danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt rename to danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketReviewGetPumpDecRatio.kt index 990ffce54c..eafc4837d4 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketReviewGetPumpDecRatio.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import javax.inject.Inject -class DanaRS_Packet_Review_Get_Pump_Dec_Ratio( +class DanaRSPacketReviewGetPumpDecRatio( injector: HasAndroidInjector -) : DanaRS_Packet(injector) { +) : DanaRSPacket(injector) { @Inject lateinit var danaPump: DanaPump @@ -23,7 +23,5 @@ class DanaRS_Packet_Review_Get_Pump_Dec_Ratio( aapsLogger.debug(LTag.PUMPCOMM, "Dec ratio: ${danaPump.decRatio}%") } - override fun getFriendlyName(): String { - return "REVIEW__GET_PUMP_DEC_RATIO" - } + override val friendlyName: String = "REVIEW__GET_PUMP_DEC_RATIO" } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt deleted file mode 100644 index 721479198c..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt +++ /dev/null @@ -1,47 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import java.util.* -import javax.inject.Inject - -open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate( - injector: HasAndroidInjector, - private val profileNumber: Int = 0 -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE - aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates for profile $profileNumber") - } - - override fun getRequestParams(): ByteArray { - val request = ByteArray(1) - request[0] = (profileNumber and 0xff).toByte() - return request - } - - override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 2 - danaPump.pumpProfiles = Array(4) { Array(48) { 0.0 } } - var i = 0 - val size = 24 - while (i < size) { - danaPump.pumpProfiles!![profileNumber][i] = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - i++ - } - for (index in 0..23) - aapsLogger.debug(LTag.PUMPCOMM, "Basal " + String.format(Locale.ENGLISH, "%02d", index) + "h: " + danaPump.pumpProfiles!![profileNumber][index]) - } - - override fun getFriendlyName(): String { - return "BASAL__GET_PROFILE_BASAL_RATE" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt deleted file mode 100644 index f8f475f759..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt +++ /dev/null @@ -1,55 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject -import kotlin.math.abs -import kotlin.math.ceil - -class DanaRS_Packet_Basal_Get_Temporary_Basal_State( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE - aapsLogger.debug(LTag.PUMPCOMM, "Requesting temporary basal status") - } - - var isTempBasalInProgress: Boolean = false - var tempBasalTotalSec: Int = 0 - var tempBasalPercent: Int = 0 - - override fun handleMessage(data: ByteArray) { - val error = byteArrayToInt(getBytes(data, DATA_START, 1)) - isTempBasalInProgress = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) == 0x01 - val isAPSTempBasalInProgress = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) == 0x02 - tempBasalPercent = byteArrayToInt(getBytes(data, DATA_START + 2, 1)) - if (tempBasalPercent > 200) tempBasalPercent = (tempBasalPercent - 200) * 10 - val durationHour = byteArrayToInt(getBytes(data, DATA_START + 3, 1)) - tempBasalTotalSec = if (durationHour == 150) 15 * 60 else if (durationHour == 160) 30 * 60 else durationHour * 60 * 60 - val runningMin = byteArrayToInt(getBytes(data, DATA_START + 4, 2)) - if (error != 0) failed = true - val tempBasalRemainingMin = (danaPump.tempBasalTotalSec - runningMin * 60) / 60 - val tempBasalStart = if (isTempBasalInProgress) getDateFromTempBasalSecAgo(runningMin * 60) else 0 - if (!isTempBasalInProgress) danaPump.isTempBasalInProgress = false - aapsLogger.debug(LTag.PUMPCOMM, "Error code: $error") - aapsLogger.debug(LTag.PUMPCOMM, "Is temp basal running: $isTempBasalInProgress") - aapsLogger.debug(LTag.PUMPCOMM, "Is APS temp basal running: $isAPSTempBasalInProgress") - aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: $tempBasalPercent") - aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin") - aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: $tempBasalTotalSec") - aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + dateUtil.dateAndTimeString(tempBasalStart)) - } - - override fun getFriendlyName(): String { - return "BASAL__TEMPORARY_BASAL_STATE" - } - - private fun getDateFromTempBasalSecAgo(tempBasalAgoSecs: Int): Long { - return (ceil(System.currentTimeMillis() / 1000.0) - tempBasalAgoSecs).toLong() * 1000 - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt deleted file mode 100644 index de96fb2c4d..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt +++ /dev/null @@ -1,45 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.danars.encryption.BleEncryption - -class DanaRS_Packet_Basal_Set_Basal_Rate( - injector: HasAndroidInjector, - private var profileBasalRate: Array -) : DanaRS_Packet(injector) { - - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_BASAL_RATE - aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates") - } - - override fun getRequestParams(): ByteArray { - val request = ByteArray(48) - var i = 0 - val size = 24 - while (i < size) { - val rate = (profileBasalRate[i] * 100.0).toInt() - request[0 + i * 2] = (rate and 0xff).toByte() - request[1 + i * 2] = (rate ushr 8 and 0xff).toByte() - i++ - } - return request - } - - override fun handleMessage(data: ByteArray) { - val result = intFromBuff(data, 0, 1) - if (result == 0) { - aapsLogger.debug(LTag.PUMPCOMM, "Result OK") - failed = false - } else { - aapsLogger.error("Result Error: $result") - failed = true - } - } - - override fun getFriendlyName(): String { - return "BASAL__SET_BASAL_RATE" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt deleted file mode 100644 index e51a25967d..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt +++ /dev/null @@ -1,39 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject - -class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 1 - val error = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - val carbs = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - danaPump.currentCIR = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - if (error != 0) failed = true - aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") - aapsLogger.debug(LTag.PUMPCOMM, "Carbs: $carbs") - aapsLogger.debug(LTag.PUMPCOMM, "Current CIR: " + danaPump.currentCIR) - } - - override fun getFriendlyName(): String { - return "BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt deleted file mode 100644 index 309f3ed561..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt +++ /dev/null @@ -1,37 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject - -class DanaRS_Packet_Bolus_Get_Dual_Bolus( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - val error = byteArrayToInt(getBytes(data, DATA_START, 1)) - danaPump.bolusStep = byteArrayToInt(getBytes(data, DATA_START + 1, 2)) / 100.0 - val extendedBolusAbsoluteRate = byteArrayToInt(getBytes(data, DATA_START + 3, 2)) / 100.0 - danaPump.maxBolus = byteArrayToInt(getBytes(data, DATA_START + 5, 2)) / 100.0 - val bolusIncrement = byteArrayToInt(getBytes(data, DATA_START + 7, 1)) / 100.0 - failed = error != 0 - aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") - aapsLogger.debug(LTag.PUMPCOMM, "Bolus step: ${danaPump.bolusStep} U") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus running: $extendedBolusAbsoluteRate U/h") - aapsLogger.debug(LTag.PUMPCOMM, "Max bolus: " + danaPump.maxBolus + " U") - aapsLogger.debug(LTag.PUMPCOMM, "bolusIncrement: $bolusIncrement U") - } - - override fun getFriendlyName(): String { - return "BOLUS__GET_DUAL_BOLUS" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt deleted file mode 100644 index 623e1f8361..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt +++ /dev/null @@ -1,43 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject - -class DanaRS_Packet_Bolus_Get_Extended_Bolus( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 1 - val error = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - val extendedBolusAbsoluteRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - danaPump.maxBolus = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 1 - danaPump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - failed = error != 0 - aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus running: $extendedBolusAbsoluteRate U/h") - aapsLogger.debug(LTag.PUMPCOMM, "Max bolus: " + danaPump.maxBolus + " U") - aapsLogger.debug(LTag.PUMPCOMM, "Bolus step: " + danaPump.bolusStep + " U") - } - - override fun getFriendlyName(): String { - return "BOLUS__GET_EXTENDED_BOLUS" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt deleted file mode 100644 index e3e6cb9e45..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt +++ /dev/null @@ -1,54 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import info.nightscout.androidaps.utils.T -import javax.inject.Inject - -class DanaRS_Packet_Bolus_Get_Extended_Bolus_State( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - var isExtendedInProgress: Boolean = false - - override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 1 - val error = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01 - dataIndex += dataSize - dataSize = 1 - val extendedBolusDuration = T.mins(byteArrayToInt(getBytes(data, dataIndex, dataSize)) * 30L).msecs() - dataIndex += dataSize - dataSize = 2 - val extendedBolusAbsoluteRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 // duration must be set first for recalculation to amount - dataIndex += dataSize - dataSize = 2 - val extendedBolusSoFarInMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - val extendedBolusDeliveredSoFar = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - failed = error != 0 - aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") - aapsLogger.debug(LTag.PUMPCOMM, "Is extended bolus running: $isExtendedInProgress") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus running: $extendedBolusAbsoluteRate U/h") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus duration: " + T.msecs(extendedBolusDuration).mins() + " min") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus so far: $extendedBolusSoFarInMinutes min") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus delivered so far: $extendedBolusDeliveredSoFar U") - } - - override fun getFriendlyName(): String { - return "BOLUS__GET_EXTENDED_BOLUS_STATE" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt deleted file mode 100644 index 9f4a26da6f..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt +++ /dev/null @@ -1,35 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject - -class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - var isExtendedInProgress: Boolean = false - - override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 1 - val extendedMenuOption = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01 - aapsLogger.debug(LTag.PUMPCOMM, "extendedMenuOption: $extendedMenuOption") - } - - override fun getFriendlyName(): String { - return "BOLUS__GET_EXTENDED_MENU_OPTION_STATE" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt deleted file mode 100644 index 3c58bc5175..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt +++ /dev/null @@ -1,43 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.danars.encryption.BleEncryption - -class DanaRS_Packet_Bolus_Get_Initial_Bolus( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - val initialBolusValue01: Double - val initialBolusValue02: Double - val initialBolusValue03: Double - val initialBolusValue04: Double - var dataIndex = DATA_START - var dataSize = 2 - initialBolusValue01 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - initialBolusValue02 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - initialBolusValue03 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - initialBolusValue04 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - failed = initialBolusValue01 == 0.0 && initialBolusValue02 == 0.0 && initialBolusValue03 == 0.0 && initialBolusValue04 == 0.0 - aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount 01: $initialBolusValue01") - aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount 02: $initialBolusValue02") - aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount 03: $initialBolusValue03") - aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount 04: $initialBolusValue04") - } - - override fun getFriendlyName(): String { - return "BOLUS__GET_BOLUS_RATE" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt deleted file mode 100644 index 783b874f4a..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt +++ /dev/null @@ -1,77 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.danars.encryption.BleEncryption - -class DanaRS_Packet_Bolus_Set_CIR_CF_Array( - injector: HasAndroidInjector, - private var cir01: Int = 0, - private var cir02: Int = 0, - private var cir03: Int = 0, - private var cir04: Int = 0, - private var cir05: Int = 0, - private var cir06: Int = 0, - private var cir07: Int = 0, - private var cf01: Int = 0, - private var cf02: Int = 0, - private var cf03: Int = 0, - private var cf04: Int = 0, - private var cf05: Int = 0, - private var cf06: Int = 0, - private var cf07: Int = 0 -) : DanaRS_Packet(injector) { - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun getRequestParams(): ByteArray { - val request = ByteArray(28) - request[0] = (cir01 and 0xff).toByte() - request[1] = (cir01 ushr 8 and 0xff).toByte() - request[2] = (cir02 and 0xff).toByte() - request[3] = (cir02 ushr 8 and 0xff).toByte() - request[4] = (cir03 and 0xff).toByte() - request[5] = (cir03 ushr 8 and 0xff).toByte() - request[6] = (cir04 and 0xff).toByte() - request[7] = (cir04 ushr 8 and 0xff).toByte() - request[8] = (cir05 and 0xff).toByte() - request[9] = (cir05 ushr 8 and 0xff).toByte() - request[10] = (cir06 and 0xff).toByte() - request[11] = (cir06 ushr 8 and 0xff).toByte() - request[12] = (cir07 and 0xff).toByte() - request[13] = (cir07 ushr 8 and 0xff).toByte() - request[14] = (cf01 and 0xff).toByte() - request[15] = (cf01 ushr 8 and 0xff).toByte() - request[16] = (cf02 and 0xff).toByte() - request[17] = (cf02 ushr 8 and 0xff).toByte() - request[18] = (cf03 and 0xff).toByte() - request[19] = (cf03 ushr 8 and 0xff).toByte() - request[20] = (cf04 and 0xff).toByte() - request[21] = (cf04 ushr 8 and 0xff).toByte() - request[22] = (cf05 and 0xff).toByte() - request[23] = (cf05 ushr 8 and 0xff).toByte() - request[24] = (cf06 and 0xff).toByte() - request[25] = (cf06 ushr 8 and 0xff).toByte() - request[26] = (cf07 and 0xff).toByte() - request[27] = (cf07 ushr 8 and 0xff).toByte() - return request - } - - override fun handleMessage(data: ByteArray) { - val result = intFromBuff(data, 0, 1) - if (result == 0) { - aapsLogger.debug(LTag.PUMPCOMM, "Result OK") - failed = false - } else { - aapsLogger.error("Result Error: $result") - failed = true - } - } - - override fun getFriendlyName(): String { - return "BOLUS__SET_CIR_CF_ARRAY" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt deleted file mode 100644 index 0f93dbf349..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt +++ /dev/null @@ -1,45 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.danars.encryption.BleEncryption - -class DanaRS_Packet_Bolus_Set_Dual_Bolus( - injector: HasAndroidInjector, - private var amount: Double = 0.0, - private var extendedAmount: Double = 0.0, - private var extendedBolusDurationInHalfHours: Int = 0 -) : DanaRS_Packet(injector) { - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS - aapsLogger.debug(LTag.PUMPCOMM, "Dual bolus start : $amount U extended: $extendedAmount U halfhours: $extendedBolusDurationInHalfHours") - } - - override fun getRequestParams(): ByteArray { - val stepBolusRate = (amount / 100.0).toInt() - val extendedBolusRate = (extendedAmount / 100.0).toInt() - val request = ByteArray(5) - request[0] = (stepBolusRate and 0xff).toByte() - request[1] = (stepBolusRate ushr 8 and 0xff).toByte() - request[2] = (extendedBolusRate and 0xff).toByte() - request[3] = (extendedBolusRate ushr 8 and 0xff).toByte() - request[4] = (extendedBolusDurationInHalfHours and 0xff).toByte() - return request - } - - override fun handleMessage(data: ByteArray) { - val result = intFromBuff(data, 0, 1) - if (result == 0) { - aapsLogger.debug(LTag.PUMPCOMM, "Result OK") - failed = false - } else { - aapsLogger.error("Result Error: $result") - failed = true - } - } - - override fun getFriendlyName(): String { - return "BOLUS__SET_DUAL_BOLUS" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt deleted file mode 100644 index 6b8278ac29..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt +++ /dev/null @@ -1,47 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.danars.encryption.BleEncryption - -class DanaRS_Packet_Bolus_Set_Initial_Bolus( - injector: HasAndroidInjector, - private var bolusRate01: Int = 0, - private var bolusRate02: Int = 0, - private var bolusRate03: Int = 0, - private var bolusRate04: Int = 0 -) : DanaRS_Packet(injector) { - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun getRequestParams(): ByteArray { - val request = ByteArray(8) - request[0] = (bolusRate01 and 0xff).toByte() - request[1] = (bolusRate01 ushr 8 and 0xff).toByte() - request[2] = (bolusRate02 and 0xff).toByte() - request[3] = (bolusRate02 ushr 8 and 0xff).toByte() - request[4] = (bolusRate03 and 0xff).toByte() - request[5] = (bolusRate03 ushr 8 and 0xff).toByte() - request[6] = (bolusRate04 and 0xff).toByte() - request[7] = (bolusRate04 ushr 8 and 0xff).toByte() - return request - } - - override fun handleMessage(data: ByteArray) { - val result = intFromBuff(data, 0, 1) - if (result == 0) { - aapsLogger.debug(LTag.PUMPCOMM, "Result OK") - failed = false - } else { - aapsLogger.error("Result Error: $result") - failed = true - } - } - - override fun getFriendlyName(): String { - return "BOLUS__SET_BOLUS_RATE" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Delivery_Status.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Delivery_Status.kt deleted file mode 100644 index 9ff3884a57..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Delivery_Status.kt +++ /dev/null @@ -1,30 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.danars.encryption.BleEncryption - -class DanaRS_Packet_General_Delivery_Status( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - val result = intFromBuff(data, 0, 1) - if (result == 0) { - aapsLogger.debug(LTag.PUMPCOMM, "Result OK") - failed = false - } else { - aapsLogger.error("Result Error: $result") - failed = true - } - } - - override fun getFriendlyName(): String { - return "REVIEW__DELIVERY_STATUS" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt deleted file mode 100644 index 4659e91dae..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt +++ /dev/null @@ -1,49 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import org.joda.time.DateTime -import org.joda.time.DateTimeZone -import javax.inject.Inject - -class DanaRS_Packet_General_Get_More_Information( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - if (data.size < 15) { - failed = true - return - } - danaPump.iob = intFromBuff(data, 0, 2) / 100.0 - danaPump.dailyTotalUnits = intFromBuff(data, 2, 2) / 100.0 - val isExtendedInProgress = intFromBuff(data, 4, 1) == 0x01 - val extendedBolusRemainingMinutes = intFromBuff(data, 5, 2) - // val remainRate = intFromBuff(data, 7, 2) / 100.0 - val hours = intFromBuff(data, 9, 1) - val minutes = intFromBuff(data, 10, 1) - if (danaPump.usingUTC) danaPump.lastBolusTime = DateTime.now().withZone(DateTimeZone.UTC).withHourOfDay(hours).withMinuteOfHour(minutes).millis - else danaPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis - danaPump.lastBolusAmount = intFromBuff(data, 11, 2) / 100.0 - // On DanaRS DailyUnits can't be more than 160 - if (danaPump.dailyTotalUnits > 160) failed = true - aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaPump.dailyTotalUnits.toString() + " U") - aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: $isExtendedInProgress") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: $extendedBolusRemainingMinutes") - aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + dateUtil.dateAndTimeAndSecondsString(danaPump.lastBolusTime)) - aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaPump.lastBolusAmount) - } - - override fun getFriendlyName(): String { - return "REVIEW__GET_MORE_INFORMATION" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Password.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Password.kt deleted file mode 100644 index 34d9ce1238..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Password.kt +++ /dev/null @@ -1,36 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject - -class DanaRS_Packet_General_Get_Password( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - if (data.size < 2) { // returned data size is too small - failed = true - return - } else { - failed = false - } - var pass: Int = (data[DATA_START + 1].toInt() and 0x000000FF shl 8) + (data[DATA_START + 0].toInt() and 0x000000FF) - pass = pass xor 3463 - danaPump.rsPassword = Integer.toHexString(pass) - aapsLogger.debug(LTag.PUMPCOMM, "Pump password: " + danaPump.rsPassword) - } - - override fun getFriendlyName(): String { - return "REVIEW__GET_PASSWORD" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt deleted file mode 100644 index 4eece3e5fe..0000000000 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt +++ /dev/null @@ -1,42 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.encryption.BleEncryption -import javax.inject.Inject - -class DanaRS_Packet_General_Get_Today_Delivery_Total( - injector: HasAndroidInjector -) : DanaRS_Packet(injector) { - - @Inject lateinit var danaPump: DanaPump - - init { - opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL - aapsLogger.debug(LTag.PUMPCOMM, "New message") - } - - override fun handleMessage(data: ByteArray) { - if (data.size < 8) { - failed = true - return - } else failed = false - var dataIndex = DATA_START - var dataSize = 2 - danaPump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - danaPump.dailyTotalBasalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - danaPump.dailyTotalBolusUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - aapsLogger.debug(LTag.PUMPCOMM, "Daily total: " + danaPump.dailyTotalUnits + " U") - aapsLogger.debug(LTag.PUMPCOMM, "Daily total bolus: " + danaPump.dailyTotalBolusUnits + " U") - aapsLogger.debug(LTag.PUMPCOMM, "Daily total basal: " + danaPump.dailyTotalBasalUnits + " U") - } - - override fun getFriendlyName(): String { - return "REVIEW__GET_TODAY_DELIVERY_TOTAL" - } -} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt b/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt index f239525f85..cef12e716c 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt @@ -8,76 +8,60 @@ import info.nightscout.androidaps.danars.comm.* @Suppress("unused") abstract class DanaRSCommModule { - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet(): DanaRS_Packet - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(): DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Basal_Rate(): DanaRS_Packet_Basal_Get_Basal_Rate - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Profile_Basal_Rate(): DanaRS_Packet_Basal_Get_Profile_Basal_Rate - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Profile_Number(): DanaRS_Packet_Basal_Get_Profile_Number - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Basal_Rate(): DanaRS_Packet_Basal_Set_Basal_Rate - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Profile_Basal_Rate(): DanaRS_Packet_Basal_Set_Profile_Basal_Rate - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Profile_Number(): DanaRS_Packet_Basal_Set_Profile_Number - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Suspend_Off(): DanaRS_Packet_Basal_Set_Suspend_Off - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Suspend_On(): DanaRS_Packet_Basal_Set_Suspend_On - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Temporary_Basal(): DanaRS_Packet_Basal_Set_Temporary_Basal - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Temporary_Basal_State(): DanaRS_Packet_Basal_Get_Temporary_Basal_State - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Bolus_Option(): DanaRS_Packet_Bolus_Get_Bolus_Option - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Initial_Bolus(): DanaRS_Packet_Bolus_Get_Initial_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Calculation_Information(): DanaRS_Packet_Bolus_Get_Calculation_Information - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(): DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_CIR_CF_Array(): DanaRS_Packet_Bolus_Get_CIR_CF_Array - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_24_CIR_CF_Array(): DanaRS_Packet_Bolus_Get_24_CIR_CF_Array - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Dual_Bolus(): DanaRS_Packet_Bolus_Get_Dual_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus(): DanaRS_Packet_Bolus_Get_Extended_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus_State(): DanaRS_Packet_Bolus_Get_Extended_Bolus_State - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(): DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Step_Bolus_Information(): DanaRS_Packet_Bolus_Get_Step_Bolus_Information - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Bolus_Option(): DanaRS_Packet_Bolus_Set_Bolus_Option - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Initial_Bolus(): DanaRS_Packet_Bolus_Set_Initial_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_CIR_CF_Array(): DanaRS_Packet_Bolus_Set_CIR_CF_Array - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_24_CIR_CF_Array(): DanaRS_Packet_Bolus_Set_24_CIR_CF_Array - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Dual_Bolus(): DanaRS_Packet_Bolus_Set_Dual_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus(): DanaRS_Packet_Bolus_Set_Extended_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(): DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Step_Bolus_Start(): DanaRS_Packet_Bolus_Set_Step_Bolus_Start - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Step_Bolus_Stop(): DanaRS_Packet_Bolus_Set_Step_Bolus_Stop - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Etc_Keep_Connection(): DanaRS_Packet_Etc_Keep_Connection - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Etc_Set_History_Save(): DanaRS_Packet_Etc_Set_History_Save - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Delivery_Status(): DanaRS_Packet_General_Delivery_Status - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Password(): DanaRS_Packet_General_Get_Password - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Initial_Screen_Information(): DanaRS_Packet_General_Initial_Screen_Information - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Alarm(): DanaRS_Packet_Notify_Alarm - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Delivery_Complete(): DanaRS_Packet_Notify_Delivery_Complete - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Delivery_Rate_Display(): DanaRS_Packet_Notify_Delivery_Rate_Display - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Missed_Bolus_Alarm(): DanaRS_Packet_Notify_Missed_Bolus_Alarm - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_Pump_Time(): DanaRS_Packet_Option_Get_Pump_Time - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_User_Option(): DanaRS_Packet_Option_Get_User_Option - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_Pump_Time(): DanaRS_Packet_Option_Set_Pump_Time - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_User_Option(): DanaRS_Packet_Option_Set_User_Option - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_(): DanaRS_Packet_History_ - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Alarm(): DanaRS_Packet_History_Alarm - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_All_History(): DanaRS_Packet_History_All_History - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Basal(): DanaRS_Packet_History_Basal - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Blood_Glucose(): DanaRS_Packet_History_Blood_Glucose - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Bolus(): DanaRS_Packet_History_Bolus - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Bolus_Avg(): DanaRS_Packet_Review_Bolus_Avg - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Carbohydrate(): DanaRS_Packet_History_Carbohydrate - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Daily(): DanaRS_Packet_History_Daily - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_More_Information(): DanaRS_Packet_General_Get_More_Information - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Pump_Check(): DanaRS_Packet_General_Get_Pump_Check - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Information(): DanaRS_Packet_General_Get_Shipping_Information - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Today_Delivery_Total(): DanaRS_Packet_General_Get_Today_Delivery_Total - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_User_Time_Change_Flag(): DanaRS_Packet_General_Get_User_Time_Change_Flag - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Prime(): DanaRS_Packet_History_Prime - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Refill(): DanaRS_Packet_History_Refill - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Set_History_Upload_Mode(): DanaRS_Packet_General_Set_History_Upload_Mode - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(): DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Suspend(): DanaRS_Packet_History_Suspend - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Temporary(): DanaRS_Packet_History_Temporary - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Basal_Set_Temporary_Basal(): DanaRS_Packet_APS_Basal_Set_Temporary_Basal - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_History_Events(): DanaRS_Packet_APS_History_Events - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Set_Event_History(): DanaRS_Packet_APS_Set_Event_History - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Version(): DanaRS_Packet_General_Get_Shipping_Version - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Get_Pump_Dec_Ratio(): DanaRS_Packet_Review_Get_Pump_Dec_Ratio - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(): DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone - @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(): DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone + @ContributesAndroidInjector abstract fun contributesDanaRSPacket(): DanaRSPacket + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalSetCancelTemporaryBasal(): DanaRSPacketBasalSetCancelTemporaryBasal + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalGetBasalRate(): DanaRSPacketBasalGetBasalRate + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalGetProfileNumber(): DanaRSPacketBasalGetProfileNumber + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalSetProfileBasalRate(): DanaRSPacketBasalSetProfileBasalRate + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalSetProfileNumber(): DanaRSPacketBasalSetProfileNumber + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalSetSuspendOff(): DanaRSPacketBasalSetSuspendOff + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalSetSuspendOn(): DanaRSPacketBasalSetSuspendOn + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBasalSetTemporaryBasal(): DanaRSPacketBasalSetTemporaryBasal + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusGetBolusOption(): DanaRSPacketBolusGetBolusOption + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusGetCalculationInformation(): DanaRSPacketBolusGetCalculationInformation + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusGetCIRCFArray(): DanaRSPacketBolusGetCIRCFArray + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusGetStepBolusInformation(): DanaRSPacketBolusGetStepBolusInformation + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusSetBolusOption(): DanaRSPacketBolusSetBolusOption + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusGet24CIRCFArray(): DanaRSPacketBolusGet24CIRCFArray + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusSet24CIRCFArray(): DanaRSPacketBolusSet24CIRCFArray + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusSetExtendedBolus(): DanaRSPacketBolusSetExtendedBolus + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusSetExtendedBolusCancel(): DanaRSPacketBolusSetExtendedBolusCancel + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusSetStepBolusStart(): DanaRSPacketBolusSetStepBolusStart + @ContributesAndroidInjector abstract fun contributesDanaRSPacketBolusSetStepBolusStop(): DanaRSPacketBolusSetStepBolusStop + @ContributesAndroidInjector abstract fun contributesDanaRSPacketEtcKeepConnection(): DanaRSPacketEtcKeepConnection + @ContributesAndroidInjector abstract fun contributesDanaRSPacketEtcSetHistorySave(): DanaRSPacketEtcSetHistorySave + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralInitialScreenInformation(): DanaRSPacketGeneralInitialScreenInformation + @ContributesAndroidInjector abstract fun contributesDanaRSPacketNotifyDeliveryRateDisplay(): DanaRSPacketNotifyDeliveryRateDisplay + @ContributesAndroidInjector abstract fun contributesDanaRSPacketNotifyAlarm(): DanaRSPacketNotifyAlarm + @ContributesAndroidInjector abstract fun contributesDanaRSPacketNotifyDeliveryComplete(): DanaRSPacketNotifyDeliveryComplete + @ContributesAndroidInjector abstract fun contributesDanaRSPacketNotifyMissedBolusAlarm(): DanaRSPacketNotifyMissedBolusAlarm + @ContributesAndroidInjector abstract fun contributesDanaRSPacketOptionGetPumpTime(): DanaRSPacketOptionGetPumpTime + @ContributesAndroidInjector abstract fun contributesDanaRSPacketOptionGetUserOption(): DanaRSPacketOptionGetUserOption + @ContributesAndroidInjector abstract fun contributesDanaRSPacketOptionSetPumpTime(): DanaRSPacketOptionSetPumpTime + @ContributesAndroidInjector abstract fun contributesDanaRSPacketOptionSetUserOption(): DanaRSPacketOptionSetUserOption + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistory(): DanaRSPacketHistory + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryAlarm(): DanaRSPacketHistoryAlarm + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryAllHistory(): DanaRSPacketHistoryAllHistory + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryBasal(): DanaRSPacketHistoryBasal + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryBloodGlucose(): DanaRSPacketHistoryBloodGlucose + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryBolus(): DanaRSPacketHistoryBolus + @ContributesAndroidInjector abstract fun contributesDanaRSPacketReviewBolusAvg(): DanaRSPacketReviewBolusAvg + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryCarbohydrate(): DanaRSPacketHistoryCarbohydrate + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryDaily(): DanaRSPacketHistoryDaily + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralGetPumpCheck(): DanaRSPacketGeneralGetPumpCheck + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralGetShippingInformation(): DanaRSPacketGeneralGetShippingInformation + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralGetUserTimeChangeFlag(): DanaRSPacketGeneralGetUserTimeChangeFlag + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryPrime(): DanaRSPacketHistoryPrime + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryRefill(): DanaRSPacketHistoryRefill + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralSetHistoryUploadMode(): DanaRSPacketGeneralSetHistoryUploadMode + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralSetUserTimeChangeFlagClear(): DanaRSPacketGeneralSetUserTimeChangeFlagClear + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistorySuspend(): DanaRSPacketHistorySuspend + @ContributesAndroidInjector abstract fun contributesDanaRSPacketHistoryTemporary(): DanaRSPacketHistoryTemporary + @ContributesAndroidInjector abstract fun contributesDanaRSPacketAPSBasalSetTemporaryBasal(): DanaRSPacketAPSBasalSetTemporaryBasal + @ContributesAndroidInjector abstract fun contributesDanaRSPacketAPSHistoryEvents(): DanaRSPacketAPSHistoryEvents + @ContributesAndroidInjector abstract fun contributesDanaRSPacketAPSSetEventHistory(): DanaRSPacketAPSSetEventHistory + @ContributesAndroidInjector abstract fun contributesDanaRSPacketGeneralGetShippingVersion(): DanaRSPacketGeneralGetShippingVersion + @ContributesAndroidInjector abstract fun contributesDanaRSPacketReviewGetPumpDecRatio(): DanaRSPacketReviewGetPumpDecRatio + @ContributesAndroidInjector abstract fun contributesDanaRSPacketOptionGetPumpUTCAndTimeZone(): DanaRSPacketOptionGetPumpUTCAndTimeZone + @ContributesAndroidInjector abstract fun contributesDanaRSPacketOptionSetPumpUTCAndTimeZone(): DanaRSPacketOptionSetPumpUTCAndTimeZone } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt b/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt index 866eee6251..241720a19e 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt @@ -12,8 +12,8 @@ import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.danars.activities.EnterPinActivity import info.nightscout.androidaps.danars.activities.PairingHelperActivity import info.nightscout.androidaps.danars.comm.DanaRSMessageHashTable -import info.nightscout.androidaps.danars.comm.DanaRS_Packet -import info.nightscout.androidaps.danars.comm.DanaRS_Packet_Etc_Keep_Connection +import info.nightscout.androidaps.danars.comm.DanaRSPacket +import info.nightscout.androidaps.danars.comm.DanaRSPacketEtcKeepConnection import info.nightscout.androidaps.danars.encryption.BleEncryption import info.nightscout.androidaps.danars.encryption.EncryptionType import info.nightscout.androidaps.danars.events.EventDanaRSPairingSuccess @@ -67,7 +67,7 @@ class BLEComm @Inject internal constructor( } private var scheduledDisconnection: ScheduledFuture<*>? = null - private var processedMessage: DanaRS_Packet? = null + private var processedMessage: DanaRSPacket? = null private val mSendQueue = ArrayList() private var bluetoothManager: BluetoothManager? = null private var bluetoothAdapter: BluetoothAdapter? = null @@ -408,10 +408,8 @@ class BLEComm @Inject internal constructor( bufferLength -= length + 7 // now we have encrypted packet in inputBuffer - val decrypted = bleEncryption.getDecryptedPacket(inputBuffer) - //aapsLogger.debug(LTag.PUMPBTCOMM, "XXXXXX <<<<< PROCESSING: " + DanaRS_Packet.toHexString(inputBuffer)) - //aapsLogger.debug(LTag.PUMPBTCOMM, "XXXXXY <<<<< PROCESSING: " + DanaRS_Packet.toHexString(decrypted)) // decrypt the packet + val decrypted = bleEncryption.getDecryptedPacket(inputBuffer) decrypted?.let { decryptedBuffer -> if (decryptedBuffer[0] == BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte()) { when (decryptedBuffer[1]) { @@ -470,7 +468,7 @@ class BLEComm @Inject internal constructor( return } val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRSPacket.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) } @@ -479,7 +477,7 @@ class BLEComm @Inject internal constructor( private fun processConnectResponse(decryptedBuffer: ByteArray) { // response OK v1 if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.code.toByte() && decryptedBuffer[3] == 'K'.code.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) encryption = EncryptionType.ENCRYPTION_DEFAULT danaPump.ignoreUserPassword = false // Grab pairing key from preferences if exists @@ -502,11 +500,11 @@ class BLEComm @Inject internal constructor( sp.putString(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName, String.format("%02x", decryptedBuffer[decryptedBuffer.size - 1])) if (danaPump.hwModel == 0x05) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 (OK)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) // Dana RS Pump sendV3PairingInformation() } else if (danaPump.hwModel == 0x06) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 EASY (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 EASY (OK)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) // Dana RS Easy sendEasyMenuCheck() } @@ -517,17 +515,17 @@ class BLEComm @Inject internal constructor( danaPump.ignoreUserPassword = true danaPump.hwModel = decryptedBuffer[5].toInt() danaPump.protocol = decryptedBuffer[7].toInt() - val pairingKey = DanaRS_Packet.asciiStringFromBuff(decryptedBuffer, 8, 6) // used while bonding + val pairingKey = DanaRSPacket.asciiStringFromBuff(decryptedBuffer, 8, 6) // used while bonding if (danaPump.hwModel == 0x09) { bleEncryption.setBle5Key(pairingKey.encodeToByteArray()) - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK BLE5 (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK BLE5 (OK)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) // Dana-i BLE5 Pump sendBLE5PairingInformation() } // response PUMP : error status } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.code.toByte() && decryptedBuffer[3] == 'U'.code.toByte() && decryptedBuffer[4] == 'M'.code.toByte() && decryptedBuffer[5] == 'P'.code.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) mSendQueue.clear() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror))) pumpSync.insertAnnouncement(resourceHelper.gs(R.string.pumperror), null, danaPump.pumpType(), danaPump.serialNumber) @@ -535,12 +533,12 @@ class BLEComm @Inject internal constructor( rxBus.send(EventNewNotification(n)) // response BUSY: error status } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.code.toByte() && decryptedBuffer[3] == 'U'.code.toByte() && decryptedBuffer[4] == 'S'.code.toByte() && decryptedBuffer[5] == 'Y'.code.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) mSendQueue.clear() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy))) } else { // ERROR in response, wrong serial number - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRSPacket.toHexString(decryptedBuffer)) mSendQueue.clear() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) danaRSPlugin.clearPairing() @@ -551,15 +549,15 @@ class BLEComm @Inject internal constructor( // 2nd packet v1 check passkey private fun sendPasskeyCheck(pairingKey: String) { - val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) + val encodedPairingKey = DanaRSPacket.hexToBytes(pairingKey) val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRSPacket.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) } // 2nd packet v1 response private fun processPasskeyCheck(decryptedBuffer: ByteArray) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRSPacket.toHexString(decryptedBuffer)) // Paring is not requested, sending time info if (decryptedBuffer[2] == 0x00.toByte()) sendTimeInfo() // Pairing on pump is requested @@ -590,20 +588,20 @@ class BLEComm @Inject internal constructor( private fun sendBLE5PairingInformation() { val params = ByteArray(4) { 0.toByte() } val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, params, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION BLE5" + " " + DanaRS_Packet.toHexString(bytes)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION BLE5" + " " + DanaRSPacket.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) } private fun sendV3PairingInformation(requestNewPairing: Int) { val params = byteArrayOf(requestNewPairing.toByte()) val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, params, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRSPacket.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) } // 2nd packet response private fun processEncryptionResponse(decryptedBuffer: ByteArray) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + DanaRSPacket.toHexString(decryptedBuffer)) if (encryption == EncryptionType.ENCRYPTION_BLE5) { isConnected = true isConnecting = false @@ -651,7 +649,7 @@ class BLEComm @Inject internal constructor( // 3rd packet v1 existing pairing private fun sendTimeInfo() { val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRSPacket.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) } @@ -661,7 +659,7 @@ class BLEComm @Inject internal constructor( // On pump pairing request is displayed and is waiting for conformation context.startActivity(Intent(context, PairingHelperActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRSPacket.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) } @@ -680,7 +678,7 @@ class BLEComm @Inject internal constructor( // 2nd or 3rd packet v1 response private fun processPairingRequest(decryptedBuffer: ByteArray) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRSPacket.toHexString(decryptedBuffer)) if (decryptedBuffer[2] != 0x00.toByte()) { disconnect("passkey request failed") } @@ -688,14 +686,14 @@ class BLEComm @Inject internal constructor( // 2nd or 3rd packet v1 response private fun processPairingRequest2(decryptedBuffer: ByteArray) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRSPacket.toHexString(decryptedBuffer)) // Paring is successful, sending time info rxBus.send(EventDanaRSPairingSuccess()) sendTimeInfo() val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) // store pairing key to preferences - sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) - aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) + sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRSPacket.bytesToHex(pairingKey)) + aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRSPacket.bytesToHex(pairingKey)) } // 3rd packet Easy menu pump @@ -715,12 +713,12 @@ class BLEComm @Inject internal constructor( } // the rest of packets - fun sendMessage(message: DanaRS_Packet) { + fun sendMessage(message: DanaRSPacket) { encryptedCommandSent = true processedMessage = message val command = byteArrayOf(message.type.toByte(), message.opCode.toByte()) val params = message.getRequestParams() - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + message.friendlyName + " " + DanaRSPacket.toHexString(command) + " " + DanaRSPacket.toHexString(params)) var bytes = bleEncryption.getEncryptedPacket(message.opCode, params, null) // aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + DanaRS_Packet.toHexString(bytes)) if (encryption != EncryptionType.ENCRYPTION_DEFAULT) @@ -780,19 +778,19 @@ class BLEComm @Inject internal constructor( //SystemClock.sleep(200); if (!message.isReceived) { - aapsLogger.warn(LTag.PUMPBTCOMM, "Reply not received " + message.getFriendlyName()) + aapsLogger.warn(LTag.PUMPBTCOMM, "Reply not received " + message.friendlyName) message.handleMessageNotReceived() } // verify encryption for v3 - if (message is DanaRS_Packet_Etc_Keep_Connection) + if (message is DanaRSPacketEtcKeepConnection) if (!message.isReceived) disconnect("KeepAlive not received") } // process common packet response private fun processMessage(decryptedBuffer: ByteArray) { val originalCommand = processedMessage?.command ?: 0xFFFF - val receivedCommand = DanaRS_Packet(injector).getCommand(decryptedBuffer) - val message: DanaRS_Packet? = if (originalCommand == receivedCommand) { + val receivedCommand = DanaRSPacket(injector).getCommand(decryptedBuffer) + val message: DanaRSPacket? = if (originalCommand == receivedCommand) { // it's response to last message processedMessage } else { @@ -800,7 +798,7 @@ class BLEComm @Inject internal constructor( danaRSMessageHashTable.findMessage(receivedCommand) } if (message != null) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message.friendlyName + " " + DanaRSPacket.toHexString(decryptedBuffer)) // process received data message.handleMessage(decryptedBuffer) message.setReceived() @@ -808,7 +806,7 @@ class BLEComm @Inject internal constructor( // notify to sendMessage message.notify() } - } else aapsLogger.error("Unknown message received " + DanaRS_Packet.toHexString(decryptedBuffer)) + } else aapsLogger.error("Unknown message received " + DanaRSPacket.toHexString(decryptedBuffer)) } } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt index 43b3b8fa9d..b541f1096f 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt @@ -110,7 +110,7 @@ class DanaRSService : DaggerService() { bleComm.disconnect(from) } - fun sendMessage(message: DanaRS_Packet) { + fun sendMessage(message: DanaRSPacket) { bleComm.sendMessage(message) } @@ -118,20 +118,20 @@ class DanaRSService : DaggerService() { try { val pump = activePlugin.activePump rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) - sendMessage(DanaRS_Packet_Etc_Keep_Connection(injector)) // test encryption for v3 - sendMessage(DanaRS_Packet_General_Get_Shipping_Information(injector)) // serial no - sendMessage(DanaRS_Packet_General_Get_Pump_Check(injector)) // firmware - sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(injector)) - sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) // isExtendedEnabled - sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal - sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) // target - if (danaPump.profile24) sendMessage(DanaRS_Packet_Bolus_Get_24_CIR_CF_Array(injector)) - else sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) - sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) // Getting user options + sendMessage(DanaRSPacketEtcKeepConnection(injector)) // test encryption for v3 + sendMessage(DanaRSPacketGeneralGetShippingInformation(injector)) // serial no + sendMessage(DanaRSPacketGeneralGetPumpCheck(injector)) // firmware + sendMessage(DanaRSPacketBasalGetProfileNumber(injector)) + sendMessage(DanaRSPacketBolusGetBolusOption(injector)) // isExtendedEnabled + sendMessage(DanaRSPacketBasalGetBasalRate(injector)) // basal profile, basalStep, maxBasal + sendMessage(DanaRSPacketBolusGetCalculationInformation(injector)) // target + if (danaPump.profile24) sendMessage(DanaRSPacketBolusGet24CIRCFArray(injector)) + else sendMessage(DanaRSPacketBolusGetCIRCFArray(injector)) + sendMessage(DanaRSPacketOptionGetUserOption(injector)) // Getting user options rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))) - sendMessage(DanaRS_Packet_General_Initial_Screen_Information(injector)) + sendMessage(DanaRSPacketGeneralInitialScreenInformation(injector)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) // last bolus, bolusStep, maxBolus + sendMessage(DanaRSPacketBolusGetStepBolusInformation(injector)) // last bolus, bolusStep, maxBolus danaPump.lastConnection = System.currentTimeMillis() val profile = profileFunction.getProfile() if (profile != null && abs(danaPump.currentBasal - profile.getBasal()) >= pump.pumpDescription.basalStep) { @@ -141,8 +141,8 @@ class DanaRSService : DaggerService() { } } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))) - if (danaPump.usingUTC) sendMessage(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) - else sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) + if (danaPump.usingUTC) sendMessage(DanaRSPacketOptionGetPumpUTCAndTimeZone(injector)) + else sendMessage(DanaRSPacketOptionGetPumpTime(injector)) var timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L if (danaPump.getPumpTime() == 0L) { // initial handshake was not successful @@ -172,21 +172,21 @@ class DanaRSService : DaggerService() { } else { when { danaPump.usingUTC -> { - sendMessage(DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(injector, dateUtil.now(), offset)) + sendMessage(DanaRSPacketOptionSetPumpUTCAndTimeZone(injector, dateUtil.now(), offset)) } danaPump.protocol >= 6 -> { // can set seconds - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, dateUtil.now())) + sendMessage(DanaRSPacketOptionSetPumpTime(injector, dateUtil.now())) } else -> { waitForWholeMinute() // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cut off anyway) - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, dateUtil.now() + T.secs(10).msecs())) + sendMessage(DanaRSPacketOptionSetPumpTime(injector, dateUtil.now() + T.secs(10).msecs())) } } - if (danaPump.usingUTC) sendMessage(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) - else sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) + if (danaPump.usingUTC) sendMessage(DanaRSPacketOptionGetPumpUTCAndTimeZone(injector)) + else sendMessage(DanaRSPacketOptionGetPumpTime(injector)) timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") } @@ -221,12 +221,12 @@ class DanaRSService : DaggerService() { return result } SystemClock.sleep(1000) - val msg: DanaRS_Packet_APS_History_Events + val msg: DanaRSPacketAPSHistoryEvents if (danaPump.lastHistoryFetched == 0L) { - msg = DanaRS_Packet_APS_History_Events(injector, 0) + msg = DanaRSPacketAPSHistoryEvents(injector, 0) aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history") } else { - msg = DanaRS_Packet_APS_History_Events(injector, danaPump.lastHistoryFetched) + msg = DanaRSPacketAPSHistoryEvents(injector, danaPump.lastHistoryFetched) aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.lastHistoryFetched)) } sendMessage(msg) @@ -240,7 +240,7 @@ class DanaRSService : DaggerService() { } fun setUserSettings(): PumpEnactResult { - val message = DanaRS_Packet_Option_Set_User_Option(injector) + val message = DanaRSPacketOptionSetUserOption(injector) sendMessage(message) return PumpEnactResult(injector).success(message.success()) } @@ -256,11 +256,11 @@ class DanaRSService : DaggerService() { danaPump.bolusStopped = false danaPump.bolusStopForced = false danaPump.bolusProgressLastTimeStamp = dateUtil.now() - val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector, insulin, preferencesSpeed) + val start = DanaRSPacketBolusSetStepBolusStart(injector, insulin, preferencesSpeed) if (carbs > 0) { // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbTime, carbs); #### // sendMessage(msg); - val msgSetHistoryEntryV2 = DanaRS_Packet_APS_Set_Event_History(injector, DanaPump.CARBS, carbTime, carbs, 0) + val msgSetHistoryEntryV2 = DanaRSPacketAPSSetEventHistory(injector, DanaPump.CARBS, carbTime, carbs, 0) sendMessage(msgSetHistoryEntryV2) danaPump.lastHistoryFetched = min(danaPump.lastHistoryFetched, carbTime - T.mins(1).msecs()) } @@ -305,7 +305,7 @@ class DanaRSService : DaggerService() { override fun run() { // reread bolus status rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) // last bolus + sendMessage(DanaRSPacketBolusGetStepBolusInformation(injector)) // last bolus bolusingEvent.percent = 100 rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))) } @@ -315,7 +315,7 @@ class DanaRSService : DaggerService() { fun bolusStop() { aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + if (danaPump.bolusingTreatment == null) "" else danaPump.bolusingTreatment?.insulin) - val stop = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(injector) + val stop = DanaRSPacketBolusSetStepBolusStop(injector) danaPump.bolusStopForced = true if (isConnected) { sendMessage(stop) @@ -332,11 +332,11 @@ class DanaRSService : DaggerService() { if (!isConnected) return false if (danaPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + sendMessage(DanaRSPacketBasalSetCancelTemporaryBasal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - val msgTBR = DanaRS_Packet_Basal_Set_Temporary_Basal(injector, percent, durationInHours) + val msgTBR = DanaRSPacketBasalSetTemporaryBasal(injector, percent, durationInHours) sendMessage(msgTBR) SystemClock.sleep(200) loadEvents() @@ -349,11 +349,11 @@ class DanaRSService : DaggerService() { fun highTempBasal(percent: Int): Boolean { if (danaPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + sendMessage(DanaRSPacketBasalSetCancelTemporaryBasal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - val msgTBR = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, percent) + val msgTBR = DanaRSPacketAPSBasalSetTemporaryBasal(injector, percent) sendMessage(msgTBR) loadEvents() val tbr = pumpSync.expectedPumpState().temporaryBasal @@ -369,11 +369,11 @@ class DanaRSService : DaggerService() { } if (danaPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + sendMessage(DanaRSPacketBasalSetCancelTemporaryBasal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - val msgTBR = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, percent) + val msgTBR = DanaRSPacketAPSBasalSetTemporaryBasal(injector, percent) sendMessage(msgTBR) loadEvents() val tbr = pumpSync.expectedPumpState().temporaryBasal @@ -385,7 +385,7 @@ class DanaRSService : DaggerService() { fun tempBasalStop(): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - val msgCancel = DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector) + val msgCancel = DanaRSPacketBasalSetCancelTemporaryBasal(injector) sendMessage(msgCancel) loadEvents() val tbr = pumpSync.expectedPumpState().temporaryBasal @@ -397,7 +397,7 @@ class DanaRSService : DaggerService() { fun extendedBolus(insulin: Double, durationInHalfHours: Int): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))) - val msgExtended = DanaRS_Packet_Bolus_Set_Extended_Bolus(injector, insulin, durationInHalfHours) + val msgExtended = DanaRSPacketBolusSetExtendedBolus(injector, insulin, durationInHalfHours) sendMessage(msgExtended) SystemClock.sleep(200) loadEvents() @@ -410,7 +410,7 @@ class DanaRSService : DaggerService() { fun extendedBolusStop(): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))) - val msgStop = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector) + val msgStop = DanaRSPacketBolusSetExtendedBolusCancel(injector) sendMessage(msgStop) loadEvents() val eb = pumpSync.expectedPumpState().extendedBolus @@ -423,12 +423,12 @@ class DanaRSService : DaggerService() { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates))) val basal = danaPump.buildDanaRProfileRecord(profile) - val msgSet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(injector, 0, basal) + val msgSet = DanaRSPacketBasalSetProfileBasalRate(injector, 0, basal) sendMessage(msgSet) - val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(injector, 0) + val msgActivate = DanaRSPacketBasalSetProfileNumber(injector, 0) sendMessage(msgActivate) if (danaPump.profile24) { - val msgProfile = DanaRS_Packet_Bolus_Set_24_CIR_CF_Array(injector, profile) + val msgProfile = DanaRSPacketBolusSet24CIRCFArray(injector, profile) sendMessage(msgProfile) } readPumpStatus() @@ -439,27 +439,27 @@ class DanaRSService : DaggerService() { fun loadHistory(type: Byte): PumpEnactResult { val result = PumpEnactResult(injector) if (!isConnected) return result - var msg: DanaRS_Packet_History_? = null + var msg: DanaRSPacketHistory? = null when (type) { - RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(injector) - RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(injector) - RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(injector) - RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(injector) - RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(injector) - RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(injector) - RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(injector) - RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(injector) - RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(injector) + RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRSPacketHistoryAlarm(injector) + RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRSPacketHistoryPrime(injector) + RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRSPacketHistoryBasal(injector) + RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRSPacketHistoryBolus(injector) + RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRSPacketHistoryCarbohydrate(injector) + RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRSPacketHistoryDaily(injector) + RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRSPacketHistoryBloodGlucose(injector) + RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRSPacketHistoryRefill(injector) + RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRSPacketHistorySuspend(injector) } if (msg != null) { - sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 1)) + sendMessage(DanaRSPacketGeneralSetHistoryUploadMode(injector, 1)) SystemClock.sleep(200) sendMessage(msg) while (!msg.done && isConnected) { SystemClock.sleep(100) } SystemClock.sleep(200) - sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 0)) + sendMessage(DanaRSPacketGeneralSetHistoryUploadMode(injector, 0)) } result.success = msg?.success() ?: false return result diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/DanaRSTestBase.kt b/danars/src/test/java/info/nightscout/androidaps/danars/DanaRSTestBase.kt index 05b06d4fca..b7a6c6a25d 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/DanaRSTestBase.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/DanaRSTestBase.kt @@ -4,7 +4,7 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.danars.comm.DanaRS_Packet +import info.nightscout.androidaps.danars.comm.DanaRSPacket import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Before import org.mockito.ArgumentMatchers @@ -42,13 +42,13 @@ open class DanaRSTestBase : TestBaseWithProfile() { @Suppress("unused") fun putIntToArray(array: ByteArray, position: Int, value: Int): ByteArray { - array[DanaRS_Packet.DATA_START + position] = (value and 0xFF).toByte() - array[DanaRS_Packet.DATA_START + position + 1] = ((value and 0xFF00) shr 8).toByte() + array[DanaRSPacket.DATA_START + position] = (value and 0xFF).toByte() + array[DanaRSPacket.DATA_START + position + 1] = ((value and 0xFF00) shr 8).toByte() return array } fun putByteToArray(array: ByteArray, position: Int, value: Byte): ByteArray { - array[DanaRS_Packet.DATA_START + position] = value + array[DanaRSPacket.DATA_START + position] = value return array } diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasalTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasalTest.kt index 4932678f8b..47f894bc6d 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasalTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketBasalSetTemporaryBasalTest.kt @@ -13,16 +13,16 @@ class DanaRSPacketBasalSetTemporaryBasalTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Temporary_Basal) { + if (it is DanaRSPacketBasalSetTemporaryBasal) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val testPacket = DanaRS_Packet_Basal_Set_Temporary_Basal(packetInjector, 50, 20) + val testPacket = DanaRSPacketBasalSetTemporaryBasal(packetInjector, 50, 20) // params - val params = testPacket.requestParams + val params = testPacket.getRequestParams() // is ratio 50 Assert.assertEquals(50.toByte(), params[0]) // is duration 20 diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarmTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarmTest.kt index 5993ed2535..953e851d3d 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarmTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryAlarmTest.kt @@ -19,11 +19,11 @@ class DanaRSPacketHistoryAlarmTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Alarm) { + if (it is DanaRSPacketHistoryAlarm) { it.rxBus = rxBus it.danaHistoryRecordDao = danaHistoryRecordDao } @@ -33,7 +33,7 @@ class DanaRSPacketHistoryAlarmTest : DanaRSTestBase() { @Test @kotlin.ExperimentalStdlibApi fun runTest() { - val packet = DanaRS_Packet_History_Alarm(packetInjector, 0) + val packet = DanaRSPacketHistoryAlarm(packetInjector, 0) val array = createArray(12, 0.toByte()) // 10 + 2 putByteToArray(array, 0, 0x0A) // record code alarm diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryCompleteTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryCompleteTest.kt index 7bbeef73b6..5d30bd101b 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryCompleteTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketNotifyDeliveryCompleteTest.kt @@ -25,7 +25,7 @@ class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Notify_Delivery_Complete) { + if (it is DanaRSPacketNotifyDeliveryComplete) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -38,9 +38,9 @@ class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() { `when`(resourceHelper.gs(anyInt(), anyDouble())).thenReturn("SomeString") danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) - val packet = DanaRS_Packet_Notify_Delivery_Complete(packetInjector) + val packet = DanaRSPacketNotifyDeliveryComplete(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(17, 0.toByte())) Assert.assertEquals(true, danaPump.bolusDone) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOptionTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOptionTest.kt index dfea5dee2f..101c8e8750 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOptionTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRSPacketOptionSetUserOptionTest.kt @@ -13,7 +13,7 @@ class DanaRSPacketOptionSetUserOptionTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Option_Set_User_Option) { + if (it is DanaRSPacketOptionSetUserOption) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,9 +21,9 @@ class DanaRSPacketOptionSetUserOptionTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Option_Set_User_Option(packetInjector) + val packet = DanaRSPacketOptionSetUserOption(packetInjector) // test params - val params = packet.requestParams + val params = packet.getRequestParams() Assert.assertEquals((danaPump.lcdOnTimeSec and 0xff).toByte(), params[3]) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt index 46e6a328e3..d8388ad435 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt @@ -26,17 +26,17 @@ class DanaRsMessageHashTableTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + if (it is DanaRSPacketBolusSetStepBolusStart) { it.constraintChecker = constraintChecker } - if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + if (it is DanaRSPacketBolusSetStepBolusStart) { it.danaPump = danaPump } - if (it is DanaRS_Packet_APS_History_Events) { + if (it is DanaRSPacketAPSHistoryEvents) { it.danaPump = danaPump } } @@ -47,8 +47,8 @@ class DanaRsMessageHashTableTest : DanaRSTestBase() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector) - val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, 0, 0, 0) - val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) + val forTesting: DanaRSPacket = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, 0, 0, 0) + val testPacket: DanaRSPacket = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.opCode.toLong()) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsBasalSetTemporaryBasalTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsBasalSetTemporaryBasalTest.kt index d7c9afa3fd..8386456660 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsBasalSetTemporaryBasalTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsBasalSetTemporaryBasalTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketApsBasalSetTemporaryBasalTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_APS_Basal_Set_Temporary_Basal) { + if (it is DanaRSPacketAPSBasalSetTemporaryBasal) { it.aapsLogger = aapsLogger } } @@ -23,32 +23,32 @@ class DanaRsPacketApsBasalSetTemporaryBasalTest : DanaRSTestBase() { @Test fun runTest() { // under 100% should last 30 min - var packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 0) + var packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 0) Assert.assertEquals(0, packet.temporaryBasalRatio) - Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) + Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration) //constructor with param - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 10) + packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 10) Assert.assertEquals(10, packet.temporaryBasalRatio) - Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) + Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration) // over 100% should last 15 min - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 150) + packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 150) Assert.assertEquals(150, packet.temporaryBasalRatio) - Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN, packet.temporaryBasalDuration) + Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN, packet.temporaryBasalDuration) // test low hard limit - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, -1) + packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, -1) Assert.assertEquals(0, packet.temporaryBasalRatio) - Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) + Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM30MIN, packet.temporaryBasalDuration) // test high hard limit - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 550) + packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 550) Assert.assertEquals(500, packet.temporaryBasalRatio) - Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN, packet.temporaryBasalDuration) + Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN, packet.temporaryBasalDuration) // test message generation - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 260) - val generatedCode = packet.requestParams + packet = DanaRSPacketAPSBasalSetTemporaryBasal(packetInjector, 260) + val generatedCode = packet.getRequestParams() Assert.assertEquals(3, generatedCode.size.toLong()) Assert.assertEquals(4.toByte(), generatedCode[0]) Assert.assertEquals(1.toByte(), generatedCode[1]) - Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN.toUByte(), generatedCode[2].toUByte()) + Assert.assertEquals(DanaRSPacketAPSBasalSetTemporaryBasal.PARAM15MIN.toUByte(), generatedCode[2].toUByte()) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt index 093adb3fe3..2a473adec7 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt @@ -30,11 +30,11 @@ class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_APS_History_Events) { + if (it is DanaRSPacketAPSHistoryEvents) { it.rxBus = rxBus it.resourceHelper = resourceHelper it.pumpSync = pumpSync @@ -49,9 +49,9 @@ class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() { @Test fun runTest() { val now = dateUtil.now() - val testPacket = DanaRS_Packet_APS_History_Events(packetInjector, now) + val testPacket = DanaRSPacketAPSHistoryEvents(packetInjector, now) // test getRequestedParams - val returnedValues = testPacket.requestParams + val returnedValues = testPacket.getRequestParams() val expectedValues = getCalender(now) //year Assert.assertEquals(expectedValues[0], returnedValues[0]) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt index 07809e9dc5..9c686a0cc6 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt @@ -13,11 +13,11 @@ class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_APS_Set_Event_History) { + if (it is DanaRSPacketAPSSetEventHistory) { it.danaPump = danaPump } } @@ -25,20 +25,20 @@ class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() { @Test fun runTest() { // test for negative carbs val now = dateUtil.now() - var historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, -1, 0) - var testParams = historyTest.requestParams + var historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, -1, 0) + var testParams = historyTest.getRequestParams() Assert.assertEquals(0.toByte(), testParams[8]) // 5g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0) - testParams = historyTest.requestParams + historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0) + testParams = historyTest.getRequestParams() Assert.assertEquals(5.toByte(), testParams[8]) // 150g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 150, 0) - testParams = historyTest.requestParams + historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 150, 0) + testParams = historyTest.getRequestParams() Assert.assertEquals(150.toByte(), testParams[8]) // test message generation - historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0) - testParams = historyTest.requestParams + historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0) + testParams = historyTest.getRequestParams() Assert.assertEquals(5.toByte(), testParams[8]) Assert.assertEquals(11, testParams.size) Assert.assertEquals(info.nightscout.androidaps.dana.DanaPump.CARBS.toByte(), testParams[0]) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetBasalRateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetBasalRateTest.kt index 938e716ba7..8e8df0b82c 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetBasalRateTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetBasalRateTest.kt @@ -16,7 +16,7 @@ class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Get_Basal_Rate) { + if (it is DanaRSPacketBasalGetBasalRate) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -26,7 +26,7 @@ class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Basal_Rate(packetInjector) + val packet = DanaRSPacketBasalGetBasalRate(packetInjector) // test message decoding // rate is 0.01 val array = ByteArray(100) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileBasalRateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileBasalRateTest.kt deleted file mode 100644 index c1cfd49dcd..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileBasalRateTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBasalGetProfileBasalRateTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Basal_Get_Profile_Basal_Rate) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val testPacket = DanaRS_Packet_Basal_Get_Profile_Basal_Rate(packetInjector, 1) - // test if pumpProfile array is set right - val basal01 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 1.toByte()), 2, 2)) / 100.0 - val basal05 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 5.toByte()), 2, 2)) / 100.0 - val basal12 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 12.toByte()), 2, 2)) / 100.0 - // basal rate > 1U/hr - val basal120 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 120.toByte()), 2, 2)) / 100.0 - val params = testPacket.requestParams - assertEquals(1.toByte(), params[0]) - testPacket.handleMessage(createArray(50, 0.toByte())) - assertEquals(0.0, danaPump.pumpProfiles!![1][1], 0.0) - testPacket.handleMessage(createArray(50, 1.toByte())) - assertEquals(basal01, danaPump.pumpProfiles!![1][2], 0.0) - testPacket.handleMessage(createArray(50, 5.toByte())) - assertEquals(basal05, danaPump.pumpProfiles!![1][1], 0.0) - testPacket.handleMessage(createArray(50, 12.toByte())) - assertEquals(basal12, danaPump.pumpProfiles!![1][1], 0.0) - testPacket.handleMessage(createArray(50, 120.toByte())) - assertEquals(basal120, danaPump.pumpProfiles!![1][1], 0.0) - assertEquals("BASAL__GET_PROFILE_BASAL_RATE", testPacket.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileNumberTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileNumberTest.kt index 9847d2f75c..0b2d34b2bc 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileNumberTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetProfileNumberTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketBasalGetProfileNumberTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Get_Profile_Number) { + if (it is DanaRSPacketBasalGetProfileNumber) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,7 +21,7 @@ class DanaRsPacketBasalGetProfileNumberTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Profile_Number(packetInjector) + val packet = DanaRSPacketBasalGetProfileNumber(packetInjector) val array = ByteArray(100) putByteToArray(array, 0, 1.toByte()) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetTemporaryBasalStateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetTemporaryBasalStateTest.kt deleted file mode 100644 index e29ed61b41..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalGetTemporaryBasalStateTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBasalGetTemporaryBasalStateTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet) { - it.aapsLogger = aapsLogger - it.dateUtil = dateUtil - } - if (it is DanaRS_Packet_Basal_Get_Temporary_Basal_State) { - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(packetInjector) - // test message decoding - val array = ByteArray(100) - putByteToArray(array, 0, 1.toByte()) - putByteToArray(array, 1, 1.toByte()) - putByteToArray(array, 2, 230.toByte()) - putByteToArray(array, 3, 150.toByte()) - putIntToArray(array, 4, 1) - packet.handleMessage(array) - Assert.assertTrue(packet.failed) - Assert.assertTrue(packet.isTempBasalInProgress) - Assert.assertEquals(300, packet.tempBasalPercent) - Assert.assertEquals(15 * 60, packet.tempBasalTotalSec) - Assert.assertEquals("BASAL__TEMPORARY_BASAL_STATE", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetBasalRateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetBasalRateTest.kt deleted file mode 100644 index 765b2f462a..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetBasalRateTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBasalSetBasalRateTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Basal_Rate) { - it.aapsLogger = aapsLogger - } - } - } - - @Test fun runTest() { - // test message decoding - val packet = DanaRS_Packet_Basal_Set_Basal_Rate(packetInjector, createArray(24, 5.0)) - val requested = packet.requestParams - var lookingFor = (5 * 100 and 0xff).toByte() - Assert.assertEquals(lookingFor, requested[24]) - lookingFor = (500 ushr 8 and 0xff).toByte() - Assert.assertEquals(lookingFor, requested[25]) - packet.handleMessage(createArray(3, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(3, 1.toByte())) - Assert.assertEquals(true, packet.failed) - Assert.assertEquals("BASAL__SET_BASAL_RATE", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetCancelTemporaryBasalTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetCancelTemporaryBasalTest.kt index 442fed73cf..1f62adaf8a 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetCancelTemporaryBasalTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetCancelTemporaryBasalTest.kt @@ -13,14 +13,14 @@ class DanaRsPacketBasalSetCancelTemporaryBasalTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal) { + if (it is DanaRSPacketBasalSetCancelTemporaryBasal) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(packetInjector) + val packet = DanaRSPacketBasalSetCancelTemporaryBasal(packetInjector) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileBasalRateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileBasalRateTest.kt index 8c45544aa1..a0d67b3212 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileBasalRateTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileBasalRateTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketBasalSetProfileBasalRateTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Profile_Basal_Rate) { + if (it is DanaRSPacketBasalSetProfileBasalRate) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(packetInjector, 1, createArray(24, 1.0)) + val packet = DanaRSPacketBasalSetProfileBasalRate(packetInjector, 1, createArray(24, 1.0)) // test params - val testParams = packet.requestParams + val testParams = packet.getRequestParams() // is profile 1 Assert.assertEquals(1.toByte(), testParams[0]) // is value 100 diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileNumberTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileNumberTest.kt index d7f1135fb7..45137998b8 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileNumberTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetProfileNumberTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketBasalSetProfileNumberTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Profile_Number) { + if (it is DanaRSPacketBasalSetProfileNumber) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Profile_Number(packetInjector, 1) + val packet = DanaRSPacketBasalSetProfileNumber(packetInjector, 1) // test params - val testParams = packet.requestParams + val testParams = packet.getRequestParams() // is profile 1 Assert.assertEquals(1.toByte(), testParams[0]) // test message decoding diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOffTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOffTest.kt index 2ebd63d093..4e956beabf 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOffTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOffTest.kt @@ -13,14 +13,14 @@ class DanaRsPacketBasalSetSuspendOffTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Suspend_Off) { + if (it is DanaRSPacketBasalSetSuspendOff) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Suspend_Off(packetInjector) + val packet = DanaRSPacketBasalSetSuspendOff(packetInjector) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOnTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOnTest.kt index 7b31bbbd85..af501c62d1 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOnTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBasalSetSuspendOnTest.kt @@ -13,14 +13,14 @@ class DanaRsPacketBasalSetSuspendOnTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Set_Suspend_On) { + if (it is DanaRSPacketBasalSetSuspendOn) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Suspend_On(packetInjector) + val packet = DanaRSPacketBasalSetSuspendOn(packetInjector) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetBolusOptionTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetBolusOptionTest.kt index a28bfaa32e..369ab8fb3f 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetBolusOptionTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetBolusOptionTest.kt @@ -5,11 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.danars.DanaRSTestBase import org.junit.Assert -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.mockito.ArgumentMatchers.anyInt -import org.mockito.Mockito.`when` import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @@ -19,7 +16,7 @@ class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Bolus_Option) { + if (it is DanaRSPacketBolusGetBolusOption) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -29,7 +26,7 @@ class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Bolus_Option(packetInjector) + val packet = DanaRSPacketBolusGetBolusOption(packetInjector) // test message decoding //if dataArray is 1 pump.isExtendedBolusEnabled should be true packet.handleMessage(createArray(21, 1.toByte())) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCalculationInformationTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCalculationInformationTest.kt index a8b887ba45..ce75f1f60d 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCalculationInformationTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCalculationInformationTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketBolusGetCalculationInformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Calculation_Information) { + if (it is DanaRSPacketBolusGetCalculationInformation) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,8 +21,8 @@ class DanaRsPacketBolusGetCalculationInformationTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Calculation_Information(packetInjector) - Assert.assertEquals(null, packet.requestParams) + val packet = DanaRSPacketBolusGetCalculationInformation(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(24, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCarbohydrateCalculationInformationTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCarbohydrateCalculationInformationTest.kt deleted file mode 100644 index 9a5627c42c..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCarbohydrateCalculationInformationTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusGetCarbohydrateCalculationInformationTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(packetInjector) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(24, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(24, 1.toByte())) - Assert.assertEquals(true, packet.failed) - Assert.assertEquals("BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCirCfArrayTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCirCfArrayTest.kt index b56e1a5426..49ef077121 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCirCfArrayTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetCirCfArrayTest.kt @@ -14,7 +14,7 @@ class DanaRsPacketBolusGetCirCfArrayTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_CIR_CF_Array) { + if (it is DanaRSPacketBolusGetCIRCFArray) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -22,9 +22,9 @@ class DanaRsPacketBolusGetCirCfArrayTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_CIR_CF_Array(packetInjector) + val packet = DanaRSPacketBolusGetCIRCFArray(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) // are pump units MG/DL ??? diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetDualBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetDualBolusTest.kt deleted file mode 100644 index 9de5e53cb8..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetDualBolusTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusGetDualBolusTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Dual_Bolus) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Dual_Bolus(packetInjector) - // test params - Assert.assertEquals(null, packet.requestParams) - - val array = ByteArray(20) - putByteToArray(array, 0, 1) - putIntToArray(array, 1, (1.0 * 100).toInt()) - putIntToArray(array, 3, (0.55 * 100).toInt()) - putIntToArray(array, 5, (40.0 * 100).toInt()) - packet.handleMessage(array) - Assert.assertTrue(packet.failed) - Assert.assertEquals(1.0, danaPump.bolusStep, 0.0) - Assert.assertEquals(40.0, danaPump.maxBolus, 0.0) - - Assert.assertEquals("BOLUS__GET_DUAL_BOLUS", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedBolusStateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedBolusStateTest.kt deleted file mode 100644 index 759b35e527..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedBolusStateTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusGetExtendedBolusStateTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Extended_Bolus_State) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus_State(packetInjector) - // test params - Assert.assertEquals(null, packet.requestParams) - // test message decoding - var testValue = 0.0 - packet.handleMessage(createArray(11, testValue.toInt().toByte())) - Assert.assertEquals(testValue != 0.0, packet.failed) - testValue = 1.0 - packet.handleMessage(createArray(11, testValue.toInt().toByte())) - // is extended bolus in progress - Assert.assertEquals(testValue == 1.0, packet.isExtendedInProgress) - Assert.assertEquals(testValue != 0.0, packet.failed) - Assert.assertEquals("BOLUS__GET_EXTENDED_BOLUS_STATE", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedBolusTest.kt deleted file mode 100644 index 4da5e4ea6c..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedBolusTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusGetExtendedBolusTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Extended_Bolus) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus(packetInjector) - // test params - Assert.assertEquals(null, packet.requestParams) - // test message decoding - var testValue = 0.0 - packet.handleMessage(createArray(10, testValue.toInt().toByte())) - Assert.assertEquals(testValue != 0.0, packet.failed) - testValue = 1.0 - packet.handleMessage(createArray(10, testValue.toInt().toByte())) - // is pump.bolusStep set to 1 - Assert.assertEquals(testValue / 100.0, danaPump.bolusStep, 0.0) - Assert.assertEquals(testValue != 0.0, packet.failed) - Assert.assertEquals("BOLUS__GET_EXTENDED_BOLUS", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedMenuOptionStateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedMenuOptionStateTest.kt deleted file mode 100644 index 50921c5ea5..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetExtendedMenuOptionStateTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusGetExtendedMenuOptionStateTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(packetInjector) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - // isExtendedInProgress should be false - Assert.assertEquals(false, packet.isExtendedInProgress) - // assertEquals(false, packet.failed); - packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(true, packet.isExtendedInProgress) - Assert.assertEquals("BOLUS__GET_EXTENDED_MENU_OPTION_STATE", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetInitialBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetInitialBolusTest.kt deleted file mode 100644 index 883205431c..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetInitialBolusTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusGetInitialBolusTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Initial_Bolus) { - it.aapsLogger = aapsLogger - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Initial_Bolus(packetInjector) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - // should fail only if all the initial boluses are 0 - Assert.assertEquals(false, !packet.failed) - packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(true, !packet.failed) - Assert.assertEquals("BOLUS__GET_BOLUS_RATE", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetStepBolusInformationTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetStepBolusInformationTest.kt index b1e4721db8..3af2adbc60 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetStepBolusInformationTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusGetStepBolusInformationTest.kt @@ -14,18 +14,18 @@ class DanaRsPacketBolusGetStepBolusInformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_Bolus_Get_Step_Bolus_Information) { + if (it is DanaRSPacketBolusGetStepBolusInformation) { it.danaPump = danaPump } } } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(packetInjector) + val packet = DanaRSPacketBolusGetStepBolusInformation(packetInjector) val array = createArray(13, 0.toByte()) // 11 + 2 putByteToArray(array, 0, 2) // error 2 diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetBolusOptionTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetBolusOptionTest.kt index 450e0d17f8..1086d4eba2 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetBolusOptionTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetBolusOptionTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketBolusSetBolusOptionTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Bolus_Option) { + if (it is DanaRSPacketBolusSetBolusOption) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val packet = DanaRSPacketBolusSetBolusOption(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) // test params - val testParams = packet.requestParams + val testParams = packet.getRequestParams() Assert.assertEquals(0.toByte(), testParams[0]) Assert.assertEquals(0.toByte(), testParams[18]) // test message decoding diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetCirCfArrayTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetCirCfArrayTest.kt deleted file mode 100644 index 2987a11fb0..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetCirCfArrayTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusSetCirCfArrayTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_CIR_CF_Array) { - it.aapsLogger = aapsLogger - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - // test params - val testParams = packet.requestParams - Assert.assertEquals(0.toByte(), testParams[0]) - Assert.assertEquals(0.toByte(), testParams[18]) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - // DanaRPump testPump = DanaRPump.getInstance(); - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(34, 1.toByte())) - // int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF); -// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0); - Assert.assertEquals(true, packet.failed) - Assert.assertEquals("BOLUS__SET_CIR_CF_ARRAY", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetDualBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetDualBolusTest.kt deleted file mode 100644 index bd15873509..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetDualBolusTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusSetDualBolusTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Dual_Bolus) { - it.aapsLogger = aapsLogger - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(packetInjector, 0.0, 0.0, 1) - // test params - val testParams = packet.requestParams - Assert.assertEquals(0.toByte(), testParams[0]) - Assert.assertEquals(1.toByte(), testParams[4]) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - // DanaRPump testPump = DanaRPump.getInstance(); - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(34, 1.toByte())) - // int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF); -// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0); - Assert.assertEquals(true, packet.failed) - Assert.assertEquals("BOLUS__SET_DUAL_BOLUS", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusCancelTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusCancelTest.kt index 02893dc262..67832e9ef1 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusCancelTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusCancelTest.kt @@ -13,15 +13,15 @@ class DanaRsPacketBolusSetExtendedBolusCancelTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel) { + if (it is DanaRSPacketBolusSetExtendedBolusCancel) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(packetInjector) - Assert.assertEquals(null, packet.requestParams) + val packet = DanaRSPacketBolusSetExtendedBolusCancel(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusTest.kt index 055bbf3582..2bb83c2395 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetExtendedBolusTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketBolusSetExtendedBolusTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Extended_Bolus) { + if (it is DanaRSPacketBolusSetExtendedBolus) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus(packetInjector, 1.0, 1) + val packet = DanaRSPacketBolusSetExtendedBolus(packetInjector, 1.0, 1) // test params - val testparams = packet.requestParams + val testparams = packet.getRequestParams() Assert.assertEquals(100.toByte(), testparams[0]) Assert.assertEquals(1.toByte(), testparams[2]) // test message decoding diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetInitialBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetInitialBolusTest.kt deleted file mode 100644 index f3510221ff..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetInitialBolusTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketBolusSetInitialBolusTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Initial_Bolus) { - it.aapsLogger = aapsLogger - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(packetInjector, 0, 0, 0, 100) - // test params - val testParams = packet.requestParams - Assert.assertEquals(0.toByte(), testParams[0]) - Assert.assertEquals(100.toByte(), testParams[6]) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(34, 1.toByte())) - Assert.assertEquals(true, packet.failed) - Assert.assertEquals("BOLUS__SET_BOLUS_RATE", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStartTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStartTest.kt index 224dd6fee2..a8d70ec52f 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStartTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStartTest.kt @@ -35,7 +35,7 @@ class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + if (it is DanaRSPacketBolusSetStepBolusStart) { it.aapsLogger = aapsLogger it.danaPump = danaPump it.constraintChecker = constraintChecker @@ -44,9 +44,9 @@ class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(packetInjector) + val packet = DanaRSPacketBolusSetStepBolusStart(packetInjector) // test params - val testParams = packet.requestParams + val testParams = packet.getRequestParams() Assert.assertEquals(0.toByte(), testParams[0]) Assert.assertEquals(0.toByte(), testParams[2]) // test message decoding diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStopTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStopTest.kt index 840f9c6b42..cb5f396ecd 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStopTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketBolusSetStepBolusStopTest.kt @@ -24,7 +24,7 @@ class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Stop) { + if (it is DanaRSPacketBolusSetStepBolusStop) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -37,7 +37,7 @@ class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() { `when`(resourceHelper.gs(Mockito.anyInt())).thenReturn("SomeString") danaPump.bolusingTreatment = EventOverviewBolusProgress.Treatment(0.0, 0, true) - val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(packetInjector) + val testPacket = DanaRSPacketBolusSetStepBolusStop(packetInjector) // test message decoding testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, testPacket.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcKeepConnectionTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcKeepConnectionTest.kt index ecc02cc85b..d4f49b7392 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcKeepConnectionTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcKeepConnectionTest.kt @@ -13,15 +13,15 @@ class DanaRsPacketEtcKeepConnectionTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Etc_Keep_Connection) { + if (it is DanaRSPacketEtcKeepConnection) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Etc_Keep_Connection(packetInjector) - Assert.assertEquals(null, packet.requestParams) + val packet = DanaRSPacketEtcKeepConnection(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcSetHistorySaveTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcSetHistorySaveTest.kt index a239281ad3..509f484180 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcSetHistorySaveTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketEtcSetHistorySaveTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketEtcSetHistorySaveTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Etc_Set_History_Save) { + if (it is DanaRSPacketEtcSetHistorySave) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Etc_Set_History_Save(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2) + val packet = DanaRSPacketEtcSetHistorySave(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2) // test params - val testParams = packet.requestParams + val testParams = packet.getRequestParams() Assert.assertEquals(2.toByte(), testParams[8]) Assert.assertEquals((2 ushr 8).toByte(), testParams[9]) // test message decoding diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralDeliveryStatusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralDeliveryStatusTest.kt deleted file mode 100644 index c1a758daee..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralDeliveryStatusTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketGeneralDeliveryStatusTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_General_Delivery_Status) { - it.aapsLogger = aapsLogger - } - } - } - - @Test fun runTest() { - val packet = DanaRS_Packet_General_Delivery_Status(packetInjector) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(15, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(15, 161.toByte())) - Assert.assertEquals(true, packet.failed) - Assert.assertEquals("REVIEW__DELIVERY_STATUS", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetMoreInformationTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetMoreInformationTest.kt deleted file mode 100644 index 957553475f..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetMoreInformationTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner -import java.util.* - -@RunWith(PowerMockRunner::class) -class DanaRsPacketGeneralGetMoreInformationTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet) { - it.aapsLogger = aapsLogger - it.dateUtil = dateUtil - } - if (it is DanaRS_Packet_General_Get_More_Information) { - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_More_Information(packetInjector) - - packet.handleMessage(createArray(14, 0.toByte())) - Assert.assertTrue(packet.failed) - - packet = DanaRS_Packet_General_Get_More_Information(packetInjector) - val array = createArray(15, 0.toByte()) // 13 + 2 - putIntToArray(array, 0, 600) // iob 6 - putIntToArray(array, 2, 1250) // daily units 12.5 - putByteToArray(array, 4, 1) // is extended in progress - putIntToArray(array, 5, 150) // extended remaining minutes 150 - putByteToArray(array, 9, 15) // hours 15 - putByteToArray(array, 10, 25) // minutes 25 - putIntToArray(array, 11, 170) // last bolus amount 1.70 - - packet.handleMessage(array) - Assert.assertFalse(packet.failed) - Assert.assertEquals(6.0, danaPump.iob, 0.01) - Assert.assertEquals(12.5, danaPump.dailyTotalUnits, 0.01) - val lastBolus = Calendar.getInstance() - lastBolus.timeInMillis = danaPump.lastBolusTime - Assert.assertEquals(15, lastBolus.get(Calendar.HOUR_OF_DAY)) - Assert.assertEquals(25, lastBolus.get(Calendar.MINUTE)) - Assert.assertEquals(1.7, danaPump.lastBolusAmount, 0.01) - - Assert.assertEquals("REVIEW__GET_MORE_INFORMATION", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPasswordTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPasswordTest.kt deleted file mode 100644 index 9fe3e2a8ec..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPasswordTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketGeneralGetPasswordTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_General_Get_Password) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Password(packetInjector) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - // test for the length message - packet.handleMessage(createArray(1, 0.toByte())) - Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Password(packetInjector) - packet.handleMessage(createArray(15, 0.toByte())) - Assert.assertEquals(false, packet.failed) - Assert.assertEquals("REVIEW__GET_PASSWORD", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPumpCheckTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPumpCheckTest.kt index b3c7b5df8f..40a0d0bad4 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPumpCheckTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetPumpCheckTest.kt @@ -16,7 +16,7 @@ class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Get_Pump_Check) { + if (it is DanaRSPacketGeneralGetPumpCheck) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -26,13 +26,13 @@ class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() { } @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Pump_Check(packetInjector) - Assert.assertEquals(null, packet.requestParams) + var packet = DanaRSPacketGeneralGetPumpCheck(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Pump_Check(packetInjector) + packet = DanaRSPacketGeneralGetPumpCheck(packetInjector) packet.handleMessage(createArray(15, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingInformationTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingInformationTest.kt index 07201595db..299fa6c8fb 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingInformationTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingInformationTest.kt @@ -13,25 +13,25 @@ class DanaRsPacketGeneralGetShippingInformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_General_Get_Shipping_Information) { + if (it is DanaRSPacketGeneralGetShippingInformation) { it.danaPump = danaPump } } } @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) - Assert.assertEquals(null, packet.requestParams) + var packet = DanaRSPacketGeneralGetShippingInformation(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) // everything ok :) - packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) + packet = DanaRSPacketGeneralGetShippingInformation(packetInjector) Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingVerisonTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingVerisonTest.kt index 3a63508855..f09dbaa108 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingVerisonTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetShippingVerisonTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketGeneralGetShippingVerisonTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Get_Shipping_Version) { + if (it is DanaRSPacketGeneralGetShippingVersion) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,7 +21,7 @@ class DanaRsPacketGeneralGetShippingVerisonTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_General_Get_Shipping_Version(packetInjector) + val packet = DanaRSPacketGeneralGetShippingVersion(packetInjector) // test message decoding val ver = byteArrayOf((-78).toByte(), (-127).toByte(), (66).toByte(), (80).toByte(), (78).toByte(), (45).toByte(), (51).toByte(), (46).toByte(), (48).toByte(), (46).toByte(), (48).toByte()) packet.handleMessage(ver) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetTodayDeliveryTotalTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetTodayDeliveryTotalTest.kt deleted file mode 100644 index 4497e3dc90..0000000000 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetTodayDeliveryTotalTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -package info.nightscout.androidaps.danars.comm - -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.danars.DanaRSTestBase -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith -import org.powermock.modules.junit4.PowerMockRunner - -@RunWith(PowerMockRunner::class) -class DanaRsPacketGeneralGetTodayDeliveryTotalTest : DanaRSTestBase() { - - private val packetInjector = HasAndroidInjector { - AndroidInjector { - if (it is DanaRS_Packet_General_Get_Today_Delivery_Total) { - it.aapsLogger = aapsLogger - it.danaPump = danaPump - } - } - } - - @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(packetInjector) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - // test for the length message - packet.handleMessage(createArray(1, 0.toByte())) - Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Today_Delivery_Total(packetInjector) - packet.handleMessage(createArray(18, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(15, 1.toByte())) - Assert.assertEquals(((1 and 0x000000FF shl 8) + (1 and 0x000000FF)) / 100.0, danaPump.dailyTotalUnits, 0.0) - Assert.assertEquals("REVIEW__GET_TODAY_DELIVERY_TOTAL", packet.friendlyName) - } -} \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetUserTimeChangeFlagTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetUserTimeChangeFlagTest.kt index 0f901ca6e8..09c68d6a6e 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetUserTimeChangeFlagTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralGetUserTimeChangeFlagTest.kt @@ -13,20 +13,20 @@ class DanaRsPacketGeneralGetUserTimeChangeFlagTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Get_User_Time_Change_Flag) { + if (it is DanaRSPacketGeneralGetUserTimeChangeFlag) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(packetInjector) - Assert.assertEquals(null, packet.requestParams) + var packet = DanaRSPacketGeneralGetUserTimeChangeFlag(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(packetInjector) + packet = DanaRSPacketGeneralGetUserTimeChangeFlag(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.friendlyName) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralInitialScreenInformationTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralInitialScreenInformationTest.kt index a67535ea5e..14d6efad46 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralInitialScreenInformationTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralInitialScreenInformationTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketGeneralInitialScreenInformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Initial_Screen_Information) { + if (it is DanaRSPacketGeneralInitialScreenInformation) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,13 +21,13 @@ class DanaRsPacketGeneralInitialScreenInformationTest : DanaRSTestBase() { } @Test fun runTest() { - var packet = DanaRS_Packet_General_Initial_Screen_Information(packetInjector) - Assert.assertEquals(null, packet.requestParams) + var packet = DanaRSPacketGeneralInitialScreenInformation(packetInjector) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Initial_Screen_Information(packetInjector) + packet = DanaRSPacketGeneralInitialScreenInformation(packetInjector) packet.handleMessage(createArray(17, 1.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals(true, danaPump.pumpSuspended) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetHistoryUploadModeTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetHistoryUploadModeTest.kt index 4a2061bce1..c179f63c0d 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetHistoryUploadModeTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetHistoryUploadModeTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketGeneralSetHistoryUploadModeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Set_History_Upload_Mode) { + if (it is DanaRSPacketGeneralSetHistoryUploadMode) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_General_Set_History_Upload_Mode(packetInjector, 1) + val packet = DanaRSPacketGeneralSetHistoryUploadMode(packetInjector, 1) // test params - Assert.assertEquals(1.toByte(), packet.requestParams[0]) + Assert.assertEquals(1.toByte(), packet.getRequestParams()[0]) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetUserTimeChangeFlagClearTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetUserTimeChangeFlagClearTest.kt index 2e6e170be5..d29722bf71 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetUserTimeChangeFlagClearTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketGeneralSetUserTimeChangeFlagClearTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketGeneralSetUserTimeChangeFlagClearTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear) { + if (it is DanaRSPacketGeneralSetUserTimeChangeFlagClear) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(packetInjector) + val packet = DanaRSPacketGeneralSetUserTimeChangeFlagClear(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryAllHistoryTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryAllHistoryTest.kt index 8135997298..62e2f42646 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryAllHistoryTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryAllHistoryTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryAllHistoryTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_All_History) { + if (it is DanaRSPacketHistoryAllHistory) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_All_History(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryAllHistory(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBasalTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBasalTest.kt index 1d0f7f978d..bfda87308b 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBasalTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBasalTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryBasalTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Basal) { + if (it is DanaRSPacketHistoryBasal) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Basal(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryBasal(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BASAL", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBloodGlucoseTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBloodGlucoseTest.kt index 683298ff8b..88245a085a 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBloodGlucoseTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBloodGlucoseTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryBloodGlucoseTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Blood_Glucose) { + if (it is DanaRSPacketHistoryBloodGlucose) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Blood_Glucose(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryBloodGlucose(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBolusTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBolusTest.kt index 94b8f19777..aa642a645e 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBolusTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryBolusTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryBolusTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Bolus) { + if (it is DanaRSPacketHistoryBolus) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Bolus(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryBolus(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BOLUS", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryCarbohydrateTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryCarbohydrateTest.kt index cfa447fa89..cb77a3078b 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryCarbohydrateTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryCarbohydrateTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryCarbohydrateTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Carbohydrate) { + if (it is DanaRSPacketHistoryCarbohydrate) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Carbohydrate(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryCarbohydrate(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryDailyTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryDailyTest.kt index a98894c6e7..eb1c1331ec 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryDailyTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryDailyTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryDailyTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Daily) { + if (it is DanaRSPacketHistoryDaily) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Daily(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryDaily(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__DAILY", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryPrimeTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryPrimeTest.kt index a651910802..bd050f9048 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryPrimeTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryPrimeTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryPrimeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Prime) { + if (it is DanaRSPacketHistoryPrime) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Prime(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryPrime(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__PRIME", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryRefillTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryRefillTest.kt index 65d484aa77..8a961122d0 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryRefillTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryRefillTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryRefillTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Refill) { + if (it is DanaRSPacketHistoryRefill) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Refill(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryRefill(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__REFILL", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistorySuspendTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistorySuspendTest.kt index 04fba763ee..af5b2adcbd 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistorySuspendTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistorySuspendTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistorySuspendTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Suspend) { + if (it is DanaRSPacketHistorySuspend) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Suspend(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistorySuspend(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__SUSPEND", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryTemporaryTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryTemporaryTest.kt index c8eed86284..5a906984a1 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryTemporaryTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketHistoryTemporaryTest.kt @@ -13,18 +13,18 @@ class DanaRsPacketHistoryTemporaryTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_History_Temporary) { + if (it is DanaRSPacketHistoryTemporary) { it.rxBus = rxBus } } } @Test fun runTest() { - val packet = DanaRS_Packet_History_Temporary(packetInjector, System.currentTimeMillis()) + val packet = DanaRSPacketHistoryTemporary(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__TEMPORARY", packet.friendlyName) } } \ No newline at end of file diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyAlarmTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyAlarmTest.kt index 9df91c6c38..3e2b68a21c 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyAlarmTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyAlarmTest.kt @@ -17,7 +17,7 @@ class DanaRsPacketNotifyAlarmTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Notify_Alarm) { + if (it is DanaRSPacketNotifyAlarm) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -28,9 +28,9 @@ class DanaRsPacketNotifyAlarmTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Alarm(packetInjector) + val packet = DanaRSPacketNotifyAlarm(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(17, 0x01.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyDeliveryRateDisplayTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyDeliveryRateDisplayTest.kt index ab9b803ad9..ef51dafae2 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyDeliveryRateDisplayTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyDeliveryRateDisplayTest.kt @@ -39,7 +39,7 @@ class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Notify_Delivery_Rate_Display) { + if (it is DanaRSPacketNotifyDeliveryRateDisplay) { it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper @@ -51,11 +51,11 @@ class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(ArgumentMatchers.anyInt(), anyObject())).thenReturn("SomeString") // val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(1.0, Treatment(treatmentInjector)) - val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(packetInjector) + val packet = DanaRSPacketNotifyDeliveryRateDisplay(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding -// 0% delivered + // 0% delivered packet.handleMessage(createArray(17, 0.toByte())) Assert.assertEquals(true, packet.failed) // 100 % delivered diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyMissedBolusAlarmTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyMissedBolusAlarmTest.kt index 0a25ea13e9..4062e844f8 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyMissedBolusAlarmTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketNotifyMissedBolusAlarmTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketNotifyMissedBolusAlarmTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Notify_Missed_Bolus_Alarm) { + if (it is DanaRSPacketNotifyMissedBolusAlarm) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Missed_Bolus_Alarm(packetInjector) + val packet = DanaRSPacketNotifyMissedBolusAlarm(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(6, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetPumpTimeTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetPumpTimeTest.kt index 5efaeb9812..d2f8a624f3 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetPumpTimeTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetPumpTimeTest.kt @@ -14,18 +14,18 @@ class DanaRsPacketOptionGetPumpTimeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } - if (it is DanaRS_Packet_Option_Get_Pump_Time) { + if (it is DanaRSPacketOptionGetPumpTime) { it.danaPump = danaPump } } } @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_Pump_Time(packetInjector) + val packet = DanaRSPacketOptionGetPumpTime(packetInjector) val array = createArray(8, 0.toByte()) // 6 + 2 putByteToArray(array, 0, 19) // year 2019 putByteToArray(array, 1, 2) // month february diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetUserOptionTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetUserOptionTest.kt index fb55d3c58b..7592981130 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetUserOptionTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionGetUserOptionTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketOptionGetUserOptionTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Option_Get_User_Option) { + if (it is DanaRSPacketOptionGetUserOption) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,9 +21,9 @@ class DanaRsPacketOptionGetUserOptionTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_User_Option(packetInjector) + val packet = DanaRSPacketOptionGetUserOption(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(20, 0.toByte())) Assert.assertEquals(true, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionSetPumpTimeTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionSetPumpTimeTest.kt index 2b39688f61..1bcf69767b 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionSetPumpTimeTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketOptionSetPumpTimeTest.kt @@ -14,7 +14,7 @@ class DanaRsPacketOptionSetPumpTimeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet) { + if (it is DanaRSPacket) { it.aapsLogger = aapsLogger it.dateUtil = dateUtil } @@ -23,9 +23,9 @@ class DanaRsPacketOptionSetPumpTimeTest : DanaRSTestBase() { @Test fun runTest() { val date = DateTime() - val packet = DanaRS_Packet_Option_Set_Pump_Time(packetInjector, date.millis) + val packet = DanaRSPacketOptionSetPumpTime(packetInjector, date.millis) // test params - val params = packet.requestParams + val params = packet.getRequestParams() Assert.assertEquals((date.year - 2000 and 0xff).toByte(), params[0]) // 2019 -> 19 Assert.assertEquals((date.monthOfYear and 0xff).toByte(), params[1]) Assert.assertEquals((date.dayOfMonth and 0xff).toByte(), params[2]) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewBolusAvgTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewBolusAvgTest.kt index c4b7219a41..99688376d5 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewBolusAvgTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewBolusAvgTest.kt @@ -13,16 +13,16 @@ class DanaRsPacketReviewBolusAvgTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Review_Bolus_Avg) { + if (it is DanaRSPacketReviewBolusAvg) { it.aapsLogger = aapsLogger } } } @Test fun runTest() { - val packet = DanaRS_Packet_Review_Bolus_Avg(packetInjector) + val packet = DanaRSPacketReviewBolusAvg(packetInjector) // test params - Assert.assertEquals(null, packet.requestParams) + Assert.assertEquals(0, packet.getRequestParams().size) // test message decoding packet.handleMessage(createArray(12, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewGetPumpDecRatioTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewGetPumpDecRatioTest.kt index 43c56c9496..44deb23fbd 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewGetPumpDecRatioTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketReviewGetPumpDecRatioTest.kt @@ -13,7 +13,7 @@ class DanaRsPacketReviewGetPumpDecRatioTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Review_Get_Pump_Dec_Ratio) { + if (it is DanaRSPacketReviewGetPumpDecRatio) { it.aapsLogger = aapsLogger it.danaPump = danaPump } @@ -21,7 +21,7 @@ class DanaRsPacketReviewGetPumpDecRatioTest : DanaRSTestBase() { } @Test fun runTest() { - val packet = DanaRS_Packet_Review_Get_Pump_Dec_Ratio(packetInjector) + val packet = DanaRSPacketReviewGetPumpDecRatio(packetInjector) val array = ByteArray(100) putByteToArray(array, 0, 4.toByte())