ComboV2: remove core dependency
This commit is contained in:
parent
681fe52d80
commit
c6d01f10bd
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
||||||
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
|
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.combov2.ComboV2Plugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
|
@ -60,6 +59,7 @@ import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatus
|
||||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||||
import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
|
import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
|
||||||
import info.nightscout.pump.combo.ComboPlugin
|
import info.nightscout.pump.combo.ComboPlugin
|
||||||
|
import info.nightscout.pump.combov2.ComboV2Plugin
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventPreferenceChange
|
import info.nightscout.rx.events.EventPreferenceChange
|
||||||
import info.nightscout.rx.events.EventRebuildTabs
|
import info.nightscout.rx.events.EventRebuildTabs
|
||||||
|
|
|
@ -5,7 +5,6 @@ import dagger.Component
|
||||||
import dagger.android.AndroidInjectionModule
|
import dagger.android.AndroidInjectionModule
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.combov2.di.ComboV2Module
|
|
||||||
import info.nightscout.androidaps.dana.di.DanaHistoryModule
|
import info.nightscout.androidaps.dana.di.DanaHistoryModule
|
||||||
import info.nightscout.androidaps.dana.di.DanaModule
|
import info.nightscout.androidaps.dana.di.DanaModule
|
||||||
import info.nightscout.androidaps.danar.di.DanaRModule
|
import info.nightscout.androidaps.danar.di.DanaRModule
|
||||||
|
@ -28,6 +27,7 @@ import info.nightscout.implementation.di.ImplementationModule
|
||||||
import info.nightscout.plugins.aps.di.ApsModule
|
import info.nightscout.plugins.aps.di.ApsModule
|
||||||
import info.nightscout.plugins.di.PluginsModule
|
import info.nightscout.plugins.di.PluginsModule
|
||||||
import info.nightscout.pump.combo.di.ComboModule
|
import info.nightscout.pump.combo.di.ComboModule
|
||||||
|
import info.nightscout.pump.combov2.di.ComboV2Module
|
||||||
import info.nightscout.rx.di.RxModule
|
import info.nightscout.rx.di.RxModule
|
||||||
import info.nightscout.shared.di.SharedModule
|
import info.nightscout.shared.di.SharedModule
|
||||||
import info.nightscout.shared.impl.di.SharedImplModule
|
import info.nightscout.shared.impl.di.SharedImplModule
|
||||||
|
|
|
@ -14,7 +14,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin
|
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.combov2.ComboV2Plugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
|
@ -63,6 +62,7 @@ import info.nightscout.plugins.sync.nsclient.NSClientPlugin
|
||||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||||
import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
|
import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
|
||||||
import info.nightscout.pump.combo.ComboPlugin
|
import info.nightscout.pump.combo.ComboPlugin
|
||||||
|
import info.nightscout.pump.combov2.ComboV2Plugin
|
||||||
import info.nightscout.sensitivity.SensitivityAAPSPlugin
|
import info.nightscout.sensitivity.SensitivityAAPSPlugin
|
||||||
import info.nightscout.sensitivity.SensitivityOref1Plugin
|
import info.nightscout.sensitivity.SensitivityOref1Plugin
|
||||||
import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin
|
import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
|
|
|
@ -1,55 +1,11 @@
|
||||||
package info.nightscout.core.pump
|
package info.nightscout.core.pump
|
||||||
|
|
||||||
import info.nightscout.interfaces.profile.Profile
|
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.utils.DecimalFormatter
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import info.nightscout.shared.utils.T
|
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
val PumpSync.PumpState.TemporaryBasal.plannedRemainingMinutesRoundedUp: Int
|
val PumpSync.PumpState.TemporaryBasal.plannedRemainingMinutesRoundedUp: Int
|
||||||
get() = max(ceil((end - System.currentTimeMillis()) / 1000.0 / 60).toInt(), 0)
|
get() = max(ceil((end - System.currentTimeMillis()) / 1000.0 / 60).toInt(), 0)
|
||||||
|
|
||||||
val PumpSync.PumpState.TemporaryBasal.durationInMinutes: Int
|
|
||||||
get() = T.msecs(duration).mins().toInt()
|
|
||||||
|
|
||||||
fun PumpSync.PumpState.TemporaryBasal.getPassedDurationToTimeInMinutes(time: Long): Int =
|
|
||||||
((min(time, end) - timestamp) / 60.0 / 1000).roundToInt()
|
|
||||||
|
|
||||||
fun PumpSync.PumpState.TemporaryBasal.convertedToAbsolute(time: Long, profile: Profile): Double =
|
|
||||||
if (isAbsolute) rate
|
|
||||||
else profile.getBasal(time) * rate / 100
|
|
||||||
|
|
||||||
fun PumpSync.PumpState.TemporaryBasal.toStringFull(dateUtil: DateUtil): String {
|
|
||||||
return when {
|
|
||||||
isAbsolute -> {
|
|
||||||
DecimalFormatter.to2Decimal(rate) + "U/h @" +
|
|
||||||
dateUtil.timeString(timestamp) +
|
|
||||||
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> { // percent
|
|
||||||
rate.toString() + "% @" +
|
|
||||||
dateUtil.timeString(timestamp) +
|
|
||||||
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val PumpSync.PumpState.ExtendedBolus.end: Long
|
|
||||||
get() = timestamp + duration
|
|
||||||
|
|
||||||
val PumpSync.PumpState.ExtendedBolus.plannedRemainingMinutes: Long
|
|
||||||
get() = max(T.msecs(end - System.currentTimeMillis()).mins(), 0L)
|
|
||||||
|
|
||||||
fun PumpSync.PumpState.ExtendedBolus.getPassedDurationToTimeInMinutes(time: Long): Int =
|
|
||||||
((min(time, end) - timestamp) / 60.0 / 1000).roundToInt()
|
|
||||||
|
|
||||||
fun PumpSync.PumpState.ExtendedBolus.toStringFull(dateUtil: DateUtil): String =
|
|
||||||
"E " + DecimalFormatter.to2Decimal(rate) + "U/h @" +
|
|
||||||
dateUtil.timeString(timestamp) +
|
|
||||||
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min"
|
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
<string name="tempbasaldeliveryerror">Tempbasal delivery error</string>
|
<string name="tempbasaldeliveryerror">Tempbasal delivery error</string>
|
||||||
<string name="goingtodeliver">Going to deliver %1$.2f U</string>
|
<string name="goingtodeliver">Going to deliver %1$.2f U</string>
|
||||||
<string name="waitingforpump">Waiting for pump</string>
|
<string name="waitingforpump">Waiting for pump</string>
|
||||||
<string name="connecting">Connecting</string>
|
|
||||||
<string name="disconnected">Disconnected</string>
|
|
||||||
<string name="androidaps_start">AAPS started</string>
|
<string name="androidaps_start">AAPS started</string>
|
||||||
<string name="formatsignedinsulinunits">%1$+.2f U</string>
|
<string name="formatsignedinsulinunits">%1$+.2f U</string>
|
||||||
<string name="format_carbs">%1$d g</string>
|
<string name="format_carbs">%1$d g</string>
|
||||||
|
@ -446,7 +444,6 @@
|
||||||
<string name="unconfirmed_command" comment="26 characters max for translation">Unconfirmed command</string>
|
<string name="unconfirmed_command" comment="26 characters max for translation">Unconfirmed command</string>
|
||||||
<string name="requested_by_user" comment="26 characters max for translation">Requested by user</string>
|
<string name="requested_by_user" comment="26 characters max for translation">Requested by user</string>
|
||||||
<string name="bolus_ok" comment="26 characters max for translation">Bolus OK</string>
|
<string name="bolus_ok" comment="26 characters max for translation">Bolus OK</string>
|
||||||
<string name="pump_paired" comment="26 characters max for translation">Pump paired</string>
|
|
||||||
<string name="insight_refresh_button" comment="26 characters max for translation">Insight Refresh Button</string>
|
<string name="insight_refresh_button" comment="26 characters max for translation">Insight Refresh Button</string>
|
||||||
<string name="formatPercent">%1$.0f%%</string>
|
<string name="formatPercent">%1$.0f%%</string>
|
||||||
<string name="basal">Basal</string>
|
<string name="basal">Basal</string>
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package info.nightscout.core.ui.activities
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import dagger.android.support.DaggerAppCompatActivity
|
||||||
|
import info.nightscout.core.ui.R
|
||||||
|
|
||||||
|
open class PluginNoSplashAppCompatActivity : DaggerAppCompatActivity() {
|
||||||
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar)
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ class BluetoothDevicePreference @JvmOverloads constructor(context: Context, attr
|
||||||
} else {
|
} else {
|
||||||
entries = emptyArray()
|
entries = emptyArray()
|
||||||
entryValues = emptyArray()
|
entryValues = emptyArray()
|
||||||
ToastUtils.errorToast(context, context.getString(R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,8 @@
|
||||||
<string name="tempbasal_label">Temp basal</string>
|
<string name="tempbasal_label">Temp basal</string>
|
||||||
<string name="extended_bolus_label">Extended bolus</string>
|
<string name="extended_bolus_label">Extended bolus</string>
|
||||||
<string name="serial_number">Serial number</string>
|
<string name="serial_number">Serial number</string>
|
||||||
|
<string name="disconnected">Disconnected</string>
|
||||||
|
<string name="connecting">Connecting</string>
|
||||||
|
|
||||||
<!-- Locale -->
|
<!-- Locale -->
|
||||||
<string name="key_language" translatable="false">language</string>
|
<string name="key_language" translatable="false">language</string>
|
||||||
|
@ -55,9 +57,10 @@
|
||||||
<string name="event_time_label">Event time</string>
|
<string name="event_time_label">Event time</string>
|
||||||
|
|
||||||
<!-- BluetoothDevicePreference -->
|
<!-- BluetoothDevicePreference -->
|
||||||
<string name="needconnectpermission">Application needs bluetooth permission</string>
|
<string name="need_connect_permission">Application needs bluetooth permission</string>
|
||||||
|
|
||||||
<!-- Combo-->
|
<!-- Combo-->
|
||||||
<string name="user_request" comment="26 characters max for translation">User request</string>
|
<string name="user_request" comment="26 characters max for translation">User request</string>
|
||||||
|
<string name="pump_paired" comment="26 characters max for translation">Pump paired</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -111,7 +111,7 @@ class AndroidPermissionImpl @Inject constructor(
|
||||||
if (permissionNotGranted(activity, Manifest.permission.BLUETOOTH_CONNECT) || permissionNotGranted(activity, Manifest.permission.BLUETOOTH_SCAN))
|
if (permissionNotGranted(activity, Manifest.permission.BLUETOOTH_CONNECT) || permissionNotGranted(activity, Manifest.permission.BLUETOOTH_SCAN))
|
||||||
activePlugin.activeOverview.addNotification(
|
activePlugin.activeOverview.addNotification(
|
||||||
id = Notification.PERMISSION_BT,
|
id = Notification.PERMISSION_BT,
|
||||||
text = rh.gs(R.string.needconnectpermission),
|
text = rh.gs(R.string.need_connect_permission),
|
||||||
level = Notification.URGENT,
|
level = Notification.URGENT,
|
||||||
actionButtonId = R.string.request
|
actionButtonId = R.string.request
|
||||||
) { askForPermission(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT)) }
|
) { askForPermission(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT)) }
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.insight;
|
package info.nightscout.androidaps.plugins.pump.insight;
|
||||||
|
|
||||||
import static info.nightscout.core.pump.PumpStateExtensionKt.convertedToAbsolute;
|
|
||||||
import static info.nightscout.core.pump.PumpStateExtensionKt.getPlannedRemainingMinutes;
|
|
||||||
|
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
@ -966,7 +963,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
|
||||||
}
|
}
|
||||||
PumpSync.PumpState.TemporaryBasal tb = pumpSync.expectedPumpState().getTemporaryBasal();
|
PumpSync.PumpState.TemporaryBasal tb = pumpSync.expectedPumpState().getTemporaryBasal();
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", convertedToAbsolute(tb, now, profile));
|
extended.put("TempBasalAbsoluteRate", tb.convertedToAbsolute(now, profile));
|
||||||
extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.getTimestamp()));
|
extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.getTimestamp()));
|
||||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
|
@ -974,7 +971,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Insight,
|
||||||
if (eb != null) {
|
if (eb != null) {
|
||||||
extended.put("ExtendedBolusAbsoluteRate", eb.getRate());
|
extended.put("ExtendedBolusAbsoluteRate", eb.getRate());
|
||||||
extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.getTimestamp()));
|
extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.getTimestamp()));
|
||||||
extended.put("ExtendedBolusRemaining", getPlannedRemainingMinutes(eb));
|
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
extended.put("BaseBasalRate", getBaseBasalRate());
|
extended.put("BaseBasalRate", getBaseBasalRate());
|
||||||
status.put("timestamp", dateUtil.toISOString(now));
|
status.put("timestamp", dateUtil.toISOString(now));
|
||||||
|
|
|
@ -3,8 +3,12 @@ package info.nightscout.interfaces.pump
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
|
import info.nightscout.interfaces.utils.DecimalFormatter
|
||||||
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
import kotlin.math.min
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface allows pump drivers to push data changes (creation and update of treatments, temporary basals and extended boluses) back to AAPS-core.
|
* This interface allows pump drivers to push data changes (creation and update of treatments, temporary basals and extended boluses) back to AAPS-core.
|
||||||
|
@ -83,6 +87,32 @@ interface PumpSync {
|
||||||
|
|
||||||
val end: Long get() = timestamp + duration
|
val end: Long get() = timestamp + duration
|
||||||
val plannedRemainingMinutes: Long get() = max(T.msecs(end - System.currentTimeMillis()).mins(), 0L)
|
val plannedRemainingMinutes: Long get() = max(T.msecs(end - System.currentTimeMillis()).mins(), 0L)
|
||||||
|
fun convertedToAbsolute(time: Long, profile: Profile): Double =
|
||||||
|
if (isAbsolute) rate
|
||||||
|
else profile.getBasal(time) * rate / 100
|
||||||
|
|
||||||
|
fun toStringFull(dateUtil: DateUtil): String {
|
||||||
|
return when {
|
||||||
|
isAbsolute -> {
|
||||||
|
DecimalFormatter.to2Decimal(rate) + "U/h @" +
|
||||||
|
dateUtil.timeString(timestamp) +
|
||||||
|
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> { // percent
|
||||||
|
rate.toString() + "% @" +
|
||||||
|
dateUtil.timeString(timestamp) +
|
||||||
|
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val durationInMinutes: Int
|
||||||
|
get() = T.msecs(duration).mins().toInt()
|
||||||
|
|
||||||
|
private fun getPassedDurationToTimeInMinutes(time: Long): Int =
|
||||||
|
((min(time, end) - timestamp) / 60.0 / 1000).roundToInt()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ExtendedBolus @JvmOverloads constructor(
|
data class ExtendedBolus @JvmOverloads constructor(
|
||||||
|
@ -93,7 +123,20 @@ interface PumpSync {
|
||||||
// used only to cancel EB on pump change
|
// used only to cancel EB on pump change
|
||||||
val pumpType: PumpType = PumpType.USER,
|
val pumpType: PumpType = PumpType.USER,
|
||||||
val pumpSerial: String = ""
|
val pumpSerial: String = ""
|
||||||
)
|
) {
|
||||||
|
|
||||||
|
val end: Long
|
||||||
|
get() = timestamp + duration
|
||||||
|
|
||||||
|
val plannedRemainingMinutes: Long
|
||||||
|
get() = max(T.msecs(end - System.currentTimeMillis()).mins(), 0L)
|
||||||
|
private fun getPassedDurationToTimeInMinutes(time: Long): Int =
|
||||||
|
((min(time, end) - timestamp) / 60.0 / 1000).roundToInt()
|
||||||
|
fun toStringFull(dateUtil: DateUtil): String =
|
||||||
|
"E " + DecimalFormatter.to2Decimal(rate) + "U/h @" +
|
||||||
|
dateUtil.timeString(timestamp) +
|
||||||
|
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min"
|
||||||
|
}
|
||||||
|
|
||||||
data class Bolus(val timestamp: Long, val amount: Double)
|
data class Bolus(val timestamp: Long, val amount: Double)
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class TriggerBTDevice(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
|
||||||
(context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.bondedDevices?.forEach { s.add(it.name) }
|
(context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter?.bondedDevices?.forEach { s.add(it.name) }
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.errorToast(context, context.getString(R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,13 @@ apply plugin: 'kotlin-kapt'
|
||||||
apply plugin: 'kotlin-allopen'
|
apply plugin: 'kotlin-allopen'
|
||||||
apply plugin: 'com.hiya.jacoco-android'
|
apply plugin: 'com.hiya.jacoco-android'
|
||||||
|
|
||||||
apply from: "${project.rootDir}/core/core-main//android_dependencies.gradle"
|
apply from: "${project.rootDir}/core/core-main/android_dependencies.gradle"
|
||||||
apply from: "${project.rootDir}/core/core-main//android_module_dependencies.gradle"
|
apply from: "${project.rootDir}/core/core-main/android_module_dependencies.gradle"
|
||||||
apply from: "${project.rootDir}/core/core-main//test_dependencies.gradle"
|
apply from: "${project.rootDir}/core/core-main/test_dependencies.gradle"
|
||||||
apply from: "${project.rootDir}/core/core-main//jacoco_global.gradle"
|
apply from: "${project.rootDir}/core/core-main/jacoco_global.gradle"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':libraries')
|
implementation project(':libraries')
|
||||||
implementation project(':core:core-main')
|
|
||||||
implementation project(':core:ui')
|
implementation project(':core:ui')
|
||||||
implementation project(':core:utils')
|
implementation project(':core:utils')
|
||||||
implementation project(':app-wear-shared:rx')
|
implementation project(':app-wear-shared:rx')
|
||||||
|
@ -37,7 +36,7 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'info.nightscout.androidaps.combov2'
|
namespace 'info.nightscout.pump.combov2'
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
dataBinding true
|
dataBinding true
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<activity
|
<activity
|
||||||
android:name="info.nightscout.androidaps.plugins.pump.combov2.activities.ComboV2PairingActivity"
|
android:name="info.nightscout.pump.combov2.activities.ComboV2PairingActivity"
|
||||||
android:label="@string/combov2_pair_with_pump_title"
|
android:label="@string/combov2_pair_with_pump_title"
|
||||||
android:theme="@style/AppTheme" />
|
android:theme="@style/AppTheme" />
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2
|
package info.nightscout.pump.combov2
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import info.nightscout.comboctl.base.LogLevel
|
import info.nightscout.comboctl.base.LogLevel
|
||||||
import info.nightscout.comboctl.base.LoggerBackend as ComboCtlLoggerBackend
|
|
||||||
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.comboctl.base.LoggerBackend as ComboCtlLoggerBackend
|
||||||
|
|
||||||
internal class AAPSComboCtlLogger(private val aapsLogger: AAPSLogger) : ComboCtlLoggerBackend {
|
internal class AAPSComboCtlLogger(private val aapsLogger: AAPSLogger) : ComboCtlLoggerBackend {
|
||||||
override fun log(tag: String, level: LogLevel, throwable: Throwable?, message: String?) {
|
override fun log(tag: String, level: LogLevel, throwable: Throwable?, message: String?) {
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2
|
package info.nightscout.pump.combov2
|
||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -10,12 +10,11 @@ import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.combov2.R
|
|
||||||
import info.nightscout.androidaps.combov2.databinding.Combov2FragmentBinding
|
|
||||||
import info.nightscout.comboctl.base.NullDisplayFrame
|
import info.nightscout.comboctl.base.NullDisplayFrame
|
||||||
import info.nightscout.comboctl.parser.BatteryState
|
import info.nightscout.comboctl.parser.BatteryState
|
||||||
import info.nightscout.comboctl.parser.ReservoirState
|
import info.nightscout.comboctl.parser.ReservoirState
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
import info.nightscout.pump.combov2.databinding.Combov2FragmentBinding
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
@ -62,13 +61,13 @@ class ComboV2Fragment : DaggerFragment() {
|
||||||
combov2Plugin.driverStateUIFlow
|
combov2Plugin.driverStateUIFlow
|
||||||
.onEach { connectionState ->
|
.onEach { connectionState ->
|
||||||
val text = when (connectionState) {
|
val text = when (connectionState) {
|
||||||
ComboV2Plugin.DriverState.NotInitialized -> rh.gs(R.string.combov2_not_initialized)
|
ComboV2Plugin.DriverState.NotInitialized -> rh.gs(R.string.combov2_not_initialized)
|
||||||
ComboV2Plugin.DriverState.Disconnected -> rh.gs(R.string.disconnected)
|
ComboV2Plugin.DriverState.Disconnected -> rh.gs(R.string.disconnected)
|
||||||
ComboV2Plugin.DriverState.Connecting -> rh.gs(R.string.connecting)
|
ComboV2Plugin.DriverState.Connecting -> rh.gs(R.string.connecting)
|
||||||
ComboV2Plugin.DriverState.CheckingPump -> rh.gs(R.string.combov2_checking_pump)
|
ComboV2Plugin.DriverState.CheckingPump -> rh.gs(R.string.combov2_checking_pump)
|
||||||
ComboV2Plugin.DriverState.Ready -> rh.gs(R.string.combov2_ready)
|
ComboV2Plugin.DriverState.Ready -> rh.gs(R.string.combov2_ready)
|
||||||
ComboV2Plugin.DriverState.Suspended -> rh.gs(R.string.combov2_suspended)
|
ComboV2Plugin.DriverState.Suspended -> rh.gs(R.string.combov2_suspended)
|
||||||
ComboV2Plugin.DriverState.Error -> rh.gs(R.string.error)
|
ComboV2Plugin.DriverState.Error -> rh.gs(R.string.error)
|
||||||
is ComboV2Plugin.DriverState.ExecutingCommand ->
|
is ComboV2Plugin.DriverState.ExecutingCommand ->
|
||||||
when (val desc = connectionState.description) {
|
when (val desc = connectionState.description) {
|
||||||
is ComboCtlPump.GettingBasalProfileCommandDesc ->
|
is ComboCtlPump.GettingBasalProfileCommandDesc ->
|
||||||
|
@ -101,9 +100,9 @@ class ComboV2Fragment : DaggerFragment() {
|
||||||
|
|
||||||
binding.combov2DriverState.setTextColor(
|
binding.combov2DriverState.setTextColor(
|
||||||
when (connectionState) {
|
when (connectionState) {
|
||||||
ComboV2Plugin.DriverState.Error -> Color.RED
|
ComboV2Plugin.DriverState.Error -> Color.RED
|
||||||
ComboV2Plugin.DriverState.Suspended -> Color.YELLOW
|
ComboV2Plugin.DriverState.Suspended -> Color.YELLOW
|
||||||
else -> Color.WHITE
|
else -> Color.WHITE
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2
|
package info.nightscout.pump.combov2
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -9,7 +9,6 @@ import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreference
|
import androidx.preference.SwitchPreference
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.combov2.R
|
|
||||||
import info.nightscout.comboctl.android.AndroidBluetoothInterface
|
import info.nightscout.comboctl.android.AndroidBluetoothInterface
|
||||||
import info.nightscout.comboctl.base.BasicProgressStage
|
import info.nightscout.comboctl.base.BasicProgressStage
|
||||||
import info.nightscout.comboctl.base.BluetoothException
|
import info.nightscout.comboctl.base.BluetoothException
|
||||||
|
@ -24,9 +23,6 @@ import info.nightscout.comboctl.parser.AlertScreenContent
|
||||||
import info.nightscout.comboctl.parser.AlertScreenException
|
import info.nightscout.comboctl.parser.AlertScreenException
|
||||||
import info.nightscout.comboctl.parser.BatteryState
|
import info.nightscout.comboctl.parser.BatteryState
|
||||||
import info.nightscout.comboctl.parser.ReservoirState
|
import info.nightscout.comboctl.parser.ReservoirState
|
||||||
import info.nightscout.core.events.EventNewNotification
|
|
||||||
import info.nightscout.core.pump.convertedToAbsolute
|
|
||||||
import info.nightscout.core.pump.toStringFull
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
@ -45,6 +41,7 @@ import info.nightscout.interfaces.pump.defs.ManufacturerType
|
||||||
import info.nightscout.interfaces.pump.defs.PumpDescription
|
import info.nightscout.interfaces.pump.defs.PumpDescription
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
import info.nightscout.interfaces.utils.DecimalFormatter
|
import info.nightscout.interfaces.utils.DecimalFormatter
|
||||||
import info.nightscout.interfaces.utils.TimeChangeType
|
import info.nightscout.interfaces.utils.TimeChangeType
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
@ -109,7 +106,8 @@ class ComboV2Plugin @Inject constructor (
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val pumpSync: PumpSync,
|
private val pumpSync: PumpSync,
|
||||||
private val dateUtil: DateUtil
|
private val dateUtil: DateUtil,
|
||||||
|
private val activityNames: ActivityNames
|
||||||
) :
|
) :
|
||||||
PumpPluginBase(
|
PumpPluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
|
@ -337,7 +335,7 @@ class ComboV2Plugin @Inject constructor (
|
||||||
DriverState.Connecting,
|
DriverState.Connecting,
|
||||||
DriverState.CheckingPump,
|
DriverState.CheckingPump,
|
||||||
is DriverState.ExecutingCommand -> true
|
is DriverState.ExecutingCommand -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isConnected(): Boolean =
|
override fun isConnected(): Boolean =
|
||||||
|
@ -351,7 +349,7 @@ class ComboV2Plugin @Inject constructor (
|
||||||
DriverState.Ready,
|
DriverState.Ready,
|
||||||
DriverState.Suspended,
|
DriverState.Suspended,
|
||||||
is DriverState.ExecutingCommand -> true
|
is DriverState.ExecutingCommand -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isConnecting(): Boolean =
|
override fun isConnecting(): Boolean =
|
||||||
|
@ -515,12 +513,11 @@ class ComboV2Plugin @Inject constructor (
|
||||||
val activeBasalProfileNumber = it.statusFlow.value?.activeBasalProfileNumber
|
val activeBasalProfileNumber = it.statusFlow.value?.activeBasalProfileNumber
|
||||||
aapsLogger.debug(LTag.PUMP, "Active basal profile number: $activeBasalProfileNumber")
|
aapsLogger.debug(LTag.PUMP, "Active basal profile number: $activeBasalProfileNumber")
|
||||||
if ((activeBasalProfileNumber != null) && (activeBasalProfileNumber != 1)) {
|
if ((activeBasalProfileNumber != null) && (activeBasalProfileNumber != 1)) {
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_PUMP_ALARM,
|
Notification.COMBO_PUMP_ALARM,
|
||||||
text = rh.gs(R.string.combov2_incorrect_active_basal_profile, activeBasalProfileNumber),
|
text = rh.gs(R.string.combov2_incorrect_active_basal_profile, activeBasalProfileNumber),
|
||||||
level = Notification.URGENT
|
level = Notification.URGENT
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
}
|
}
|
||||||
lastActiveBasalProfileNumber = activeBasalProfileNumber
|
lastActiveBasalProfileNumber = activeBasalProfileNumber
|
||||||
}
|
}
|
||||||
|
@ -550,12 +547,11 @@ class ComboV2Plugin @Inject constructor (
|
||||||
notifyAboutComboAlert(e.alertScreenContent)
|
notifyAboutComboAlert(e.alertScreenContent)
|
||||||
forciblyDisconnectDueToError = true
|
forciblyDisconnectDueToError = true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_PUMP_ALARM,
|
Notification.COMBO_PUMP_ALARM,
|
||||||
text = rh.gs(R.string.combov2_connection_error, e.message),
|
text = rh.gs(R.string.combov2_connection_error, e.message),
|
||||||
level = Notification.URGENT
|
level = Notification.URGENT
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
|
|
||||||
aapsLogger.error(LTag.PUMP, "Exception while connecting: ${e.stackTraceToString()}")
|
aapsLogger.error(LTag.PUMP, "Exception while connecting: ${e.stackTraceToString()}")
|
||||||
|
|
||||||
|
@ -635,12 +631,11 @@ class ComboV2Plugin @Inject constructor (
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
aapsLogger.error(LTag.PUMP, "Cannot set profile since driver is not initialized")
|
aapsLogger.error(LTag.PUMP, "Cannot set profile since driver is not initialized")
|
||||||
|
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.PROFILE_NOT_SET_NOT_INITIALIZED,
|
Notification.PROFILE_NOT_SET_NOT_INITIALIZED,
|
||||||
rh.gs(R.string.pump_not_initialized_profile_not_set),
|
rh.gs(R.string.pump_not_initialized_profile_not_set),
|
||||||
Notification.URGENT
|
Notification.URGENT
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
|
|
||||||
return PumpEnactResult(injector).apply {
|
return PumpEnactResult(injector).apply {
|
||||||
success = false
|
success = false
|
||||||
|
@ -665,13 +660,12 @@ class ComboV2Plugin @Inject constructor (
|
||||||
activeBasalProfile = requestedBasalProfile
|
activeBasalProfile = requestedBasalProfile
|
||||||
updateBaseBasalRateUI()
|
updateBaseBasalRateUI()
|
||||||
|
|
||||||
val notification = Notification(
|
activityNames.addNotificationValidFor(
|
||||||
Notification.PROFILE_SET_OK,
|
Notification.PROFILE_SET_OK,
|
||||||
rh.gs(R.string.profile_set_ok),
|
rh.gs(R.string.profile_set_ok),
|
||||||
Notification.INFO,
|
Notification.INFO,
|
||||||
60
|
60
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
|
|
||||||
pumpEnactResult.apply {
|
pumpEnactResult.apply {
|
||||||
success = true
|
success = true
|
||||||
|
@ -696,12 +690,11 @@ class ComboV2Plugin @Inject constructor (
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
aapsLogger.error("Exception thrown during basal profile update: $e")
|
aapsLogger.error("Exception thrown during basal profile update: $e")
|
||||||
|
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.FAILED_UPDATE_PROFILE,
|
Notification.FAILED_UPDATE_PROFILE,
|
||||||
rh.gs(R.string.failed_update_basal_profile),
|
rh.gs(R.string.failed_update_basal_profile),
|
||||||
Notification.URGENT
|
Notification.URGENT
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
|
|
||||||
pumpEnactResult.apply {
|
pumpEnactResult.apply {
|
||||||
success = false
|
success = false
|
||||||
|
@ -1651,21 +1644,19 @@ class ComboV2Plugin @Inject constructor (
|
||||||
|
|
||||||
when (event) {
|
when (event) {
|
||||||
is ComboCtlPump.Event.BatteryLow -> {
|
is ComboCtlPump.Event.BatteryLow -> {
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_PUMP_ALARM,
|
Notification.COMBO_PUMP_ALARM,
|
||||||
text = rh.gs(R.string.combov2_battery_low_warning),
|
text = rh.gs(R.string.combov2_battery_low_warning),
|
||||||
level = Notification.NORMAL
|
level = Notification.NORMAL
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is ComboCtlPump.Event.ReservoirLow -> {
|
is ComboCtlPump.Event.ReservoirLow -> {
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_PUMP_ALARM,
|
Notification.COMBO_PUMP_ALARM,
|
||||||
text = rh.gs(R.string.combov2_reservoir_low_warning),
|
text = rh.gs(R.string.combov2_reservoir_low_warning),
|
||||||
level = Notification.NORMAL
|
level = Notification.NORMAL
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is ComboCtlPump.Event.QuickBolusInfused -> {
|
is ComboCtlPump.Event.QuickBolusInfused -> {
|
||||||
|
@ -1756,7 +1747,7 @@ class ComboV2Plugin @Inject constructor (
|
||||||
event.remainingTbrDurationInMinutes / 60,
|
event.remainingTbrDurationInMinutes / 60,
|
||||||
event.remainingTbrDurationInMinutes % 60
|
event.remainingTbrDurationInMinutes % 60
|
||||||
)
|
)
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_UNKNOWN_TBR,
|
Notification.COMBO_UNKNOWN_TBR,
|
||||||
text = rh.gs(
|
text = rh.gs(
|
||||||
R.string.combov2_unknown_tbr_detected,
|
R.string.combov2_unknown_tbr_detected,
|
||||||
|
@ -1765,7 +1756,6 @@ class ComboV2Plugin @Inject constructor (
|
||||||
),
|
),
|
||||||
level = Notification.URGENT
|
level = Notification.URGENT
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> Unit
|
else -> Unit
|
||||||
|
@ -1900,7 +1890,7 @@ class ComboV2Plugin @Inject constructor (
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
if (updateUIState) {
|
if (updateUIState) {
|
||||||
_driverStateUIFlow.value = newState
|
_driverStateUIFlow.value = newState
|
||||||
|
@ -1909,12 +1899,11 @@ class ComboV2Plugin @Inject constructor (
|
||||||
// that the Combo is currently suspended, otherwise this
|
// that the Combo is currently suspended, otherwise this
|
||||||
// only shows up in the Combo fragment.
|
// only shows up in the Combo fragment.
|
||||||
if (newState == DriverState.Suspended) {
|
if (newState == DriverState.Suspended) {
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_PUMP_SUSPENDED,
|
Notification.COMBO_PUMP_SUSPENDED,
|
||||||
text = rh.gs(R.string.combov2_pump_is_suspended),
|
text = rh.gs(R.string.combov2_pump_is_suspended),
|
||||||
level = Notification.NORMAL
|
level = Notification.NORMAL
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1928,10 +1917,10 @@ class ComboV2Plugin @Inject constructor (
|
||||||
// TODO: Is it OK to send CONNECTED twice? It can happen when changing from Ready to Suspended.
|
// TODO: Is it OK to send CONNECTED twice? It can happen when changing from Ready to Suspended.
|
||||||
when (newState) {
|
when (newState) {
|
||||||
DriverState.Disconnected -> rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED))
|
DriverState.Disconnected -> rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED))
|
||||||
DriverState.Connecting -> rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING))
|
DriverState.Connecting -> rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING))
|
||||||
DriverState.Ready,
|
DriverState.Ready,
|
||||||
DriverState.Suspended -> rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED))
|
DriverState.Suspended -> rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED))
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1945,14 +1934,13 @@ class ComboV2Plugin @Inject constructor (
|
||||||
|
|
||||||
private fun unpairDueToPumpDataError() {
|
private fun unpairDueToPumpDataError() {
|
||||||
disconnectInternal(forceDisconnect = true)
|
disconnectInternal(forceDisconnect = true)
|
||||||
val notification = Notification(
|
activityNames.addNotificationValidTo(
|
||||||
id = Notification.PUMP_ERROR,
|
id = Notification.PUMP_ERROR,
|
||||||
date = dateUtil.now(),
|
date = dateUtil.now(),
|
||||||
text = rh.gs(R.string.combov2_cannot_access_pump_data),
|
text = rh.gs(R.string.combov2_cannot_access_pump_data),
|
||||||
level = Notification.URGENT,
|
level = Notification.URGENT,
|
||||||
validTo = 0
|
validTo = 0
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
unpair()
|
unpair()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2032,12 +2020,11 @@ class ComboV2Plugin @Inject constructor (
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyAboutComboAlert(alert: AlertScreenContent) {
|
private fun notifyAboutComboAlert(alert: AlertScreenContent) {
|
||||||
val notification = Notification(
|
activityNames.addNotification(
|
||||||
Notification.COMBO_PUMP_ALARM,
|
Notification.COMBO_PUMP_ALARM,
|
||||||
text = "${rh.gs(R.string.combov2_combo_alert)}: ${getAlertDescription(alert)}",
|
text = "${rh.gs(R.string.combov2_combo_alert)}: ${getAlertDescription(alert)}",
|
||||||
level = if (alert is AlertScreenContent.Warning) Notification.NORMAL else Notification.URGENT
|
level = if (alert is AlertScreenContent.Warning) Notification.NORMAL else Notification.URGENT
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reportFinishedBolus(status: String, pumpEnactResult: PumpEnactResult, succeeded: Boolean) {
|
private fun reportFinishedBolus(status: String, pumpEnactResult: PumpEnactResult, succeeded: Boolean) {
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2
|
package info.nightscout.pump.combov2
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2
|
package info.nightscout.pump.combov2
|
||||||
|
|
||||||
import info.nightscout.comboctl.base.BluetoothAddress
|
import info.nightscout.comboctl.base.BluetoothAddress
|
||||||
import info.nightscout.comboctl.base.CurrentTbrState
|
import info.nightscout.comboctl.base.CurrentTbrState
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2
|
package info.nightscout.pump.combov2
|
||||||
|
|
||||||
import info.nightscout.comboctl.main.BasalProfile
|
import info.nightscout.comboctl.main.BasalProfile
|
||||||
import info.nightscout.comboctl.main.NUM_COMBO_BASAL_PROFILE_FACTORS
|
import info.nightscout.comboctl.main.NUM_COMBO_BASAL_PROFILE_FACTORS
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combov2.activities
|
package info.nightscout.pump.combov2.activities
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -10,21 +10,25 @@ import androidx.databinding.DataBindingUtil
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import info.nightscout.androidaps.combov2.R
|
|
||||||
import info.nightscout.androidaps.combov2.databinding.Combov2PairingActivityBinding
|
|
||||||
import info.nightscout.androidaps.plugins.pump.combov2.ComboV2Plugin
|
|
||||||
import info.nightscout.comboctl.base.BasicProgressStage
|
import info.nightscout.comboctl.base.BasicProgressStage
|
||||||
import info.nightscout.comboctl.base.PairingPIN
|
import info.nightscout.comboctl.base.PairingPIN
|
||||||
import info.nightscout.core.activities.NoSplashAppCompatActivity
|
import info.nightscout.core.ui.activities.PluginNoSplashAppCompatActivity
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
import info.nightscout.pump.combov2.ComboV2Plugin
|
||||||
|
import info.nightscout.pump.combov2.R
|
||||||
|
import info.nightscout.pump.combov2.databinding.Combov2PairingActivityBinding
|
||||||
|
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 kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ComboV2PairingActivity : NoSplashAppCompatActivity() {
|
class ComboV2PairingActivity : PluginNoSplashAppCompatActivity() {
|
||||||
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var rh: ResourceHelper
|
||||||
@Inject lateinit var combov2Plugin: ComboV2Plugin
|
@Inject lateinit var combov2Plugin: ComboV2Plugin
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.combov2.di
|
package info.nightscout.pump.combov2.di
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.pump.combov2.ComboV2Fragment
|
import info.nightscout.pump.combov2.ComboV2Fragment
|
||||||
import info.nightscout.androidaps.plugins.pump.combov2.activities.ComboV2PairingActivity
|
import info.nightscout.pump.combov2.activities.ComboV2PairingActivity
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.combov2.di
|
package info.nightscout.pump.combov2.di
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
|
|
@ -412,7 +412,7 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<info.nightscout.androidaps.plugins.pump.combov2.ComboV2RTDisplayFrameView
|
<info.nightscout.pump.combov2.ComboV2RTDisplayFrameView
|
||||||
android:id="@+id/combov2_rt_display_frame"
|
android:id="@+id/combov2_rt_display_frame"
|
||||||
android:layout_width="192dp"
|
android:layout_width="192dp"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
android:summary="@string/combov2_pair_with_pump_summary"
|
android:summary="@string/combov2_pair_with_pump_summary"
|
||||||
android:shouldDisableView="true">
|
android:shouldDisableView="true">
|
||||||
<intent
|
<intent
|
||||||
android:targetClass="info.nightscout.androidaps.plugins.pump.combov2.activities.ComboV2PairingActivity"
|
android:targetClass="info.nightscout.pump.combov2.activities.ComboV2PairingActivity"
|
||||||
android:targetPackage="info.nightscout.androidaps" />
|
android:targetPackage="info.nightscout.androidaps" />
|
||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.dana.DanaPump;
|
||||||
import info.nightscout.androidaps.dana.comm.RecordTypes;
|
import info.nightscout.androidaps.dana.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
|
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
|
||||||
import info.nightscout.core.events.EventNewNotification;
|
import info.nightscout.core.events.EventNewNotification;
|
||||||
import info.nightscout.core.pump.PumpStateExtensionKt;
|
|
||||||
import info.nightscout.interfaces.constraints.Constraint;
|
import info.nightscout.interfaces.constraints.Constraint;
|
||||||
import info.nightscout.interfaces.constraints.Constraints;
|
import info.nightscout.interfaces.constraints.Constraints;
|
||||||
import info.nightscout.interfaces.notifications.Notification;
|
import info.nightscout.interfaces.notifications.Notification;
|
||||||
|
@ -399,14 +398,14 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
||||||
}
|
}
|
||||||
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
|
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
|
||||||
if (pumpState.getTemporaryBasal() != null) {
|
if (pumpState.getTemporaryBasal() != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", PumpStateExtensionKt.convertedToAbsolute(pumpState.getTemporaryBasal(), now, profile));
|
extended.put("TempBasalAbsoluteRate", pumpState.getTemporaryBasal().convertedToAbsolute(now, profile));
|
||||||
extended.put("TempBasalStart", dateUtil.dateAndTimeString(pumpState.getTemporaryBasal().getTimestamp()));
|
extended.put("TempBasalStart", dateUtil.dateAndTimeString(pumpState.getTemporaryBasal().getTimestamp()));
|
||||||
extended.put("TempBasalRemaining", pumpState.getTemporaryBasal().getPlannedRemainingMinutes());
|
extended.put("TempBasalRemaining", pumpState.getTemporaryBasal().getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
if (pumpState.getExtendedBolus() != null) {
|
if (pumpState.getExtendedBolus() != null) {
|
||||||
extended.put("ExtendedBolusAbsoluteRate", pumpState.getExtendedBolus().getRate());
|
extended.put("ExtendedBolusAbsoluteRate", pumpState.getExtendedBolus().getRate());
|
||||||
extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(pumpState.getExtendedBolus().getTimestamp()));
|
extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(pumpState.getExtendedBolus().getTimestamp()));
|
||||||
extended.put("ExtendedBolusRemaining", PumpStateExtensionKt.getPlannedRemainingMinutes(pumpState.getExtendedBolus()));
|
extended.put("ExtendedBolusRemaining", pumpState.getExtendedBolus().getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
extended.put("BaseBasalRate", getBaseBasalRate());
|
extended.put("BaseBasalRate", getBaseBasalRate());
|
||||||
try {
|
try {
|
||||||
|
@ -496,10 +495,10 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
||||||
}
|
}
|
||||||
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
|
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
|
||||||
if (pumpState.getTemporaryBasal() != null) {
|
if (pumpState.getTemporaryBasal() != null) {
|
||||||
ret += "Temp: " + PumpStateExtensionKt.toStringFull(pumpState.getTemporaryBasal(), dateUtil) + "\n";
|
ret += "Temp: " + pumpState.getTemporaryBasal().toStringFull(dateUtil) + "\n";
|
||||||
}
|
}
|
||||||
if (pumpState.getExtendedBolus() != null) {
|
if (pumpState.getExtendedBolus() != null) {
|
||||||
ret += "Extended: " + PumpStateExtensionKt.toStringFull(pumpState.getExtendedBolus(), dateUtil) + "\n";
|
ret += "Extended: " + pumpState.getExtendedBolus().toStringFull(dateUtil) + "\n";
|
||||||
}
|
}
|
||||||
if (!veryShort) {
|
if (!veryShort) {
|
||||||
ret += "TDD: " + DecimalFormatter.INSTANCE.to0Decimal(danaPump.getDailyTotalUnits()) + " / " + danaPump.getMaxDailyTotalUnits() + " U\n";
|
ret += "TDD: " + DecimalFormatter.INSTANCE.to0Decimal(danaPump.getDailyTotalUnits()) + " / " + danaPump.getMaxDailyTotalUnits() + " U\n";
|
||||||
|
|
|
@ -221,7 +221,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
ToastUtils.INSTANCE.errorToast(context.getApplicationContext(), R.string.devicenotfound);
|
ToastUtils.INSTANCE.errorToast(context.getApplicationContext(), R.string.devicenotfound);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.INSTANCE.errorToast(context, R.string.needconnectpermission);
|
ToastUtils.INSTANCE.errorToast(context, R.string.need_connect_permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@ import info.nightscout.androidaps.dana.comm.RecordTypes
|
||||||
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
|
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
|
||||||
import info.nightscout.androidaps.danars.services.DanaRSService
|
import info.nightscout.androidaps.danars.services.DanaRSService
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
import info.nightscout.core.pump.convertedToAbsolute
|
|
||||||
import info.nightscout.core.pump.plannedRemainingMinutes
|
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
|
|
@ -66,7 +66,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
||||||
bluetoothAdapter?.safeEnable()
|
bluetoothAdapter?.safeEnable()
|
||||||
startScan()
|
startScan()
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
||||||
} catch (ignore: IllegalStateException) {
|
} catch (ignore: IllegalStateException) {
|
||||||
} // ignore BT not on
|
} // ignore BT not on
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopScan() =
|
private fun stopScan() =
|
||||||
|
@ -92,7 +92,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
||||||
} catch (ignore: IllegalStateException) {
|
} catch (ignore: IllegalStateException) {
|
||||||
} // ignore BT not on
|
} // ignore BT not on
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
|
@ -153,7 +153,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
||||||
item.device.createBond()
|
item.device.createBond()
|
||||||
rxBus.send(EventDanaRSDeviceChange())
|
rxBus.send(EventDanaRSDeviceChange())
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ class BLEComm @Inject internal constructor(
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED
|
ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from")
|
aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange
|
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8DeviceChange
|
||||||
import info.nightscout.androidaps.diaconn.service.DiaconnG8Service
|
import info.nightscout.androidaps.diaconn.service.DiaconnG8Service
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
import info.nightscout.core.pump.convertedToAbsolute
|
|
||||||
import info.nightscout.core.pump.plannedRemainingMinutes
|
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
|
|
@ -73,7 +73,7 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() {
|
||||||
startScan()
|
startScan()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class DiaconnG8BLEScanActivity : NoSplashAppCompatActivity() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED
|
ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (device == null || device.name == null || device.name == "") {
|
if (device == null || device.name == null || device.name == "") {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class BLECommonService @Inject internal constructor(
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED
|
ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.needconnectpermission))
|
ToastUtils.errorToast(context, context.getString(info.nightscout.core.main.R.string.need_connect_permission))
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from")
|
aapsLogger.error(LTag.PUMPBTCOMM, "missing permission: $from")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.OmnipodDashOvervi
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.Constants
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.Constants
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
import info.nightscout.core.pump.convertedToAbsolute
|
|
||||||
import info.nightscout.core.pump.plannedRemainingMinutes
|
|
||||||
import info.nightscout.core.pump.toStringFull
|
|
||||||
import info.nightscout.core.utils.DateTimeUtil
|
import info.nightscout.core.utils.DateTimeUtil
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
import info.nightscout.interfaces.notifications.Notification
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.eros;
|
package info.nightscout.androidaps.plugins.pump.omnipod.eros;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants.BASAL_STEP_DURATION;
|
import static info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants.BASAL_STEP_DURATION;
|
||||||
import static info.nightscout.core.pump.PumpStateExtensionKt.convertedToAbsolute;
|
|
||||||
import static info.nightscout.core.pump.PumpStateExtensionKt.getPlannedRemainingMinutes;
|
|
||||||
import static info.nightscout.core.pump.PumpStateExtensionKt.toStringFull;
|
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -774,7 +771,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
|
|
||||||
PumpSync.PumpState.TemporaryBasal tb = pumpSync.expectedPumpState().getTemporaryBasal();
|
PumpSync.PumpState.TemporaryBasal tb = pumpSync.expectedPumpState().getTemporaryBasal();
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", convertedToAbsolute(tb, now, profile));
|
extended.put("TempBasalAbsoluteRate", tb.convertedToAbsolute(now, profile));
|
||||||
extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.getTimestamp()));
|
extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.getTimestamp()));
|
||||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
|
@ -782,7 +779,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
if (eb != null) {
|
if (eb != null) {
|
||||||
extended.put("ExtendedBolusAbsoluteRate", eb.getRate());
|
extended.put("ExtendedBolusAbsoluteRate", eb.getRate());
|
||||||
extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.getTimestamp()));
|
extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.getTimestamp()));
|
||||||
extended.put("ExtendedBolusRemaining", getPlannedRemainingMinutes(eb));
|
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
||||||
}
|
}
|
||||||
|
|
||||||
status.put("timestamp", dateUtil.toISOString(dateUtil.now()));
|
status.put("timestamp", dateUtil.toISOString(dateUtil.now()));
|
||||||
|
@ -845,10 +842,10 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
}
|
}
|
||||||
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
|
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
|
||||||
if (pumpState.getTemporaryBasal() != null && pumpState.getProfile() != null) {
|
if (pumpState.getTemporaryBasal() != null && pumpState.getProfile() != null) {
|
||||||
ret += rh.gs(R.string.omnipod_common_short_status_temp_basal, toStringFull(pumpState.getTemporaryBasal(), dateUtil) + "\n");
|
ret += rh.gs(R.string.omnipod_common_short_status_temp_basal, pumpState.getTemporaryBasal().toStringFull(dateUtil) + "\n");
|
||||||
}
|
}
|
||||||
if (pumpState.getExtendedBolus() != null) {
|
if (pumpState.getExtendedBolus() != null) {
|
||||||
ret += rh.gs(R.string.omnipod_common_short_status_extended_bolus, toStringFull(pumpState.getExtendedBolus(), dateUtil) + "\n");
|
ret += rh.gs(R.string.omnipod_common_short_status_extended_bolus, pumpState.getExtendedBolus().toStringFull(dateUtil) + "\n");
|
||||||
}
|
}
|
||||||
ret += rh.gs(R.string.omnipod_common_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.INSTANCE.to0Decimal(getReservoirLevel()))) + "\n";
|
ret += rh.gs(R.string.omnipod_common_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.INSTANCE.to0Decimal(getReservoirLevel()))) + "\n";
|
||||||
if (isUseRileyLinkBatteryLevel()) {
|
if (isUseRileyLinkBatteryLevel()) {
|
||||||
|
@ -1139,6 +1136,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("TypeParameterHidesVisibleType")
|
||||||
private <T> T executeCommand(OmnipodCommandType commandType, Supplier<T> supplier) {
|
private <T> T executeCommand(OmnipodCommandType commandType, Supplier<T> supplier) {
|
||||||
try {
|
try {
|
||||||
aapsLogger.debug(LTag.PUMP, "Executing command: {}", commandType);
|
aapsLogger.debug(LTag.PUMP, "Executing command: {}", commandType);
|
||||||
|
|
|
@ -10,9 +10,6 @@ import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState
|
||||||
import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryCarbs
|
import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryCarbs
|
||||||
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
|
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
|
||||||
import info.nightscout.core.pump.convertedToAbsolute
|
|
||||||
import info.nightscout.core.pump.plannedRemainingMinutes
|
|
||||||
import info.nightscout.core.pump.toStringFull
|
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
|
Loading…
Reference in a new issue