From 5c05a31030271778ef92ce6854f82aaaa4b9500c Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 17 Mar 2022 19:05:38 +0000 Subject: [PATCH] - support for Aidex plugins --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 ++ .../nightscout/androidaps/di/WorkersModule.kt | 1 + .../androidaps/plugins/source/AidexPlugin.kt | 16 +++++++++++++--- .../nightscout/androidaps/services/Intents.kt | 16 +--------------- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 427013fd1a..9d7b945424 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "3.0.0.1-dev-e" + version "3.0.0.1-dev-aidex" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b8b5d99d97..3badcdbfaf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -109,6 +109,8 @@ + + diff --git a/app/src/main/java/info/nightscout/androidaps/di/WorkersModule.kt b/app/src/main/java/info/nightscout/androidaps/di/WorkersModule.kt index 92c84687b7..78991d111f 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/WorkersModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/WorkersModule.kt @@ -32,4 +32,5 @@ abstract class WorkersModule { @ContributesAndroidInjector abstract fun contributesNSClientMbgWorker(): NSClientMbgWorker @ContributesAndroidInjector abstract fun contributesFoodWorker(): FoodPlugin.FoodWorker @ContributesAndroidInjector abstract fun contributesCsvExportWorker(): ImportExportPrefsImpl.CsvExportWorker + @ContributesAndroidInjector abstract fun contributesAidexWorker(): AidexPlugin.AidexWorker } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/AidexPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/AidexPlugin.kt index 5c91d6f278..05e795cfcb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/AidexPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/AidexPlugin.kt @@ -21,6 +21,7 @@ import info.nightscout.androidaps.services.Intents import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import javax.inject.Singleton +import kotlin.math.log @Singleton class AidexPlugin @Inject constructor( @@ -32,7 +33,7 @@ class AidexPlugin @Inject constructor( .fragmentClass(BGSourceFragment::class.java.name) .pluginIcon((R.drawable.ic_blooddrop_48)) .pluginName(R.string.aidex) - .shortName(R.string.randombg_short) + .shortName(R.string.aidex_short) .description(R.string.description_source_aidex), aapsLogger, rh, injector ), BgSource { @@ -76,9 +77,18 @@ class AidexPlugin @Inject constructor( if (bundle.containsKey(Intents.AIDEX_SENSOR_ID)) aapsLogger.debug(LTag.BGSOURCE, "sensorId: " + bundle.getString(Intents.AIDEX_SENSOR_ID)) val glucoseValues = mutableListOf() + + val timestamp = bundle.getLong(Intents.AIDEX_TIMESTAMP, 0) + val bgType = bundle.getString(Intents.AIDEX_BG_TYPE, "mg/dl") + val bgValue = bundle.getDouble(Intents.AIDEX_BG_VALUE, 0.0) + + val bgValueTarget = if (bgType.equals("mg/dl")) bgValue else bgValue * Constants.MMOLL_TO_MGDL + + aapsLogger.debug(LTag.BGSOURCE, "Received Aidex broadcast [time=$timestamp, bgType=$bgType, value=$bgValue, targetValue=$bgValueTarget") + glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( - timestamp = bundle.getLong(Intents.AIDEX_TIMESTAMP, 0), - value = if (bundle.getString(Intents.AIDEX_BG_TYPE, "mg/dl").equals("mg/dl")) bundle.getDouble(Intents.AIDEX_BG_VALUE, 0.0) else bundle.getDouble(Intents.AIDEX_BG_VALUE, 0.0) * Constants.MMOLL_TO_MGDL, + timestamp = timestamp, + value = bgValueTarget, raw = null, noise = null, trendArrow = GlucoseValue.TrendArrow.fromString(bundle.getString(Intents.AIDEX_BG_SLOPE_NAME)), diff --git a/app/src/main/java/info/nightscout/androidaps/services/Intents.kt b/app/src/main/java/info/nightscout/androidaps/services/Intents.kt index 87c74bcb47..925c74eff8 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/Intents.kt +++ b/app/src/main/java/info/nightscout/androidaps/services/Intents.kt @@ -32,28 +32,14 @@ interface Intents { const val TOMATO_BG = "com.fanqies.tomatofn.BgEstimate" // Aidex -> AAPS - var AIDEX_NEW_BG_ESTIMATE = "com.microtechmd.cgms.aidex.BgEstimate" - - // DATA - // DATA - /** - * BG Type: Can be either mmol/l or mg/dl - */ + var AIDEX_NEW_BG_ESTIMATE = "com.microtechmd.cgms.aidex.action.BgEstimate" var AIDEX_BG_TYPE = "com.microtechmd.cgms.aidex.BgType" var AIDEX_BG_VALUE = "com.microtechmd.cgms.aidex.BgValue" - - /** - * BG Slope Name: following values are valid: - * "DoubleUp", "SingleUp", "FortyFiveUp", "Flat", "FortyFiveDown", "SingleDown", - * "DoubleDown", "NotComputable", "RateOutOfRange" - */ var AIDEX_BG_SLOPE_NAME = "com.microtechmd.cgms.aidex.BgSlopeName" var AIDEX_TIMESTAMP = "com.microtechmd.cgms.aidex.Time" // epoch in ms - var AIDEX_TRANSMITTER_SN = "com.microtechmd.cgms.aidex.TransmitterSerialNumber" var AIDEX_SENSOR_ID = "com.microtechmd.cgms.aidex.SensorId" - // Broadcast status const val AAPS_BROADCAST = "info.nightscout.androidaps.status" }