Compare commits

...

17 commits

Author SHA1 Message Date
Casper V. Kristensen 1d90a15c4e disable SignatureVerifierPlugin
I really don't want to be stuck on vacation with a broken app and no way
to build a new one.
2024-05-29 23:06:30 +02:00
Casper V. Kristensen 6ff98f3082 always allow SMB 2024-05-29 23:05:12 +02:00
Casper V. Kristensen 5388c5488b chill objectives 2024-05-29 23:05:12 +02:00
Casper V. Kristensen 6fd3a85d90 GitHub Actions workflow 2024-05-29 23:05:12 +02:00
Milos Kozak 3df83535f9
Update revoked_certs.txt 2024-05-23 10:57:55 +02:00
Milos Kozak 5d3e33ce8a
Merge pull request #3242 from nightscout/dev32
3.2.0.4
2024-02-27 10:06:09 +01:00
Milos Kozak 2798ae6473 NSC: process objective 0 properly 2024-02-27 09:29:55 +01:00
osodebailar 1586336daf useroption icon now visible again in useroption button 2024-02-27 09:29:38 +01:00
Milos Kozak e2692f7d67
3.2.0.4 2024-02-26 14:25:03 +01:00
Milos Kozak 927676d5ee
Merge pull request #3177 from jbr7rr/medtrum-fixes
Medtrum improvements
2024-01-23 11:27:32 +01:00
jbr7rr 5768d3b75a Revert check for plain sn range 2024-01-22 20:23:31 +01:00
jbr7rr 43a3d8d8de Fix stuck on error when activation failed due to disconnect
> Remove PatchStep.ERROR state
2024-01-21 19:38:15 +01:00
jbr7rr 23e7af2d82 Show ref no instead of raw pumpType value 2024-01-21 13:20:10 +01:00
jbr7rr 907387df33 Remove patch fault 2 string to avoid confusion 2024-01-21 08:57:59 +01:00
Milos Kozak 44966f3bd8 xdrip: G7 support 2024-01-08 15:49:25 +01:00
Milos Kozak 11ebdc7bb2 gradle 8.2.1 2024-01-08 15:38:53 +01:00
Milos Kozak 759b27f1f5
3.2.0.3-dev 2023-12-16 20:39:03 +01:00
36 changed files with 142 additions and 87 deletions

59
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,59 @@
# https://github.com/settings/billing/summary
name: Build and Release APK
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
on:
push:
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Check out repository under $GITHUB_WORKSPACE
# https://github.com/actions/checkout
- name: Checkout repository
uses: actions/checkout@v4
# https://github.com/actions/setup-java
- name: Set up Java
uses: actions/setup-java@v4
with:
# https://github.com/actions/setup-java?tab=readme-ov-file#supported-version-syntax
# https://adoptium.net/support/
# https://docs.gradle.org/current/userguide/compatibility.html
distribution: "temurin"
java-version: "17"
cache: "gradle"
# https://developer.android.com/build/building-cmdline
- name: Build APK
run: ./gradlew assembleRelease --no-daemon
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/customizing-github-hosted-runners
- name: Install android tools
run: |
sudo apt-get update
sudo apt-get install zipalign apksigner
# https://developer.android.com/build/building-cmdline#sign_cmdline
# https://github.com/caspervk/AndroidAPS-builds/settings/secrets/actions
- name: Sign APK
run: |
cd app/build/outputs/apk/full/release/
echo "$APK_RELEASE_KEY_BASE64" | base64 -d > release-key.jks
zipalign -v -p 4 app-full-release-unsigned.apk app-full-release-unsigned-aligned.apk
apksigner sign --ks release-key.jks --ks-pass pass:"$APK_RELEASE_KEY_PASSWORD" --out "aaps-$REF_NAME.apk" app-full-release-unsigned-aligned.apk
env:
APK_RELEASE_KEY_BASE64: ${{ secrets.APK_RELEASE_KEY_BASE64 }}
APK_RELEASE_KEY_PASSWORD: ${{ secrets.APK_RELEASE_KEY_PASSWORD }}
REF_NAME: ${{ github.ref_name }}
# https://github.com/softprops/action-gh-release
- name: Release APK
uses: softprops/action-gh-release@v2
with:
files: app/build/outputs/apk/full/release/aaps-${{ github.ref_name }}.apk

View file

@ -8,3 +8,7 @@ E0:71:A3:6E:96:60:5A:FC:B3:77:DB:2F:C4:E0:92:F3:39:A6:27:24:91:F5:7E:BB:55:9B:60
32:99:61:C4:A0:92:E8:D2:C7:65:04:74:04:17:7E:2D:2A:16:2A:5A:63:48:69:6A:0A:C4:53:3C:7C:78:22:95
# mςRr¡ЇζΛLφK&ĐΨ5CnЎϴPDñЍŒkϼ{ΨδwВb
6D:C2:52:72:A1:07:B6:9B:4C:C6:4B:26:10:A8:35:43:6E:0E:F4:50:44:F1:0D:52:6B:FC:7B:A8:B4:77:12:62
# èΩQ\kné8EΔËZKòΓϳ^ΙÈμXÄ~Éìϰηmô΢ЉЋ
E8:A9:51:5C:6B:6E:E9:38:45:94:CB:5A:4B:F2:93:F3:5E:99:C8:BC:58:C4:7E:C9:EC:F0:B7:6D:F4:A2:09:0B
# gsЂ?ν°ćЅϯk0ϸÇ$rЁ3ΥЕϹϿΘt4βΛmÄ|I´І
67:73:02:3F:BD:B0:07:05:EF:6B:30:F8:C7:24:72:01:33:A5:15:F9:FF:98:74:34:B2:9B:6D:C4:7C:49:B4:06

View file

@ -8,7 +8,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.2.0")
classpath("com.android.tools.build:gradle:8.2.1")
classpath("com.google.gms:google-services:4.4.0")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.9")

View file

@ -2,7 +2,7 @@ import org.gradle.api.JavaVersion
object Versions {
const val appVersion = "3.2.0.3"
const val appVersion = "3.2.0.4"
const val versionCode = 1500
const val ndkVersion = "21.1.6352462"

View file

@ -5,8 +5,8 @@
android:viewportHeight="24">
<path
android:pathData="M13.351,12.926c-0.137,-0.003 -0.283,0.012 -0.337,-0.17c-0.046,-0.155 0.002,-0.266 0.122,-0.366c0.628,-0.523 0.741,-1.232 0.711,-2.042c0,-0.148 0.013,-0.348 -0.002,-0.546c-0.071,-0.91 -0.785,-1.606 -1.718,-1.686c-0.845,-0.073 -1.71,0.485 -1.862,1.344c-0.184,1.039 -0.278,2.111 0.636,2.933c0.115,0.104 0.172,0.206 0.12,0.363c-0.059,0.177 -0.201,0.171 -0.34,0.169c-0.347,-0.005 -0.668,0.083 -0.97,0.249c-0.973,0.535 -1.043,1.404 -0.165,2.061c1.299,0.974 3.949,0.841 5.144,-0.257c0.471,-0.433 0.508,-0.927 0.084,-1.408C14.4,13.146 13.918,12.937 13.351,12.926zM13.572,14.889c-1.202,0.486 -2.407,0.499 -3.555,-0.158c-0.579,-0.331 -0.548,-0.663 0.046,-0.976c0.248,-0.131 0.517,-0.214 0.801,-0.195c0.348,0.024 0.636,-0.047 0.765,-0.414c0.14,-0.399 0.306,-0.823 -0.105,-1.149c-0.661,-0.524 -0.705,-1.225 -0.666,-1.98c0.039,-0.729 0.51,-1.259 1.159,-1.248c0.662,0.011 1.13,0.529 1.146,1.269c0.003,0.119 0,0.239 0,0.456c0.097,0.503 -0.086,0.988 -0.564,1.377c-0.395,0.321 -0.385,0.738 -0.235,1.187c0.15,0.448 0.477,0.542 0.89,0.506c0.039,-0.003 0.08,0.004 0.118,0.014c0.389,0.093 0.879,0.167 0.948,0.599C14.392,14.615 13.901,14.756 13.572,14.889z"
android:fillColor="?attr/userOptionColor"/>
android:fillColor="@color/userOption"/>
<path
android:pathData="M19.107,10.662H17.78c-0.15,-0.648 -0.406,-1.253 -0.749,-1.801l0.941,-0.941c0.239,-0.239 0.239,-0.626 0,-0.864l-1.027,-1.027c-0.239,-0.239 -0.626,-0.239 -0.864,0l-0.941,0.941c-0.548,-0.343 -1.154,-0.599 -1.801,-0.749V4.893c0,-0.338 -0.274,-0.611 -0.611,-0.611h-1.453c-0.338,0 -0.611,0.274 -0.611,0.611V6.22c-0.648,0.15 -1.253,0.406 -1.801,0.749L7.92,6.028c-0.239,-0.239 -0.626,-0.239 -0.864,0L6.028,7.056c-0.239,0.239 -0.239,0.626 0,0.864l0.941,0.941C6.626,9.409 6.37,10.015 6.22,10.662H4.893c-0.338,0 -0.611,0.274 -0.611,0.611v1.453c0,0.338 0.274,0.611 0.611,0.611H6.22c0.15,0.648 0.406,1.253 0.749,1.801L6.028,16.08c-0.239,0.239 -0.239,0.626 0,0.864l1.027,1.027c0.239,0.239 0.626,0.239 0.864,0l0.941,-0.941c0.548,0.343 1.154,0.599 1.801,0.749v1.328c0,0.338 0.274,0.611 0.611,0.611h1.453c0.338,0 0.611,-0.274 0.611,-0.611V17.78c0.648,-0.15 1.254,-0.406 1.801,-0.749l0.941,0.941c0.239,0.239 0.626,0.239 0.864,0l1.027,-1.027c0.239,-0.239 0.239,-0.626 0,-0.864l-0.941,-0.941c0.343,-0.548 0.599,-1.154 0.749,-1.801h1.328c0.338,0 0.611,-0.274 0.611,-0.611v-1.453C19.719,10.936 19.445,10.662 19.107,10.662zM12,16.938c-2.723,0 -4.938,-2.215 -4.938,-4.938S9.277,7.063 12,7.063S16.938,9.277 16.938,12S14.723,16.938 12,16.938z"
android:fillColor="?attr/userOptionColor"/>
android:fillColor="@color/userOption"/>
</vector>

View file

@ -97,6 +97,7 @@ data class GlucoseValue(
DEXCOM_G6_NATIVE_XDRIP("G6 Native"),
DEXCOM_G5_NATIVE_XDRIP("G5 Native"),
DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"),
DEXCOM_G7_NATIVE_XDRIP("G7"),
LIBRE_1_OTHER("Other App"),
LIBRE_1_NET("Network libre"),
LIBRE_1_BLUE("BlueReader"),

View file

@ -149,7 +149,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe
override fun isCompleted(): Boolean = answered
fun isEnabledAnswer(): Boolean = disabledTo < dateUtil.now()
fun isEnabledAnswer(): Boolean = true
fun option(option: Option): ExamTask {
options.add(option)

View file

@ -22,11 +22,6 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R
val tidepoolPlugin get() = activePlugin.getSpecificPluginsListByInterface(Tidepool::class.java).firstOrNull() as Tidepool?
init {
tasks.add(object : Task(this, R.string.objectives_bgavailableinns) {
override fun isCompleted(): Boolean {
return sp.getBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, false) || tidepoolPlugin?.hasWritePermission == true
}
})
tasks.add(object : Task(this, R.string.synchaswritepermission) {
override fun isCompleted(): Boolean {
return activePlugin.firstActiveSync?.hasWritePermission == true || tidepoolPlugin?.hasWritePermission == true
@ -41,13 +36,6 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R
return !virtualPumpPlugin.isEnabled()
}
})
tasks.add(
object : Task(this, R.string.objectives_pumpstatusavailableinns) {
override fun isCompleted(): Boolean {
return sp.getBoolean(app.aaps.core.utils.R.string.key_objectives_pump_status_is_available_in_ns, false) || tidepoolPlugin?.hasWritePermission == true
}
}.learned(Learned(R.string.objectives_0_learned))
)
tasks.add(object : Task(this, R.string.hasbgdata) {
override fun isCompleted(): Boolean {
return iobCobCalculator.ads.lastBg() != null

View file

@ -8,7 +8,7 @@ class Objective10(injector: HasAndroidInjector) : Objective(injector, "auto", R.
init {
tasks.add(
MinimumDurationTask(this, T.days(28).msecs())
MinimumDurationTask(this, T.mins(28).msecs())
.learned(Learned(R.string.objectives_autosens_learned))
)
}

View file

@ -8,7 +8,7 @@ class Objective11(injector: HasAndroidInjector) : Objective(injector, "dyn_isf",
init {
tasks.add(
MinimumDurationTask(this, T.days(28).msecs())
MinimumDurationTask(this, T.mins(28).msecs())
.learned(Learned(R.string.objectives_dyn_isf_learned))
)
}

View file

@ -12,7 +12,7 @@ class Objective3 @Inject constructor(injector: HasAndroidInjector) : Objective(i
@Inject lateinit var activePlugin: ActivePlugin
init {
tasks.add(MinimumDurationTask(this, T.days(7).msecs()))
tasks.add(MinimumDurationTask(this, T.mins(7).msecs()))
tasks.add(
object : Task(this, R.string.objectives_manualenacts) {
override fun isCompleted(): Boolean {

View file

@ -15,7 +15,7 @@ class Objective5(injector: HasAndroidInjector) : Objective(injector, "maxiobzero
@Inject lateinit var aapsLogger: AAPSLogger
init {
tasks.add(MinimumDurationTask(this, T.days(5).msecs()))
tasks.add(MinimumDurationTask(this, T.mins(5).msecs()))
tasks.add(
object : Task(this, R.string.closedmodeenabled) {
override fun isCompleted(): Boolean {

View file

@ -13,7 +13,7 @@ class Objective6(injector: HasAndroidInjector) : Objective(injector, "maxiob", R
@Inject lateinit var constraintChecker: ConstraintsChecker
init {
tasks.add(MinimumDurationTask(this, T.days(1).msecs()))
tasks.add(MinimumDurationTask(this, T.mins(1).msecs()))
tasks.add(
object : Task(this, R.string.closedmodeenabled) {
override fun isCompleted(): Boolean = ApsMode.fromString(sp.getString(app.aaps.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)) == ApsMode.CLOSED

View file

@ -8,7 +8,7 @@ class Objective7(injector: HasAndroidInjector) : Objective(injector, "autosens",
init {
tasks.add(
MinimumDurationTask(this, T.days(7).msecs())
MinimumDurationTask(this, T.mins(7).msecs())
.learned(Learned(R.string.objectives_autosens_learned))
)
}

View file

@ -8,7 +8,7 @@ class Objective9(injector: HasAndroidInjector) : Objective(injector, "smb", R.st
init {
tasks.add(
MinimumDurationTask(this, T.days(28).msecs())
MinimumDurationTask(this, T.mins(28).msecs())
.learned(Learned(R.string.objectives_smb_learned))
)
}

View file

@ -91,8 +91,6 @@ class SafetyPlugin @Inject constructor(
}
override fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
val bgSource = activePlugin.activeBgSource
if (!bgSource.advancedFilteringSupported()) value.set(false, rh.gs(R.string.smbalwaysdisabled), this)
return value
}

View file

@ -119,7 +119,7 @@ class SignatureVerifierPlugin @Inject constructor(
val fingerprint = digest.digest(signature.toByteArray())
for (cert in revokedCerts!!) {
if (Arrays.equals(cert, fingerprint)) {
return true
return false
}
}
}

View file

@ -618,11 +618,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
it.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(app.aaps.core.ui.R.drawable.ic_user_options), null, null)
it.text = event.title
it.setOnClickListener {
OKDialog.showConfirmation(context, rh.gs(R.string.run_question, event.title), { handler.post { automation.processEvent(event) } })
}
binding.buttonsLayout.userButtonsLayout.addView(it)
for (drawable in it.compoundDrawables ) {
drawable?.mutate()
drawable?.colorFilter = PorterDuffColorFilter(rh.gac(context, app.aaps.core.ui.R.attr.userOptionColor), PorterDuff.Mode.SRC_IN)
}
}
}
binding.buttonsLayout.userButtonsLayout.visibility = events.isNotEmpty().toVisibility()

View file

@ -61,7 +61,8 @@ class XdripSourcePlugin @Inject constructor(
GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE,
GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE_XDRIP,
GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE_XDRIP,
GlucoseValue.SourceSensor.DEXCOM_G6_G5_NATIVE_XDRIP
GlucoseValue.SourceSensor.DEXCOM_G6_G5_NATIVE_XDRIP,
GlucoseValue.SourceSensor.DEXCOM_G7_NATIVE_XDRIP
).any { it == glucoseValue.sourceSensor }
}

View file

@ -88,6 +88,8 @@ class NsIncomingDataProcessor @Inject constructor(
*/
@Suppress("SpellCheckingInspection")
fun processSgvs(sgvs: Any): Boolean {
// Objective0
sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
if (!nsClientSource.isEnabled() && !sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_cgm, false)) return false

View file

@ -561,8 +561,6 @@ class NSClientService : DaggerService() {
val sgvs = data.getJSONArray("sgvs")
if (sgvs.length() > 0) {
rxBus.send(EventNSClientNewLog("◄ DATA", "received " + sgvs.length() + " sgvs"))
// Objective0
sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
nsIncomingDataProcessor.processSgvs(sgvs)
storeDataForDb.storeGlucoseValuesToDb()
}

View file

@ -61,8 +61,6 @@ class LoadBgWorker(
if (sgvs.isNotEmpty()) {
val action = if (isFirstLoad) "RCV-F" else "RCV"
rxBus.send(EventNSClientNewLog("$action", "${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(lastLoaded)}"))
// Objective0
sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
// Schedule processing of fetched data and continue of loading
continueLoading = response.code != 304 && nsIncomingDataProcessor.processSgvs(sgvs)
} else {

View file

@ -53,6 +53,7 @@ import app.aaps.core.ui.toast.ToastUtils
import app.aaps.core.validators.ValidatingEditTextPreference
import dagger.android.HasAndroidInjector
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.services.MedtrumService
import info.nightscout.pump.medtrum.ui.MedtrumOverviewFragment
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
@ -153,7 +154,7 @@ import kotlin.math.abs
override fun afterTextChanged(newValue: Editable?) {
val newSN = newValue?.toString()?.toLongOrNull(radix = 16) ?: 0
val newDeviceType = MedtrumSnUtil().getDeviceTypeFromSerial(newSN)
editText.error = if (newDeviceType == MedtrumSnUtil.INVALID) {
editText.error = if (newDeviceType == ModelType.INVALID) {
rh.gs(R.string.sn_input_invalid)
} else {
null
@ -174,7 +175,7 @@ import kotlin.math.abs
val newDeviceType = MedtrumSnUtil().getDeviceTypeFromSerial(newSN)
when {
newDeviceType == MedtrumSnUtil.INVALID -> {
newDeviceType == ModelType.INVALID -> {
preferenceFragment.activity?.let { activity ->
OKDialog.show(activity, rh.gs(R.string.sn_input_title), rh.gs(R.string.sn_input_invalid))
}
@ -183,7 +184,7 @@ import kotlin.math.abs
medtrumPump.pumpType(newDeviceType) == PumpType.MEDTRUM_UNTESTED -> {
preferenceFragment.activity?.let { activity ->
OKDialog.show(activity, rh.gs(R.string.sn_input_title), rh.gs(R.string.pump_unsupported, newDeviceType))
OKDialog.show(activity, rh.gs(R.string.sn_input_title), rh.gs(R.string.pump_unsupported, newDeviceType.toString()))
}
false
}

View file

@ -18,6 +18,7 @@ import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
import info.nightscout.pump.medtrum.comm.enums.AlarmState
import info.nightscout.pump.medtrum.comm.enums.BasalType
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.extension.toByteArray
import info.nightscout.pump.medtrum.extension.toInt
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
@ -291,12 +292,12 @@ class MedtrumPump @Inject constructor(
var desiredPumpWarning = true
var desiredPumpWarningExpiryThresholdHours = 72L
fun pumpType(): PumpType = pumpType(deviceType)
fun pumpType(): PumpType = pumpType(ModelType.fromValue(deviceType))
fun pumpType(type: Int): PumpType =
fun pumpType(type: ModelType): PumpType =
when (type) {
MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO
MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U
ModelType.MD0201, ModelType.MD8201 -> PumpType.MEDTRUM_NANO
ModelType.MD8301 -> PumpType.MEDTRUM_300U
else -> PumpType.MEDTRUM_UNTESTED
}
@ -569,7 +570,7 @@ class MedtrumPump @Inject constructor(
AlarmState.EXPIRED -> R.string.alarm_expired
AlarmState.RESERVOIR_EMPTY -> R.string.alarm_reservoir_empty
AlarmState.PATCH_FAULT -> R.string.alarm_patch_fault
AlarmState.PATCH_FAULT2 -> R.string.alarm_patch_fault2
AlarmState.PATCH_FAULT2 -> R.string.alarm_patch_fault // To avoid confusion, medtrum app also doesn't show patch fault 2
AlarmState.BASE_FAULT -> R.string.alarm_base_fault
AlarmState.BATTERY_OUT -> R.string.alarm_battery_out
AlarmState.NO_CALIBRATION -> R.string.alarm_no_calibration

View file

@ -15,7 +15,6 @@ enum class PatchStep {
ACTIVATE_COMPLETE,
RETRY_ACTIVATION,
RETRY_ACTIVATION_CONNECT,
ERROR,
CANCEL,
COMPLETE;
}

View file

@ -0,0 +1,17 @@
package info.nightscout.pump.medtrum.comm.enums
enum class ModelType(val value: Int) {
INVALID(-1),
MD0201(80),
MD5201(81),
MD0202(82),
MD5202(83),
MD8201(88),
MD8301(98);
companion object {
fun fromValue(value: Int): ModelType {
return values().find { it.value == value } ?: INVALID
}
}
}

View file

@ -132,7 +132,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
if (event.isChanged(rh.gs(R.string.key_sn_input))) {
aapsLogger.debug(LTag.PUMPCOMM, "Serial number changed, reporting new pump!")
medtrumPump.loadUserSettingsFromSP()
medtrumPump.deviceType = MedtrumSnUtil().getDeviceTypeFromSerial(medtrumPump.pumpSN)
medtrumPump.deviceType = MedtrumSnUtil().getDeviceTypeFromSerial(medtrumPump.pumpSN).value
medtrumPump.resetPatchParameters()
pumpSync.connectNewPump()
medtrumPump.setFakeTBRIfNotSet()

View file

@ -38,7 +38,6 @@ class MedtrumActivateFragment : MedtrumBaseFragment<FragmentMedtrumActivateBindi
MedtrumViewModel.SetupStep.ACTIVATED -> moveStep(PatchStep.ACTIVATE_COMPLETE)
MedtrumViewModel.SetupStep.ERROR -> {
moveStep(PatchStep.ERROR)
updateSetupStep(MedtrumViewModel.SetupStep.PRIMED) // Reset setup step
binding.textActivatingPump.text = rh.gs(R.string.activating_error)
binding.btnPositive.visibility = View.VISIBLE

View file

@ -43,7 +43,6 @@ class MedtrumActivity : MedtrumBaseActivity<ActivityMedtrumBinding>() {
PatchStep.ATTACH_PATCH -> setupViewFragment(MedtrumAttachPatchFragment.newInstance())
PatchStep.ACTIVATE -> setupViewFragment(MedtrumActivateFragment.newInstance())
PatchStep.ACTIVATE_COMPLETE -> setupViewFragment(MedtrumActivateCompleteFragment.newInstance())
PatchStep.ERROR -> Unit // Do nothing, let activity handle this
PatchStep.RETRY_ACTIVATION -> setupViewFragment(MedtrumRetryActivationFragment.newInstance())
PatchStep.RETRY_ACTIVATION_CONNECT -> setupViewFragment(MedtrumRetryActivationConnectFragment.newInstance())
PatchStep.START_DEACTIVATION -> setupViewFragment(MedtrumStartDeactivationFragment.newInstance())

View file

@ -38,7 +38,6 @@ class MedtrumDeactivatePatchFragment : MedtrumBaseFragment<FragmentMedtrumDeacti
}
MedtrumViewModel.SetupStep.ERROR -> {
moveStep(PatchStep.ERROR)
updateSetupStep(MedtrumViewModel.SetupStep.START_DEACTIVATION) // Reset setup step
binding.textDeactivatingPump.text = rh.gs(R.string.deactivating_error)
binding.btnNegative.visibility = View.VISIBLE

View file

@ -39,7 +39,6 @@ class MedtrumPrimingFragment : MedtrumBaseFragment<FragmentMedtrumPrimingBinding
MedtrumViewModel.SetupStep.PRIMED -> moveStep(PatchStep.PRIME_COMPLETE)
MedtrumViewModel.SetupStep.ERROR -> {
moveStep(PatchStep.ERROR)
updateSetupStep(MedtrumViewModel.SetupStep.FILLED) // Reset setup step
binding.textWaitForPriming.text = rh.gs(R.string.priming_error)
binding.btnNegative.visibility = View.VISIBLE

View file

@ -14,6 +14,7 @@ import info.nightscout.pump.medtrum.R
import info.nightscout.pump.medtrum.code.ConnectionState
import info.nightscout.pump.medtrum.code.EventType
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.ui.MedtrumBaseNavigator
import info.nightscout.pump.medtrum.ui.event.SingleLiveEvent
import info.nightscout.pump.medtrum.ui.event.UIEvent
@ -199,7 +200,7 @@ class MedtrumOverviewViewModel @Inject constructor(
val activeAlarmStrings = medtrumPump.activeAlarms.map { medtrumPump.alarmStateToString(it) }
_activeAlarms.postValue(activeAlarmStrings.joinToString("\n"))
_pumpType.postValue(medtrumPump.deviceType.toString())
_pumpType.postValue(ModelType.fromValue(medtrumPump.deviceType).toString())
_fwVersion.postValue(medtrumPump.swVersion)
_patchNo.postValue(medtrumPump.patchId.toString())

View file

@ -137,7 +137,6 @@ class MedtrumViewModel @Inject constructor(
PatchStep.CANCEL,
PatchStep.COMPLETE,
PatchStep.ACTIVATE_COMPLETE,
PatchStep.ERROR,
PatchStep.START_DEACTIVATION,
PatchStep.DEACTIVATE,
PatchStep.FORCE_DEACTIVATION,
@ -307,7 +306,6 @@ class MedtrumViewModel @Inject constructor(
PatchStep.COMPLETE,
PatchStep.FORCE_DEACTIVATION,
PatchStep.ERROR,
PatchStep.CANCEL -> _title.value
}

View file

@ -1,33 +1,23 @@
package info.nightscout.pump.medtrum.util
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.encryption.Crypt
class MedtrumSnUtil {
companion object {
const val INVALID = -1
const val MD_0201 = 80
const val MD_5201 = 81
const val MD_0202 = 82
const val MD_5202 = 83
const val MD_8201 = 88
const val MD_8301 = 98
}
fun getDeviceTypeFromSerial(serial: Long): Int {
fun getDeviceTypeFromSerial(serial: Long): ModelType {
if (serial in 106000000..106999999) {
return INVALID
return ModelType.INVALID
}
return when (Crypt().simpleDecrypt(serial)) {
in 126000000..126999999 -> MD_0201
in 127000000..127999999 -> MD_5201
in 128000000..128999999 -> MD_8201
in 130000000..130999999 -> MD_0202
in 131000000..131999999 -> MD_5202
in 148000000..148999999 -> MD_8301
else -> INVALID
in 126000000..126999999 -> ModelType.MD0201
in 127000000..127999999 -> ModelType.MD5201
in 128000000..128999999 -> ModelType.MD8201
in 130000000..130999999 -> ModelType.MD0202
in 131000000..131999999 -> ModelType.MD5202
in 148000000..148999999 -> ModelType.MD8301
else -> ModelType.INVALID
}
}
}

View file

@ -77,7 +77,6 @@
<string name="alarm_expired">Expired</string>
<string name="alarm_reservoir_empty">Reservoir empty</string>
<string name="alarm_patch_fault">Patch fault</string>
<string name="alarm_patch_fault2">Patch fault 2</string>
<string name="alarm_base_fault">Base fault</string>
<string name="alarm_battery_out">Battery out</string>
<string name="alarm_no_calibration">No calibration</string>
@ -142,7 +141,7 @@
<string name="sn_input_title">Serial Number</string>
<string name="sn_input_summary">Enter the serial number of your pump base.</string>
<string name="sn_input_invalid">Invalid serial number!</string>
<string name="pump_unsupported">Pump untested: %1$d! Please contact us at discord or github for support</string>
<string name="pump_unsupported">Pump untested: %1$s! Please contact us at discord or github for support</string>
<string name="alarm_setting_title">Alarm Settings</string>
<string name="alarm_setting_summary">Select your preferred pump alarm settings.</string>
<string name="pump_warning_notification_title">Notification on pump warning</string>

View file

@ -9,6 +9,7 @@ import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
import app.aaps.core.interfaces.utils.T
import com.google.common.truth.Truth.assertThat
import info.nightscout.pump.medtrum.comm.enums.BasalType
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
import org.json.JSONObject
import org.junit.jupiter.api.Test
@ -139,7 +140,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val receivedTime = 1500L
val duration = T.mins(5).msecs()
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -191,7 +192,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -240,7 +241,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -293,7 +294,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val duration = T.mins(5).msecs()
medtrumPump.actualBasalProfile = medtrumPump.buildMedtrumProfileArray(validProfile)!!
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -346,7 +347,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -441,7 +442,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -492,7 +493,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
Mockito.`when`(pumpSync.expectedPumpState()).thenReturn(
@ -537,7 +538,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -581,7 +582,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val basalStartTime = 1000L
val receivedTime = 1500L
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
Mockito.`when`(pumpSync.expectedPumpState()).thenReturn(
@ -650,7 +651,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
@Test fun setFakeTBRIfNotSetWhenNoFakeTBRAlreadyRunningExpectPumpSync() {
// Inputs
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)
@ -684,7 +685,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
@Test fun setFakeTBRIfNotSetWhenFakeTBRAlreadyRunningExpectNoPumpSync() {
// Inputs
medtrumPump.deviceType = MedtrumSnUtil.MD_8301
medtrumPump.deviceType = ModelType.MD8301.value
// Mocks
val expectedTemporaryBasal: PumpSync.PumpState.TemporaryBasal = mock(PumpSync.PumpState.TemporaryBasal::class.java)