Add new interface for BgSource to get SensorBatteryLevel

Note, for xDrip, an Int is sent but I don't know what type of value is sent for Eversens that has a sensor battery level too...
This commit is contained in:
Philoul 2020-10-17 20:12:58 +02:00
parent bd3cba8a1a
commit 3f4b3149db
10 changed files with 47 additions and 1 deletions

View file

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

View file

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

View file

@ -45,4 +45,8 @@ class GlimpPlugin @Inject constructor(
bgReading.raw = 0.0
MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP")
}
override fun getSensorBatteryLevel(): Int {
return -1
}
}

View file

@ -65,4 +65,8 @@ class MM640gPlugin @Inject constructor(
}
}
}
override fun getSensorBatteryLevel(): Int {
return -1
}
}

View file

@ -91,4 +91,8 @@ class NSClientSourcePlugin @Inject constructor(
lastBGTimeStamp = timeStamp
}
}
override fun getSensorBatteryLevel(): Int {
return -1
}
}

View file

@ -69,4 +69,8 @@ class PoctechPlugin @Inject constructor(
aapsLogger.error("Exception: ", e)
}
}
override fun getSensorBatteryLevel(): Int {
return -1
}
}

View file

@ -100,4 +100,9 @@ class RandomBgPlugin @Inject constructor(
}
aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading")
}
override fun getSensorBatteryLevel(): Int {
return -1
}
}

View file

@ -53,4 +53,8 @@ class TomatoPlugin @Inject constructor(
nsUpload.sendToXdrip(bgReading)
}
}
override fun getSensorBatteryLevel(): Int {
return -1
}
}

View file

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

View file

@ -9,4 +9,6 @@ public interface BgSourceInterface {
boolean advancedFilteringSupported();
void handleNewData(Intent intent);
int getSensorBatteryLevel();
}