diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt index 294af1d054..ed0cff7dcf 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt @@ -95,6 +95,7 @@ import kotlin.math.abs override fun onStart() { super.onStart() aapsLogger.debug(LTag.PUMP, "MedtrumPlugin onStart()") + medtrumPump.loadVarsFromSP() val intent = Intent(context, MedtrumService::class.java) context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE) disposable += rxBus diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt index 8756cc730c..8480282e6f 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt @@ -279,7 +279,16 @@ class MedtrumPump @Inject constructor( var desiredHourlyMaxInsulin: Int = 40 var desiredDailyMaxInsulin: Int = 180 - init { + fun pumpType(): PumpType = pumpType(deviceType) + + fun pumpType(type: Int): PumpType = + when (type) { + MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO + MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U + else -> PumpType.MEDTRUM_UNTESTED + } + + fun loadVarsFromSP() { // Load stuff from SP _patchSessionToken = sp.getLong(R.string.key_session_token, 0L) _lastConnection = sp.getLong(R.string.key_last_connection, 0L) @@ -304,16 +313,9 @@ class MedtrumPump @Inject constructor( } catch (e: Exception) { aapsLogger.warn(LTag.PUMP, "Error decoding basal profile from SP: $encodedString") } - } - fun pumpType(): PumpType = pumpType(deviceType) - - fun pumpType(type: Int): PumpType = - when (type) { - MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO - MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U - else -> PumpType.MEDTRUM_UNTESTED - } + loadUserSettingsFromSP() + } fun loadUserSettingsFromSP() { desiredPatchExpiration = sp.getBoolean(R.string.key_patch_expiration, false) diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt index 86f995bbf4..7581b8fa9c 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt @@ -145,8 +145,6 @@ class MedtrumService : DaggerService(), BLECommCallback { handleConnectionStateChange(connectionState) } } - - medtrumPump.loadUserSettingsFromSP() } override fun onDestroy() {