diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 27ad7fec82..25d4175a16 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -145,6 +145,10 @@ class DexcomPlugin @Inject constructor( } } + override fun getSensorBatteryLevel(): Int { + return -1 + } + companion object { private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol", "com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol", diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 9141d57214..43a3cb0669 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -41,6 +41,8 @@ class EversensePlugin @Inject constructor( aapsLogger, resourceHelper, injector ), BgSourceInterface { + private var sensorBatteryLevel = -1 + override fun advancedFilteringSupported(): Boolean { return false } @@ -53,7 +55,10 @@ class EversensePlugin @Inject constructor( if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) if (bundle.containsKey("glucoseTrendDirection")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection")) if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + dateUtil.dateAndTimeString(bundle.getLong("glucoseTimestamp"))) - if (bundle.containsKey("batteryLevel")) aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel")) + if (bundle.containsKey("batteryLevel")) { + aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel")) + sensorBatteryLevel = bundle.getString("batteryLevel").toInt() // TODO: Philoul: Line to check I don't have eversens so I don't know what kind of information is sent... + } if (bundle.containsKey("signalStrength")) aapsLogger.debug(LTag.BGSOURCE, "signalStrength: " + bundle.getString("signalStrength")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("isXLVersion")) aapsLogger.debug(LTag.BGSOURCE, "isXLVersion: " + bundle.getBoolean("isXLVersion")) @@ -113,4 +118,8 @@ class EversensePlugin @Inject constructor( } } } + + override fun getSensorBatteryLevel(): Int { + return sensorBatteryLevel + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index c2cd1d84e9..0cffbbde82 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -45,4 +45,8 @@ class GlimpPlugin @Inject constructor( bgReading.raw = 0.0 MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP") } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index 4d082c0133..7c9c39cf76 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -65,4 +65,8 @@ class MM640gPlugin @Inject constructor( } } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index 4e10a9c728..365aab4911 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -91,4 +91,8 @@ class NSClientSourcePlugin @Inject constructor( lastBGTimeStamp = timeStamp } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 2032dd4479..2e161363e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -69,4 +69,8 @@ class PoctechPlugin @Inject constructor( aapsLogger.error("Exception: ", e) } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index 3678f130a4..ed3101f727 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -100,4 +100,9 @@ class RandomBgPlugin @Inject constructor( } aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading") } + + + override fun getSensorBatteryLevel(): Int { + return -1 + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index 1ba7958b61..b80db46e5d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -53,4 +53,8 @@ class TomatoPlugin @Inject constructor( nsUpload.sendToXdrip(bgReading) } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt index aaf38b93b6..bb5ef91db0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt @@ -31,6 +31,7 @@ class XdripPlugin @Inject constructor( ), BgSourceInterface { private var advancedFiltering = false + private var sensorBatteryLevel = -1 override fun advancedFilteringSupported(): Boolean { return advancedFiltering @@ -45,6 +46,7 @@ class XdripPlugin @Inject constructor( bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME) bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP) bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW) + if (bundle.containsKey(Intents.EXTRA_SENSOR_BATTERY)) sensorBatteryLevel = bundle.getInt(Intents.EXTRA_SENSOR_BATTERY) val source = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "no Source specified") setSource(source) MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP") @@ -53,4 +55,8 @@ class XdripPlugin @Inject constructor( private fun setSource(source: String) { advancedFiltering = source.contains("G5 Native") || source.contains("G6 Native") } + + override fun getSensorBatteryLevel(): Int { + return sensorBatteryLevel + } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java index d42ead7950..3903e40250 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java @@ -9,4 +9,6 @@ public interface BgSourceInterface { boolean advancedFilteringSupported(); void handleNewData(Intent intent); + + int getSensorBatteryLevel(); }