BGSOURCE: allow upload from all plugins except NSC
This commit is contained in:
parent
89f822e003
commit
946ea0bf33
22 changed files with 81 additions and 185 deletions
core/interfaces/src/main/java/info/nightscout/interfaces/source
plugins
main/src/main/java/info/nightscout/plugins/general/overview
source/src
main/java/info/nightscout/source
AidexPlugin.ktDexcomPlugin.ktEversensePlugin.ktGlimpPlugin.ktGlunovoPlugin.ktIntelligoPlugin.ktMM640gPlugin.ktNSClientSourcePlugin.ktPoctechPlugin.ktRandomBgPlugin.ktTomatoPlugin.ktXdripSourcePlugin.kt
di
test/java/info/nightscout/source
sync/src/main/java/info/nightscout/plugins/sync
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.interfaces.source
|
package info.nightscout.interfaces.source
|
||||||
|
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
|
||||||
|
|
||||||
interface BgSource {
|
interface BgSource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,12 +16,4 @@ interface BgSource {
|
||||||
*/
|
*/
|
||||||
val sensorBatteryLevel: Int
|
val sensorBatteryLevel: Int
|
||||||
get() = -1
|
get() = -1
|
||||||
|
|
||||||
/**
|
|
||||||
* Decide if GlucoseValue should be uploaded to NS
|
|
||||||
*
|
|
||||||
* @param glucoseValue glucose value
|
|
||||||
* @return true if GlucoseValue should be uploaded to NS (supported by plugin and enabled in preferences)
|
|
||||||
*/
|
|
||||||
fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean
|
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
package info.nightscout.interfaces.source
|
|
||||||
|
|
||||||
interface DoingOwnUploadSource
|
|
|
@ -1,5 +1,5 @@
|
||||||
package info.nightscout.interfaces.source
|
package info.nightscout.interfaces.source
|
||||||
|
|
||||||
interface XDrip {
|
interface XDripSource {
|
||||||
fun isEnabled(): Boolean
|
fun isEnabled(): Boolean
|
||||||
}
|
}
|
|
@ -65,7 +65,7 @@ import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
import info.nightscout.interfaces.protection.ProtectionCheck
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
import info.nightscout.interfaces.source.DexcomBoyda
|
import info.nightscout.interfaces.source.DexcomBoyda
|
||||||
import info.nightscout.interfaces.source.XDrip
|
import info.nightscout.interfaces.source.XDripSource
|
||||||
import info.nightscout.interfaces.ui.UiInteraction
|
import info.nightscout.interfaces.ui.UiInteraction
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.interfaces.utils.TrendCalculator
|
import info.nightscout.interfaces.utils.TrendCalculator
|
||||||
|
@ -128,7 +128,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
@Inject lateinit var activePlugin: ActivePlugin
|
||||||
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
||||||
@Inject lateinit var dexcomBoyda: DexcomBoyda
|
@Inject lateinit var dexcomBoyda: DexcomBoyda
|
||||||
@Inject lateinit var xDrip: XDrip
|
@Inject lateinit var xDripSource: XDripSource
|
||||||
@Inject lateinit var notificationStore: NotificationStore
|
@Inject lateinit var notificationStore: NotificationStore
|
||||||
@Inject lateinit var quickWizard: QuickWizard
|
@Inject lateinit var quickWizard: QuickWizard
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
|
@ -400,7 +400,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.cgm_button -> {
|
R.id.cgm_button -> {
|
||||||
if (xDrip.isEnabled())
|
if (xDripSource.isEnabled())
|
||||||
openCgmApp("com.eveningoutpost.dexdrip")
|
openCgmApp("com.eveningoutpost.dexdrip")
|
||||||
else if (dexcomBoyda.isEnabled()) {
|
else if (dexcomBoyda.isEnabled()) {
|
||||||
dexcomBoyda.findDexcomPackageName()?.let {
|
dexcomBoyda.findDexcomPackageName()?.let {
|
||||||
|
@ -411,7 +411,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.calibration_button -> {
|
R.id.calibration_button -> {
|
||||||
if (xDrip.isEnabled()) {
|
if (xDripSource.isEnabled()) {
|
||||||
uiInteraction.runCalibrationDialog(childFragmentManager)
|
uiInteraction.runCalibrationDialog(childFragmentManager)
|
||||||
} else if (dexcomBoyda.isEnabled()) {
|
} else if (dexcomBoyda.isEnabled()) {
|
||||||
try {
|
try {
|
||||||
|
@ -577,7 +577,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
&& sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility()
|
&& sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility()
|
||||||
|
|
||||||
// **** Calibration & CGM buttons ****
|
// **** Calibration & CGM buttons ****
|
||||||
val xDripIsBgSource = xDrip.isEnabled()
|
val xDripIsBgSource = xDripSource.isEnabled()
|
||||||
val dexcomIsSource = dexcomBoyda.isEnabled()
|
val dexcomIsSource = dexcomBoyda.isEnabled()
|
||||||
binding.buttonsLayout.calibrationButton.visibility = (xDripIsBgSource && actualBG != null && sp.getBoolean(R.string.key_show_calibration_button, true)).toVisibility()
|
binding.buttonsLayout.calibrationButton.visibility = (xDripIsBgSource && actualBG != null && sp.getBoolean(R.string.key_show_calibration_button, true)).toVisibility()
|
||||||
if (dexcomIsSource) {
|
if (dexcomIsSource) {
|
||||||
|
|
|
@ -35,17 +35,13 @@ class AidexPlugin @Inject constructor(
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon((info.nightscout.core.main.R.drawable.ic_blooddrop_48))
|
.pluginIcon((info.nightscout.core.main.R.drawable.ic_blooddrop_48))
|
||||||
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.pluginName(R.string.aidex)
|
.pluginName(R.string.aidex)
|
||||||
.shortName(R.string.aidex_short)
|
.shortName(R.string.aidex_short)
|
||||||
.description(R.string.description_source_aidex),
|
.description(R.string.description_source_aidex),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Aidex App doesn't have upload to NS
|
|
||||||
*/
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = true
|
|
||||||
|
|
||||||
// Allow only for pumpcontrol or dev & engineering_mode
|
// Allow only for pumpcontrol or dev & engineering_mode
|
||||||
override fun specialEnableCondition(): Boolean {
|
override fun specialEnableCondition(): Boolean {
|
||||||
return config.APS.not() || config.isDev() && config.isEngineeringMode()
|
return config.APS.not() || config.isDev() && config.isEngineeringMode()
|
||||||
|
|
|
@ -45,7 +45,6 @@ class DexcomPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val sp: SP,
|
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
config: Config
|
config: Config
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
|
@ -53,9 +52,9 @@ class DexcomPlugin @Inject constructor(
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_dexcom_g6)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_dexcom_g6)
|
||||||
|
.preferencesId(R.xml.pref_dexcom)
|
||||||
.pluginName(R.string.dexcom_app_patched)
|
.pluginName(R.string.dexcom_app_patched)
|
||||||
.shortName(R.string.dexcom_short)
|
.shortName(R.string.dexcom_short)
|
||||||
.preferencesId(R.xml.pref_dexcom)
|
|
||||||
.description(R.string.description_source_dexcom),
|
.description(R.string.description_source_dexcom),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource, DexcomBoyda {
|
), BgSource, DexcomBoyda {
|
||||||
|
@ -68,12 +67,6 @@ class DexcomPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean = true
|
override fun advancedFilteringSupported(): Boolean = true
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
(glucoseValue.sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE ||
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE ||
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN)
|
|
||||||
&& sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
requestPermissionIfNeeded()
|
requestPermissionIfNeeded()
|
||||||
|
|
|
@ -19,7 +19,6 @@ import info.nightscout.interfaces.source.BgSource
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import java.util.Arrays
|
import java.util.Arrays
|
||||||
|
@ -30,25 +29,21 @@ import javax.inject.Singleton
|
||||||
class EversensePlugin @Inject constructor(
|
class EversensePlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger
|
||||||
private val sp: SP
|
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_eversense)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_eversense)
|
||||||
.pluginName(R.string.eversense)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.shortName(R.string.eversense_shortname)
|
.pluginName(R.string.eversense)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.shortName(R.string.eversense_shortname)
|
||||||
.description(R.string.description_source_eversense),
|
.description(R.string.description_source_eversense),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
|
||||||
override var sensorBatteryLevel = -1
|
override var sensorBatteryLevel = -1
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.EVERSENSE && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
// cannot be inner class because of needed injection
|
// cannot be inner class because of needed injection
|
||||||
class EversenseWorker(
|
class EversenseWorker(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -126,14 +121,16 @@ class EversensePlugin @Inject constructor(
|
||||||
aapsLogger.debug(LTag.BGSOURCE, "calibrationTimestamps" + Arrays.toString(calibrationTimestamps))
|
aapsLogger.debug(LTag.BGSOURCE, "calibrationTimestamps" + Arrays.toString(calibrationTimestamps))
|
||||||
aapsLogger.debug(LTag.BGSOURCE, "calibrationRecordNumbers" + Arrays.toString(calibrationRecordNumbers))
|
aapsLogger.debug(LTag.BGSOURCE, "calibrationRecordNumbers" + Arrays.toString(calibrationRecordNumbers))
|
||||||
for (i in calibrationGlucoseLevels.indices) {
|
for (i in calibrationGlucoseLevels.indices) {
|
||||||
repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(
|
repository.runTransactionForResult(
|
||||||
timestamp = calibrationTimestamps[i],
|
InsertIfNewByTimestampTherapyEventTransaction(
|
||||||
type = TherapyEvent.Type.FINGER_STICK_BG_VALUE,
|
timestamp = calibrationTimestamps[i],
|
||||||
glucose = calibrationGlucoseLevels[i].toDouble(),
|
type = TherapyEvent.Type.FINGER_STICK_BG_VALUE,
|
||||||
glucoseType = TherapyEvent.MeterType.FINGER,
|
glucose = calibrationGlucoseLevels[i].toDouble(),
|
||||||
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL,
|
glucoseType = TherapyEvent.MeterType.FINGER,
|
||||||
enteredBy = "AndroidAPS-Eversense"
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL,
|
||||||
))
|
enteredBy = "AndroidAPS-Eversense"
|
||||||
|
)
|
||||||
|
)
|
||||||
.doOnError {
|
.doOnError {
|
||||||
aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it)
|
aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it)
|
||||||
ret = Result.failure(workDataOf("Error" to it.toString()))
|
ret = Result.failure(workDataOf("Error" to it.toString()))
|
||||||
|
|
|
@ -17,7 +17,6 @@ import info.nightscout.interfaces.source.BgSource
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -27,15 +26,14 @@ import javax.inject.Singleton
|
||||||
class GlimpPlugin @Inject constructor(
|
class GlimpPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger
|
||||||
private val sp: SP
|
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_glimp)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_glimp)
|
||||||
.pluginName(R.string.glimp)
|
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
|
.pluginName(R.string.glimp)
|
||||||
.description(R.string.description_source_glimp),
|
.description(R.string.description_source_glimp),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
@ -78,8 +76,4 @@ class GlimpPlugin @Inject constructor(
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.LIBRE_1_GLIMP && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -45,8 +45,8 @@ class GlunovoPlugin @Inject constructor(
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_glunovo)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_glunovo)
|
||||||
.pluginName(R.string.glunovo)
|
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
|
.pluginName(R.string.glunovo)
|
||||||
.shortName(R.string.glunovo)
|
.shortName(R.string.glunovo)
|
||||||
.description(R.string.description_source_glunovo),
|
.description(R.string.description_source_glunovo),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
|
@ -167,9 +167,6 @@ class GlunovoPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.GLUNOVO_NATIVE && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val AUTHORITY = "alexpr.co.uk.infinivocgm.cgm_db.CgmExternalProvider/"
|
const val AUTHORITY = "alexpr.co.uk.infinivocgm.cgm_db.CgmExternalProvider/"
|
||||||
|
|
|
@ -48,8 +48,8 @@ class IntelligoPlugin @Inject constructor(
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.ui.R.drawable.ic_intelligo)
|
.pluginIcon(info.nightscout.core.ui.R.drawable.ic_intelligo)
|
||||||
.pluginName(R.string.intelligo)
|
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
|
.pluginName(R.string.intelligo)
|
||||||
.shortName(R.string.intelligo)
|
.shortName(R.string.intelligo)
|
||||||
.description(R.string.description_source_intelligo),
|
.description(R.string.description_source_intelligo),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
|
@ -175,14 +175,9 @@ class IntelligoPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.INTELLIGO_NATIVE && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val AUTHORITY = "alexpr.co.uk.infinivocgm.intelligo.cgm_db.CgmExternalProvider"
|
const val AUTHORITY = "alexpr.co.uk.infinivocgm.intelligo.cgm_db.CgmExternalProvider"
|
||||||
|
|
||||||
//const val AUTHORITY = "alexpr.co.uk.infinivocgm.cgm_db.CgmExternalProvider/"
|
|
||||||
const val TABLE_NAME = "CgmReading"
|
const val TABLE_NAME = "CgmReading"
|
||||||
const val INTERVAL = 180000L // 3 min
|
const val INTERVAL = 180000L // 3 min
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import info.nightscout.interfaces.source.BgSource
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
|
@ -28,15 +27,15 @@ import javax.inject.Singleton
|
||||||
class MM640gPlugin @Inject constructor(
|
class MM640gPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger
|
||||||
private val sp: SP
|
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_generic_cgm)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.pluginName(R.string.mm640g)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_generic_cgm)
|
||||||
.description(R.string.description_source_mm640g),
|
.pluginName(R.string.mm640g)
|
||||||
|
.description(R.string.description_source_mm640g),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
|
||||||
|
@ -75,6 +74,7 @@ class MM640gPlugin @Inject constructor(
|
||||||
trendArrow = GlucoseValue.TrendArrow.fromString(jsonObject.getString("direction")),
|
trendArrow = GlucoseValue.TrendArrow.fromString(jsonObject.getString("direction")),
|
||||||
sourceSensor = GlucoseValue.SourceSensor.MM_600_SERIES
|
sourceSensor = GlucoseValue.SourceSensor.MM_600_SERIES
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> aapsLogger.debug(LTag.BGSOURCE, "Unknown entries type: $type")
|
else -> aapsLogger.debug(LTag.BGSOURCE, "Unknown entries type: $type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,4 @@ class MM640gPlugin @Inject constructor(
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.MM_600_SERIES && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@ import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.plugin.PluginDescription
|
import info.nightscout.interfaces.plugin.PluginDescription
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.source.BgSource
|
import info.nightscout.interfaces.source.BgSource
|
||||||
import info.nightscout.interfaces.source.DoingOwnUploadSource
|
|
||||||
import info.nightscout.interfaces.source.NSClientSource
|
import info.nightscout.interfaces.source.NSClientSource
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
@ -31,15 +30,13 @@ class NSClientSourcePlugin @Inject constructor(
|
||||||
.alwaysEnabled(config.NSCLIENT)
|
.alwaysEnabled(config.NSCLIENT)
|
||||||
.setDefault(config.NSCLIENT),
|
.setDefault(config.NSCLIENT),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource, NSClientSource, DoingOwnUploadSource {
|
), BgSource, NSClientSource {
|
||||||
|
|
||||||
private var lastBGTimeStamp: Long = 0
|
private var lastBGTimeStamp: Long = 0
|
||||||
private var isAdvancedFilteringEnabled = false
|
private var isAdvancedFilteringEnabled = false
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean = isAdvancedFilteringEnabled
|
override fun advancedFilteringSupported(): Boolean = isAdvancedFilteringEnabled
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = false
|
|
||||||
|
|
||||||
override fun detectSource(glucoseValue: GlucoseValue) {
|
override fun detectSource(glucoseValue: GlucoseValue) {
|
||||||
if (glucoseValue.timestamp > lastBGTimeStamp) {
|
if (glucoseValue.timestamp > lastBGTimeStamp) {
|
||||||
isAdvancedFilteringEnabled = arrayOf(
|
isAdvancedFilteringEnabled = arrayOf(
|
||||||
|
|
|
@ -18,7 +18,6 @@ import info.nightscout.interfaces.utils.JsonHelper.safeGetString
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -29,16 +28,15 @@ import javax.inject.Singleton
|
||||||
class PoctechPlugin @Inject constructor(
|
class PoctechPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger
|
||||||
private val sp: SP
|
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_poctech)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_poctech)
|
||||||
.pluginName(R.string.poctech)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.pluginName(R.string.poctech)
|
||||||
.description(R.string.description_source_poctech),
|
.description(R.string.description_source_poctech),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
|
||||||
|
@ -91,8 +89,4 @@ class PoctechPlugin @Inject constructor(
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.POCTECH_NATIVE && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@ import info.nightscout.interfaces.source.BgSource
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
@ -35,7 +34,6 @@ class RandomBgPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val sp: SP,
|
|
||||||
private val repository: AppRepository,
|
private val repository: AppRepository,
|
||||||
private val virtualPump: VirtualPump,
|
private val virtualPump: VirtualPump,
|
||||||
private val config: Config
|
private val config: Config
|
||||||
|
@ -44,9 +42,9 @@ class RandomBgPlugin @Inject constructor(
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(R.drawable.ic_dice)
|
.pluginIcon(R.drawable.ic_dice)
|
||||||
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.pluginName(R.string.random_bg)
|
.pluginName(R.string.random_bg)
|
||||||
.shortName(R.string.random_bg_short)
|
.shortName(R.string.random_bg_short)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
|
||||||
.description(R.string.description_source_random_bg),
|
.description(R.string.description_source_random_bg),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
@ -73,9 +71,6 @@ class RandomBgPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean = true
|
override fun advancedFilteringSupported(): Boolean = true
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.RANDOM && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val cal = GregorianCalendar()
|
val cal = GregorianCalendar()
|
||||||
|
@ -116,9 +111,7 @@ class RandomBgPlugin @Inject constructor(
|
||||||
)
|
)
|
||||||
disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
||||||
.subscribe({ savedValues ->
|
.subscribe({ savedValues ->
|
||||||
savedValues.inserted.forEach {
|
savedValues.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") }
|
||||||
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
|
|
||||||
}
|
|
||||||
}, { aapsLogger.error(LTag.DATABASE, "Error while saving values from Random plugin", it) }
|
}, { aapsLogger.error(LTag.DATABASE, "Error while saving values from Random plugin", it) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,17 +25,16 @@ import javax.inject.Singleton
|
||||||
class TomatoPlugin @Inject constructor(
|
class TomatoPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
rh: ResourceHelper,
|
rh: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger
|
||||||
private val sp: SP
|
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon(info.nightscout.core.main.R.drawable.ic_sensor)
|
.pluginIcon(info.nightscout.core.main.R.drawable.ic_sensor)
|
||||||
.pluginName(R.string.tomato)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.pluginName(R.string.tomato)
|
||||||
.shortName(R.string.tomato_short)
|
.shortName(R.string.tomato_short)
|
||||||
.description(R.string.description_source_tomato),
|
.description(R.string.description_source_tomato),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource {
|
), BgSource {
|
||||||
|
|
||||||
|
@ -78,8 +77,4 @@ class TomatoPlugin @Inject constructor(
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean =
|
|
||||||
glucoseValue.sourceSensor == GlucoseValue.SourceSensor.LIBRE_1_TOMATO && sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false)
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,8 +15,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.receivers.Intents
|
import info.nightscout.interfaces.receivers.Intents
|
||||||
import info.nightscout.interfaces.source.BgSource
|
import info.nightscout.interfaces.source.BgSource
|
||||||
import info.nightscout.interfaces.source.DoingOwnUploadSource
|
import info.nightscout.interfaces.source.XDripSource
|
||||||
import info.nightscout.interfaces.source.XDrip
|
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
@ -31,19 +30,18 @@ class XdripSourcePlugin @Inject constructor(
|
||||||
aapsLogger: AAPSLogger
|
aapsLogger: AAPSLogger
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginIcon((info.nightscout.core.main.R.drawable.ic_blooddrop_48))
|
.pluginIcon((info.nightscout.core.main.R.drawable.ic_blooddrop_48))
|
||||||
.pluginName(R.string.source_xdrip)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.description(R.string.description_source_xdrip),
|
.pluginName(R.string.source_xdrip)
|
||||||
|
.description(R.string.description_source_xdrip),
|
||||||
aapsLogger, rh, injector
|
aapsLogger, rh, injector
|
||||||
), BgSource, DoingOwnUploadSource, XDrip {
|
), BgSource, XDripSource {
|
||||||
|
|
||||||
private var advancedFiltering = false
|
private var advancedFiltering = false
|
||||||
override var sensorBatteryLevel = -1
|
override var sensorBatteryLevel = -1
|
||||||
|
|
||||||
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = false
|
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean = advancedFiltering
|
override fun advancedFilteringSupported(): Boolean = advancedFiltering
|
||||||
|
|
||||||
private fun detectSource(glucoseValue: GlucoseValue) {
|
private fun detectSource(glucoseValue: GlucoseValue) {
|
||||||
|
@ -82,8 +80,10 @@ class XdripSourcePlugin @Inject constructor(
|
||||||
raw = bundle.getDouble(Intents.EXTRA_RAW, 0.0),
|
raw = bundle.getDouble(Intents.EXTRA_RAW, 0.0),
|
||||||
noise = null,
|
noise = null,
|
||||||
trendArrow = GlucoseValue.TrendArrow.fromString(bundle.getString(Intents.EXTRA_BG_SLOPE_NAME)),
|
trendArrow = GlucoseValue.TrendArrow.fromString(bundle.getString(Intents.EXTRA_BG_SLOPE_NAME)),
|
||||||
sourceSensor = GlucoseValue.SourceSensor.fromString(bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION)
|
sourceSensor = GlucoseValue.SourceSensor.fromString(
|
||||||
?: "")
|
bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION)
|
||||||
|
?: ""
|
||||||
|
)
|
||||||
)
|
)
|
||||||
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
||||||
.doOnError {
|
.doOnError {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.interfaces.source.DexcomBoyda
|
import info.nightscout.interfaces.source.DexcomBoyda
|
||||||
import info.nightscout.interfaces.source.NSClientSource
|
import info.nightscout.interfaces.source.NSClientSource
|
||||||
import info.nightscout.interfaces.source.XDrip
|
import info.nightscout.interfaces.source.XDripSource
|
||||||
import info.nightscout.source.AidexPlugin
|
import info.nightscout.source.AidexPlugin
|
||||||
import info.nightscout.source.BGSourceFragment
|
import info.nightscout.source.BGSourceFragment
|
||||||
import info.nightscout.source.DexcomPlugin
|
import info.nightscout.source.DexcomPlugin
|
||||||
|
@ -45,6 +45,6 @@ abstract class SourceModule {
|
||||||
|
|
||||||
@Binds fun bindNSClientSource(nsClientSourcePlugin: NSClientSourcePlugin): NSClientSource
|
@Binds fun bindNSClientSource(nsClientSourcePlugin: NSClientSourcePlugin): NSClientSource
|
||||||
@Binds fun bindDexcomBoyda(dexcomPlugin: DexcomPlugin): DexcomBoyda
|
@Binds fun bindDexcomBoyda(dexcomPlugin: DexcomPlugin): DexcomBoyda
|
||||||
@Binds fun bindXDrip(xdripSourcePlugin: XdripSourcePlugin): XDrip
|
@Binds fun bindXDrip(xdripSourcePlugin: XdripSourcePlugin): XDripSource
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ class GlimpPluginTest : TestBase() {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
glimpPlugin = GlimpPlugin({ AndroidInjector { } }, rh, aapsLogger, sp)
|
glimpPlugin = GlimpPlugin({ AndroidInjector { } }, rh, aapsLogger)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun advancedFilteringSupported() {
|
@Test fun advancedFilteringSupported() {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.source
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
@ -14,11 +13,10 @@ class MM640GPluginTest : TestBase() {
|
||||||
private lateinit var mM640gPlugin: MM640gPlugin
|
private lateinit var mM640gPlugin: MM640gPlugin
|
||||||
|
|
||||||
@Mock lateinit var rh: ResourceHelper
|
@Mock lateinit var rh: ResourceHelper
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
mM640gPlugin = MM640gPlugin({ AndroidInjector { } }, rh, aapsLogger, sp)
|
mM640gPlugin = MM640gPlugin({ AndroidInjector { } }, rh, aapsLogger)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun advancedFilteringSupported() {
|
@Test fun advancedFilteringSupported() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import info.nightscout.core.utils.waitMillis
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.source.NSClientSource
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.plugins.sync.R
|
import info.nightscout.plugins.sync.R
|
||||||
|
@ -74,6 +75,9 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private var running = false
|
private var running = false
|
||||||
private val sync = Any()
|
private val sync = Any()
|
||||||
|
|
||||||
|
private val bgUploadEnabled get() = sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false) && activePlugin.activeBgSource !is NSClientSource
|
||||||
|
|
||||||
override suspend fun doUpload() {
|
override suspend fun doUpload() {
|
||||||
synchronized(sync) {
|
synchronized(sync) {
|
||||||
if (running) {
|
if (running) {
|
||||||
|
@ -154,7 +158,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastBolusIdIfGreater(lastSynced: Long) {
|
private fun confirmLastBolusIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_bolus_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_bolus_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting Bolus data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_bolus_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_bolus_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +206,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastCarbsIdIfGreater(lastSynced: Long) {
|
private fun confirmLastCarbsIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_carbs_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_carbs_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting Carbs data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_carbs_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_carbs_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +254,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastBolusCalculatorResultsIdIfGreater(lastSynced: Long) {
|
private fun confirmLastBolusCalculatorResultsIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_bolus_calculator_result_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_bolus_calculator_result_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting BolusCalculatorResult data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_bolus_calculator_result_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_bolus_calculator_result_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +302,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastTempTargetsIdIfGreater(lastSynced: Long) {
|
private fun confirmLastTempTargetsIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_temporary_target_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_temporary_target_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting TemporaryTarget data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_temporary_target_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_temporary_target_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastFoodIdIfGreater(lastSynced: Long) {
|
private fun confirmLastFoodIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_food_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_food_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting Food data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_food_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_food_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,7 +398,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastGlucoseValueIdIfGreater(lastSynced: Long) {
|
private fun confirmLastGlucoseValueIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_glucose_value_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_glucose_value_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting GlucoseValue data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_glucose_value_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_glucose_value_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,7 +417,7 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
appRepository.getNextSyncElementGlucoseValue(startId).blockingGet()?.let { gv ->
|
appRepository.getNextSyncElementGlucoseValue(startId).blockingGet()?.let { gv ->
|
||||||
aapsLogger.info(LTag.NSCLIENT, "Loading GlucoseValue data Start: $startId ${gv.first} forID: ${gv.second.id} ")
|
aapsLogger.info(LTag.NSCLIENT, "Loading GlucoseValue data Start: $startId ${gv.first} forID: ${gv.second.id} ")
|
||||||
val dataPair = DataSyncSelector.PairGlucoseValue(gv.first, gv.second.id)
|
val dataPair = DataSyncSelector.PairGlucoseValue(gv.first, gv.second.id)
|
||||||
if (activePlugin.activeBgSource.shouldUploadToNs(gv.first)) {
|
if (bgUploadEnabled) {
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
gv.first.id == gv.second.id && gv.first.interfaceIDs.nightscoutId != null ->
|
gv.first.id == gv.second.id && gv.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -450,7 +448,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastTherapyEventIdIfGreater(lastSynced: Long) {
|
private fun confirmLastTherapyEventIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_therapy_event_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_therapy_event_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting TherapyEvents data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_therapy_event_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_therapy_event_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,7 +496,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastDeviceStatusIdIfGreater(lastSynced: Long) {
|
private fun confirmLastDeviceStatusIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_device_status_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_device_status_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting DeviceStatus data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_device_status_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_device_status_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +527,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastTemporaryBasalIdIfGreater(lastSynced: Long) {
|
private fun confirmLastTemporaryBasalIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_temporary_basal_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_temporary_basal_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting TemporaryBasal data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_temporary_basal_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_temporary_basal_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,7 +578,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastExtendedBolusIdIfGreater(lastSynced: Long) {
|
private fun confirmLastExtendedBolusIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_extended_bolus_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_extended_bolus_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting ExtendedBolus data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_extended_bolus_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_extended_bolus_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,7 +629,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastProfileSwitchIdIfGreater(lastSynced: Long) {
|
private fun confirmLastProfileSwitchIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_profile_switch_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_profile_switch_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting ProfileSwitch data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_profile_switch_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_profile_switch_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -684,7 +677,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastEffectiveProfileSwitchIdIfGreater(lastSynced: Long) {
|
private fun confirmLastEffectiveProfileSwitchIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_effective_profile_switch_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_effective_profile_switch_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting EffectiveProfileSwitch data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_effective_profile_switch_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_effective_profile_switch_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -733,7 +725,6 @@ class DataSyncSelectorV1 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastOfflineEventIdIfGreater(lastSynced: Long) {
|
private fun confirmLastOfflineEventIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_offline_event_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_offline_event_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting OfflineEvent data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_offline_event_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_offline_event_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import info.nightscout.interfaces.plugin.PluginDescription
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
import info.nightscout.interfaces.source.DoingOwnUploadSource
|
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.sync.NsClient
|
import info.nightscout.interfaces.sync.NsClient
|
||||||
import info.nightscout.interfaces.sync.Sync
|
import info.nightscout.interfaces.sync.Sync
|
||||||
|
@ -129,9 +128,6 @@ class NSClientPlugin @Inject constructor(
|
||||||
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false
|
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false
|
||||||
}
|
}
|
||||||
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode()
|
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode()
|
||||||
if (activePlugin.activeBgSource is DoingOwnUploadSource) {
|
|
||||||
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_do_ns_upload))?.isVisible = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val hasWritePermission: Boolean get() = nsClientService?.hasWriteAuth ?: false
|
override val hasWritePermission: Boolean get() = nsClientService?.hasWriteAuth ?: false
|
||||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.nsclient.StoreDataForDb
|
import info.nightscout.interfaces.nsclient.StoreDataForDb
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.source.NSClientSource
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.plugins.sync.R
|
import info.nightscout.plugins.sync.R
|
||||||
|
@ -70,6 +71,8 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
override fun queueSize(): Long = queueCounter.size()
|
override fun queueSize(): Long = queueCounter.size()
|
||||||
|
|
||||||
|
private val bgUploadEnabled get() = sp.getBoolean(info.nightscout.core.utils.R.string.key_do_ns_upload, false) && activePlugin.activeBgSource !is NSClientSource
|
||||||
|
|
||||||
override suspend fun doUpload() {
|
override suspend fun doUpload() {
|
||||||
rxBus.send(EventNSClientUpdateGuiStatus())
|
rxBus.send(EventNSClientUpdateGuiStatus())
|
||||||
if ((config.NSCLIENT || sp.getBoolean(R.string.key_ns_upload, true)) && !isPaused) {
|
if ((config.NSCLIENT || sp.getBoolean(R.string.key_ns_upload, true)) && !isPaused) {
|
||||||
|
@ -128,7 +131,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastBolusIdIfGreater(lastSynced: Long) {
|
private fun confirmLastBolusIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_bolus_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_bolus_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting Bolus data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_bolus_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_bolus_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +149,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.bolusesRemaining = lastDbId - startId
|
queueCounter.bolusesRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementBolus(startId).blockingGet()?.let { bolus ->
|
appRepository.getNextSyncElementBolus(startId).blockingGet()?.let { bolus ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading Bolus data Start: $startId ${bolus.first} forID: ${bolus.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
bolus.first.id == bolus.second.id && bolus.first.interfaceIDs.nightscoutId != null ->
|
bolus.first.id == bolus.second.id && bolus.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -171,7 +172,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastCarbsIdIfGreater(lastSynced: Long) {
|
private fun confirmLastCarbsIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_carbs_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_carbs_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting Carbs data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_carbs_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_carbs_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.carbsRemaining = lastDbId - startId
|
queueCounter.carbsRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementCarbs(startId).blockingGet()?.let { carb ->
|
appRepository.getNextSyncElementCarbs(startId).blockingGet()?.let { carb ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading Carbs data Start: $startId ${carb.first} forID: ${carb.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
carb.first.id == carb.second.id && carb.first.interfaceIDs.nightscoutId != null ->
|
carb.first.id == carb.second.id && carb.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -214,7 +213,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastBolusCalculatorResultsIdIfGreater(lastSynced: Long) {
|
private fun confirmLastBolusCalculatorResultsIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_bolus_calculator_result_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_bolus_calculator_result_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting BolusCalculatorResult data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_bolus_calculator_result_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_bolus_calculator_result_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,7 +231,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.bcrRemaining = lastDbId - startId
|
queueCounter.bcrRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementBolusCalculatorResult(startId).blockingGet()?.let { bolusCalculatorResult ->
|
appRepository.getNextSyncElementBolusCalculatorResult(startId).blockingGet()?.let { bolusCalculatorResult ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading BolusCalculatorResult data Start: $startId ${bolusCalculatorResult.first} forID: ${bolusCalculatorResult.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
bolusCalculatorResult.first.id == bolusCalculatorResult.second.id && bolusCalculatorResult.first.interfaceIDs.nightscoutId != null ->
|
bolusCalculatorResult.first.id == bolusCalculatorResult.second.id && bolusCalculatorResult.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -265,7 +262,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastTempTargetsIdIfGreater(lastSynced: Long) {
|
private fun confirmLastTempTargetsIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_temporary_target_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_temporary_target_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting TemporaryTarget data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_temporary_target_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_temporary_target_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +280,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.ttsRemaining = lastDbId - startId
|
queueCounter.ttsRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementTemporaryTarget(startId).blockingGet()?.let { tt ->
|
appRepository.getNextSyncElementTemporaryTarget(startId).blockingGet()?.let { tt ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading TemporaryTarget data Start: $startId ${tt.first} forID: ${tt.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
tt.first.id == tt.second.id && tt.first.interfaceIDs.nightscoutId != null ->
|
tt.first.id == tt.second.id && tt.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -308,7 +303,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastFoodIdIfGreater(lastSynced: Long) {
|
private fun confirmLastFoodIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_food_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_food_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting Food data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_food_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_food_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +321,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.foodsRemaining = lastDbId - startId
|
queueCounter.foodsRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementFood(startId).blockingGet()?.let { food ->
|
appRepository.getNextSyncElementFood(startId).blockingGet()?.let { food ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading Food data Start: $startId ${food.first} forID: ${food.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
food.first.id == food.second.id && food.first.interfaceIDs.nightscoutId != null ->
|
food.first.id == food.second.id && food.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -351,7 +344,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastGlucoseValueIdIfGreater(lastSynced: Long) {
|
private fun confirmLastGlucoseValueIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_glucose_value_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_glucose_value_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting GlucoseValue data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_glucose_value_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_glucose_value_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,8 +362,7 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.gvsRemaining = lastDbId - startId
|
queueCounter.gvsRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementGlucoseValue(startId).blockingGet()?.let { gv ->
|
appRepository.getNextSyncElementGlucoseValue(startId).blockingGet()?.let { gv ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading GlucoseValue data Start: $startId ${gv.first} forID: ${gv.second.id} ")
|
if (bgUploadEnabled) {
|
||||||
if (activePlugin.activeBgSource.shouldUploadToNs(gv.first)) {
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
gv.first.id == gv.second.id && gv.first.interfaceIDs.nightscoutId != null ->
|
gv.first.id == gv.second.id && gv.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -396,7 +387,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastTherapyEventIdIfGreater(lastSynced: Long) {
|
private fun confirmLastTherapyEventIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_therapy_event_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_therapy_event_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting TherapyEvents data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_therapy_event_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_therapy_event_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +405,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.tesRemaining = lastDbId - startId
|
queueCounter.tesRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementTherapyEvent(startId).blockingGet()?.let { te ->
|
appRepository.getNextSyncElementTherapyEvent(startId).blockingGet()?.let { te ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading TherapyEvents data Start: $startId ${te.first} forID: ${te.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
te.first.id == te.second.id && te.first.interfaceIDs.nightscoutId != null ->
|
te.first.id == te.second.id && te.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -439,7 +428,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastDeviceStatusIdIfGreater(lastSynced: Long) {
|
private fun confirmLastDeviceStatusIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_device_status_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_device_status_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting DeviceStatus data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_device_status_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_device_status_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,7 +446,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.dssRemaining = lastDbId - startId
|
queueCounter.dssRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementDeviceStatus(startId).blockingGet()?.let { deviceStatus ->
|
appRepository.getNextSyncElementDeviceStatus(startId).blockingGet()?.let { deviceStatus ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading DeviceStatus data Start: $startId $deviceStatus")
|
|
||||||
cont = activePlugin.activeNsClient?.nsAdd("devicestatus", DataSyncSelector.PairDeviceStatus(deviceStatus, lastDbId), "$startId/$lastDbId") ?: false
|
cont = activePlugin.activeNsClient?.nsAdd("devicestatus", DataSyncSelector.PairDeviceStatus(deviceStatus, lastDbId), "$startId/$lastDbId") ?: false
|
||||||
if (cont) confirmLastDeviceStatusIdIfGreater(deviceStatus.id)
|
if (cont) confirmLastDeviceStatusIdIfGreater(deviceStatus.id)
|
||||||
// with nsId = ignore
|
// with nsId = ignore
|
||||||
|
@ -470,7 +457,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastTemporaryBasalIdIfGreater(lastSynced: Long) {
|
private fun confirmLastTemporaryBasalIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_temporary_basal_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_temporary_basal_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting TemporaryBasal data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_temporary_basal_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_temporary_basal_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,7 +476,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementTemporaryBasal(startId).blockingGet()?.let { tb ->
|
appRepository.getNextSyncElementTemporaryBasal(startId).blockingGet()?.let { tb ->
|
||||||
val profile = profileFunction.getProfile(tb.first.timestamp)
|
val profile = profileFunction.getProfile(tb.first.timestamp)
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading TemporaryBasal data Start: $startId ${tb.first} forID: ${tb.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
tb.first.id == tb.second.id && tb.first.interfaceIDs.nightscoutId != null ->
|
tb.first.id == tb.second.id && tb.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -514,7 +499,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastExtendedBolusIdIfGreater(lastSynced: Long) {
|
private fun confirmLastExtendedBolusIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_extended_bolus_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_extended_bolus_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting ExtendedBolus data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_extended_bolus_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_extended_bolus_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,7 +517,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.ebsRemaining = lastDbId - startId
|
queueCounter.ebsRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementExtendedBolus(startId).blockingGet()?.let { eb ->
|
appRepository.getNextSyncElementExtendedBolus(startId).blockingGet()?.let { eb ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading ExtendedBolus data Start: $startId ${eb.first} forID: ${eb.second.id} ")
|
|
||||||
val profile = profileFunction.getProfile(eb.first.timestamp)
|
val profile = profileFunction.getProfile(eb.first.timestamp)
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
when {
|
when {
|
||||||
|
@ -560,7 +543,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastProfileSwitchIdIfGreater(lastSynced: Long) {
|
private fun confirmLastProfileSwitchIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_profile_switch_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_profile_switch_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting ProfileSwitch data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_profile_switch_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_profile_switch_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +561,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.pssRemaining = lastDbId - startId
|
queueCounter.pssRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementProfileSwitch(startId).blockingGet()?.let { ps ->
|
appRepository.getNextSyncElementProfileSwitch(startId).blockingGet()?.let { ps ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading ProfileSwitch data Start: $startId ${ps.first} forID: ${ps.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null ->
|
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -603,7 +584,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastEffectiveProfileSwitchIdIfGreater(lastSynced: Long) {
|
private fun confirmLastEffectiveProfileSwitchIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_effective_profile_switch_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_effective_profile_switch_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting EffectiveProfileSwitch data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_effective_profile_switch_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_effective_profile_switch_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,7 +602,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.epssRemaining = lastDbId - startId
|
queueCounter.epssRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementEffectiveProfileSwitch(startId).blockingGet()?.let { ps ->
|
appRepository.getNextSyncElementEffectiveProfileSwitch(startId).blockingGet()?.let { ps ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading EffectiveProfileSwitch data Start: $startId ${ps.first} forID: ${ps.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null ->
|
ps.first.id == ps.second.id && ps.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
@ -646,7 +625,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
|
|
||||||
private fun confirmLastOfflineEventIdIfGreater(lastSynced: Long) {
|
private fun confirmLastOfflineEventIdIfGreater(lastSynced: Long) {
|
||||||
if (lastSynced > sp.getLong(R.string.key_ns_offline_event_last_synced_id, 0)) {
|
if (lastSynced > sp.getLong(R.string.key_ns_offline_event_last_synced_id, 0)) {
|
||||||
//aapsLogger.debug(LTag.NSCLIENT, "Setting OfflineEvent data sync from $lastSynced")
|
|
||||||
sp.putLong(R.string.key_ns_offline_event_last_synced_id, lastSynced)
|
sp.putLong(R.string.key_ns_offline_event_last_synced_id, lastSynced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,7 +643,6 @@ class DataSyncSelectorV3 @Inject constructor(
|
||||||
queueCounter.oesRemaining = lastDbId - startId
|
queueCounter.oesRemaining = lastDbId - startId
|
||||||
rxBus.send(EventNSClientUpdateGuiQueue())
|
rxBus.send(EventNSClientUpdateGuiQueue())
|
||||||
appRepository.getNextSyncElementOfflineEvent(startId).blockingGet()?.let { oe ->
|
appRepository.getNextSyncElementOfflineEvent(startId).blockingGet()?.let { oe ->
|
||||||
//aapsLogger.info(LTag.NSCLIENT, "Loading OfflineEvent data Start: $startId ${oe.first} forID: ${oe.second.id} ")
|
|
||||||
when {
|
when {
|
||||||
// new record with existing NS id => must be coming from NS => ignore
|
// new record with existing NS id => must be coming from NS => ignore
|
||||||
oe.first.id == oe.second.id && oe.first.interfaceIDs.nightscoutId != null ->
|
oe.first.id == oe.second.id && oe.first.interfaceIDs.nightscoutId != null ->
|
||||||
|
|
Loading…
Add table
Reference in a new issue