- support for Aidex plugins

This commit is contained in:
Andy Rozman 2022-03-17 19:05:38 +00:00
parent 7502824a1b
commit 5c05a31030
5 changed files with 18 additions and 19 deletions

View file

@ -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() + '"'

View file

@ -109,6 +109,8 @@
<action android:name="com.china.poctech.data"/>
<!-- Receiver from Tomato -->
<action android:name="com.fanqies.tomatofn.BgEstimate"/>
<!-- Receiver from GlucoRx Aidex -->
<action android:name="com.microtechmd.cgms.aidex.action.BgEstimate"/>
</intent-filter>
</receiver>

View file

@ -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
}

View file

@ -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<CgmSourceTransaction.TransactionGlucoseValue>()
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)),

View file

@ -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"
}