Merge pull request #126 from AAPS-Omnipod/omnipod_eros_dev_upstream_merge

Omnipod improvements
This commit is contained in:
Milos Kozak 2020-12-21 20:45:06 +01:00 committed by GitHub
commit 07763f7c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 201 additions and 103 deletions

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.overview
import android.graphics.Color
import android.widget.TextView
import androidx.annotation.StringRes
import info.nightscout.androidaps.Config
@ -8,6 +9,8 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.WarnColors
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -33,16 +36,28 @@ class StatusLightHandler @Inject constructor(
handleAge(careportal_canulaage, CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
handleAge(careportal_insulinage, CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
if (pump.pumpDescription.isBatteryReplaceable) {
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
}
if (!config.NSCLIENT) {
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
if (pump.model() == PumpType.Insulet_Omnipod) {
handleOmnipodReservoirLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
} else {
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
}
if (bgSource.sensorBatteryLevel != -1)
handleLevel(careportal_sensorbatterylevel, R.string.key_statuslights_sbat_critical, 5.0, R.string.key_statuslights_sbat_warning, 20.0, bgSource.sensorBatteryLevel.toDouble(), "%")
else
careportal_sensorbatterylevel?.text = ""
}
if (!config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
if (!config.NSCLIENT) {
if (pump.model() == PumpType.Insulet_Omnipod) {
handleOmnipodBatteryLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%", (pump as OmnipodPumpPlugin).isUseRileyLinkBatteryLevel)
} else if (pump.model() != PumpType.AccuChekCombo) {
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
}
}
}
private fun handleAge(view: TextView?, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
@ -64,4 +79,24 @@ class StatusLightHandler @Inject constructor(
view?.text = " " + DecimalFormatter.to0Decimal(level) + units
warnColors.setColorInverse(view, level, resWarn, resUrgent)
}
// Omnipod only reports reservoir level when it's 50 units or less, so we display "50+U" for any value > 50
private fun handleOmnipodReservoirLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String) {
if (level > OmnipodConstants.MAX_RESERVOIR_READING) {
@Suppress("SetTextI18n")
view?.text = " 50+$units"
view?.setTextColor(Color.WHITE)
} else {
handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units)
}
}
private fun handleOmnipodBatteryLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String, useRileyLinkBatteryLevel: Boolean) {
if (useRileyLinkBatteryLevel) {
handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units)
} else {
view?.text = resourceHelper.gs(R.string.notavailable)
view?.setTextColor(Color.WHITE)
}
}
}

View file

@ -73,7 +73,7 @@ public class Notification {
public static final int OMNIPOD_POD_SUSPENDED = 61;
public static final int OMNIPOD_POD_ALERTS_UPDATED = 62;
public static final int OMNIPOD_POD_ALERTS = 63;
public static final int OMNIPOD_UNCERTAIN_TBR = 64;
public static final int OMNIPOD_TBR_ALERTS = 64;
public static final int OMNIPOD_POD_FAULT = 66;
public static final int OMNIPOD_UNCERTAIN_SMB = 67;
public static final int OMNIPOD_UNKNOWN_TBR = 68;

View file

@ -75,6 +75,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.util.TimeUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged;
@ -117,6 +118,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1000L; // 3 minutes
private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1000L; // 1 minute
public static final int STARTUP_STATUS_REQUEST_TRIES = 2;
public static final double RESERVOIR_OVER_50_UNITS_DEFAULT = 75.0;
private final PodStateManager podStateManager;
private final RileyLinkServiceData rileyLinkServiceData;
@ -309,7 +311,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SMB_BEEPS_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEY_LINK_STATS_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.USE_RILEY_LINK_BATTERY_LEVEL) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED) ||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED) ||
@ -390,7 +393,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
activePlugin.getActiveTreatments().removeTempBasal(tempBasal);
}
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_UNCERTAIN_TBR));
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS));
}
private void handleActivePodAlerts() {
@ -602,15 +605,18 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return 0.0d;
}
Double reservoirLevel = podStateManager.getReservoirLevel();
return reservoirLevel == null ? 75.0 : reservoirLevel;
// Omnipod only reports reservoir level when it's 50 units or less.
// When it's over 50 units, we don't know, so return some default over 50 units
return reservoirLevel == null ? RESERVOIR_OVER_50_UNITS_DEFAULT : reservoirLevel;
}
@Override
public int getBatteryLevel() {
if (!podStateManager.isPodRunning()) {
return 0;
if (aapsOmnipodManager.isUseRileyLinkBatteryLevel()) {
return rileyLinkServiceData.batteryLevel == null ? 0 : rileyLinkServiceData.batteryLevel;
}
return 75;
return 0;
}
@NonNull @Override
@ -734,11 +740,22 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
status.put("timestamp", DateUtil.toISOString(new Date()));
pump.put("battery", battery);
if (isUseRileyLinkBatteryLevel()) {
pump.put("battery", battery);
}
pump.put("status", status);
pump.put("extended", extended);
pump.put("reservoir", getReservoirLevel());
pump.put("clock", DateUtil.toISOString(new Date()));
double reservoirLevel = getReservoirLevel();
if (reservoirLevel > OmnipodConstants.MAX_RESERVOIR_READING) {
pump.put("reservoir_display_override", "50+");
pump.put("reservoir", OmnipodConstants.MAX_RESERVOIR_READING);
} else {
pump.put("reservoir", reservoirLevel);
}
pump.put("clock", DateUtil.toISOString(podStateManager.getTime().toDate()));
} catch (JSONException e) {
aapsLogger.error(LTag.PUMP, "Unhandled exception", e);
}
@ -764,34 +781,35 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return pumpDescription;
}
// FIXME i18n, null checks: iob, TDD
@NonNull @Override
public String shortStatus(boolean veryShort) {
if (!podStateManager.isPodActivationCompleted()) {
return "No active pod";
return resourceHelper.gs(R.string.omnipod_short_status_no_active_pod);
}
String ret = "";
if (lastConnectionTimeMillis != 0) {
long agoMsec = System.currentTimeMillis() - lastConnectionTimeMillis;
int agoMin = (int) (agoMsec / 60d / 1000d);
ret += "LastConn: " + agoMin + " min ago\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_last_connection, agoMin) + "\n";
}
if (podStateManager.getLastBolusStartTime() != null) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()) + "U @" + //
android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate()) + "\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_last_bolus, DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()),
android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate())) + "\n";
}
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
ret += "Temp: " + activeTemp.toStringFull() + "\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_temp_basal, activeTemp.toStringFull()) + "\n";
}
ExtendedBolus activeExtendedBolus = activePlugin.getActiveTreatments().getExtendedBolusFromHistory(
System.currentTimeMillis());
if (activeExtendedBolus != null) {
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
ret += resourceHelper.gs(R.string.omnipod_short_status_extended_bolus, activeExtendedBolus.toString()) + "\n";
}
ret += "Reserv: " + DecimalFormatter.to0Decimal(getReservoirLevel()) + "U\n";
ret += "Batt: " + getBatteryLevel();
return ret;
ret += resourceHelper.gs(R.string.omnipod_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.to0Decimal(getReservoirLevel()))) + "\n";
if (isUseRileyLinkBatteryLevel()) {
ret += resourceHelper.gs(R.string.omnipod_short_status_rl_battery, getBatteryLevel()) + "\n";
}
return ret.trim();
}
@Override
@ -1026,6 +1044,10 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
}
public boolean isUseRileyLinkBatteryLevel() {
return aapsOmnipodManager.isUseRileyLinkBatteryLevel();
}
private void initializeAfterRileyLinkConnection() {
if (podStateManager.getActivationProgress().isAtLeast(ActivationProgress.PAIRING_COMPLETED)) {
boolean success = false;

View file

@ -21,7 +21,8 @@ public class OmnipodStorageKeys {
public static final int NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_smb_sound_enabled;
public static final int NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_bolus_sound_enabled;
public static final int AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED = R.string.key_omnipod_automatically_acknowledge_alerts_enabled;
public static final int RILEYLINK_STATS_BUTTON_ENABLED = R.string.key_omnipod_rileylink_stats_button_enabled;
public static final int RILEY_LINK_STATS_BUTTON_ENABLED = R.string.key_omnipod_riley_link_stats_button_enabled;
public static final int USE_RILEY_LINK_BATTERY_LEVEL = R.string.key_omnipod_use_riley_link_battery_level;
}
public static class Statistics {

View file

@ -120,8 +120,8 @@ public class AapsOmnipodManager {
private boolean notificationUncertainSmbSoundEnabled;
private boolean notificationUncertainBolusSoundEnabled;
private boolean automaticallyAcknowledgeAlertsEnabled;
private boolean testBeepButtonEnabled;
private boolean rileylinkStatsButtonEnabled;
private boolean useRileyLinkBatteryLevel;
@Inject
public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService,
@ -165,7 +165,8 @@ public class AapsOmnipodManager {
tbrBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TBR_BEEPS_ENABLED, false);
suspendDeliveryButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED, false);
pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false);
rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED, false);
rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEY_LINK_STATS_BUTTON_ENABLED, false);
useRileyLinkBatteryLevel = sp.getBoolean(OmnipodStorageKeys.Preferences.USE_RILEY_LINK_BATTERY_LEVEL, false);
timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true);
notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, false);
notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true);
@ -218,7 +219,6 @@ public class AapsOmnipodManager {
addToHistory(System.currentTimeMillis(), PodHistoryEntryType.INSERT_CANNULA, result.comment, result.success);
if (result.success) {
uploadCareportalEvent(System.currentTimeMillis() - 2000, CareportalEvent.PUMPBATTERYCHANGE);
uploadCareportalEvent(System.currentTimeMillis() - 1000, CareportalEvent.INSULINCHANGE);
uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE);
@ -493,7 +493,7 @@ public class AapsOmnipodManager {
String errorMessage = translateException(ex.getCause());
addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation
@ -503,7 +503,7 @@ public class AapsOmnipodManager {
long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
if (!OmnipodManager.isCertainFailure(ex)) {
showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
// Assume that setting the temp basal succeeded here, because in case it didn't succeed,
// The next StatusResponse that we receive will allow us to recover from the wrong state
@ -522,6 +522,8 @@ public class AapsOmnipodManager {
addTempBasalTreatment(System.currentTimeMillis(), pumpId, tempBasalPair);
sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS));
return new PumpEnactResult(injector)
.duration(tempBasalPair.getDurationMinutes())
.absolute(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate()))
@ -533,7 +535,7 @@ public class AapsOmnipodManager {
executeCommand(() -> delegate.cancelTemporaryBasal(isTbrBeepsEnabled()));
} catch (Exception ex) {
if (OmnipodManager.isCertainFailure(ex)) {
showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
} else {
splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation
}
@ -552,6 +554,8 @@ public class AapsOmnipodManager {
activePlugin.getActiveTreatments().addToHistoryTempBasal(tempBasal);
sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS));
return new PumpEnactResult(injector).success(true).enacted(true);
}
@ -656,14 +660,14 @@ public class AapsOmnipodManager {
return pulseLogButtonEnabled;
}
public boolean isTestBeepButtonEnabled() {
return testBeepButtonEnabled;
}
public boolean isRileylinkStatsButtonEnabled() {
return rileylinkStatsButtonEnabled;
}
public boolean isUseRileyLinkBatteryLevel() {
return useRileyLinkBatteryLevel;
}
public boolean isTimeChangeEventEnabled() {
return timeChangeEventEnabled;
}

View file

@ -10,7 +10,8 @@
<string name="key_omnipod_tbr_beeps_enabled" translatable="false">AAPS.Omnipod.tbr_beeps_enabled</string>
<string name="key_omnipod_suspend_delivery_button_enabled" translatable="false">AAPS.Omnipod.suspend_delivery_button_enabled</string>
<string name="key_omnipod_pulse_log_button_enabled" translatable="false">AAPS.Omnipod.pulse_log_button_enabled</string>
<string name="key_omnipod_rileylink_stats_button_enabled" translatable="false">AAPS.Omnipod.rileylink_stats_button_enabled</string>
<string name="key_omnipod_riley_link_stats_button_enabled" translatable="false">AAPS.Omnipod.rileylink_stats_button_enabled</string>
<string name="key_omnipod_use_riley_link_battery_level" translatable="false">AAPS.Omnipod.use_riley_link_battery_level</string>
<string name="key_omnipod_time_change_event_enabled" translatable="false">AAPS.Omnipod.time_change_enabled</string>
<string name="key_omnipod_expiration_reminder_enabled" translatable="false">AAPS.Omnipod.expiration_reminder_enabled</string>
<string name="key_omnipod_expiration_reminder_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_shutdown</string>
@ -43,6 +44,8 @@
<string name="omnipod_config_suspend_delivery_button_enabled">Show Suspend Delivery button in Omnipod tab</string>
<string name="omnipod_config_pulse_log_button_enabled">Show Pulse Log button in Pod Management menu</string>
<string name="omnipod_config_rileylink_stats_button_enabled">Show RileyLink Stats button in Pod Management menu</string>
<string name="omnipod_config_use_riley_link_battery_level">Use battery level reported by RileyLink</string>
<string name="omnipod_config_use_riley_link_battery_level_summary">Works with EmaLink and OrangeLink.\nDOES NOT work with the original RileyLink: it will not report the actual battery level. Might also not work with other RileyLink alternatives.</string>
<string name="omnipod_config_time_change_enabled">DST/Time zone detection enabled</string>
<string name="omnipod_config_expiration_reminder_enabled">Expiration reminder enabled</string>
<string name="omnipod_config_expiration_reminder_hours_before_shutdown">Hours before shutdown</string>
@ -55,7 +58,7 @@
<string name="omnipod_preference_category_rileylink">RileyLink</string>
<string name="omnipod_preference_category_other">Other</string>
<string name="omnipod_preference_category_alerts">Alerts</string>
<string name="omnipod_preference_category_confirmation_beeps">Confirmation beeps</string>
<string name="omnipod_preference_category_confirmation_beeps">Confirmation Beeps</string>
<string name="omnipod_preference_category_notifications">Notifications</string>
<!-- Omnipod - Pod Status -->
@ -64,10 +67,10 @@
<string name="omnipod_pod_status_waiting_for_cannula_insertion">Setup in progress (waiting for cannula insertion)</string>
<string name="omnipod_pod_status_running">Running</string>
<string name="omnipod_pod_status_suspended">Suspended</string>
<string name="omnipod_pod_status_pod_fault">Pod fault</string>
<string name="omnipod_pod_status_pod_fault">Pod Fault</string>
<string name="omnipod_pod_status_activation_time_exceeded">Activation time exceeded</string>
<string name="omnipod_pod_status_inactive">Inactive</string>
<string name="omnipod_pod_status_pod_fault_description">Pod fault: %1$03d %2$s</string>
<string name="omnipod_pod_status_pod_fault_description">Pod Fault: %1$03d %2$s</string>
<!-- Omnipod - Alerts -->
<string name="omnipod_alert_finish_pairing_reminder">Finish pairing reminder</string>
@ -79,7 +82,7 @@
<string name="omnipod_alert_unknown_alert">Unknown alert</string>
<!-- Omnipod - History -->
<string name="omnipod_history_title">Pod history</string>
<string name="omnipod_history_title">Pod History</string>
<string name="omnipod_history_item_description">Description</string>
<string name="omnipod_history_item_source">Source</string>
<string name="omnipod_history_item_date">Date</string>
@ -88,6 +91,15 @@
<string name="omnipod_history_bolus_value_with_carbs">%1$.2f U, CH=%2$.1f g</string>
<string name="omnipod_history_tbr_value">Rate: %1$.2f U, duration: %2$d minutes</string>
<!-- Omnipod - Short status -->
<string name="omnipod_short_status_no_active_pod">No active Pod</string>
<string name="omnipod_short_status_last_connection">LastConn: %1$d min ago</string>
<string name="omnipod_short_status_last_bolus">LastBolus: %1$s @ %2$s</string>
<string name="omnipod_short_status_temp_basal">Temp: %1$s</string>
<string name="omnipod_short_status_extended_bolus">Extended: %1$s</string>
<string name="omnipod_short_status_reservoir">Reserv: %1$sU</string>
<string name="omnipod_short_status_rl_battery">RLBatt: %1$d</string>
<!-- Omnipod - Error -->
<string name="omnipod_warning">Warning</string>
<string name="omnipod_error_rileylink_address_invalid">RileyLink address invalid.</string>
@ -115,7 +127,7 @@
<string name="omnipod_error_set_basal_failed">Setting basal profile failed.</string>
<string name="omnipod_error_cancel_temp_basal_failed_uncertain">Cancelling temp basal might have failed. Please manually refresh the Pod status from the Omnipod tab.</string>
<string name="omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled">Setting temp basal failed. If a temp basal was previously running, it might have been cancelled. Please manually refresh the Pod status from the Omnipod tab.</string>
<string name="omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed">Setting temp might have basal failed. If a temp basal was previously running, it has been cancelled. Please manually refresh the Pod status from the Omnipod tab.</string>
<string name="omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed">Setting temp basal might have basal failed. If a temp basal was previously running, it has been cancelled. Please manually refresh the Pod status from the Omnipod tab.</string>
<string name="omnipod_error_set_temp_basal_failed_validation">TBR duration must be greater than zero and a multiple of %1$s minutes.</string>
<string name="omnipod_error_set_time_failed_delivery_might_be_suspended">Setting time might have failed. Delivery might be suspended! Please manually refresh the Pod status from the Omnipod tab and resume delivery if needed.</string>
<string name="omnipod_error_set_time_failed_delivery_suspended">Setting time failed. Delivery is suspended! Please manually resume delivery from the Omnipod tab.</string>
@ -129,7 +141,7 @@
<string name="omnipod_error_failed_to_suspend_delivery">Failed to suspend delivery</string>
<string name="omnipod_error_failed_to_set_time">Failed to set time</string>
<string name="omnipod_error_failed_to_resume_delivery">Failed to resume delivery</string>
<string name="omnipod_error_automatic_time_or_timezone_change_failed">Failed to automatically change time on the Pod. You should manually synchronise the time on the Omnipod tab.</string>
<string name="omnipod_error_automatic_time_or_timezone_change_failed">Failed to automatically change time on the Pod. You should manually synchronize the time on the Omnipod tab.</string>
<string name="omnipod_error_bolus_failed_uncertain">Unable to verify whether the bolus succeeded. Please manually verify that your Pod is bolusing by listening to clicks. <b>If you are sure that the bolus didn\'t succeed, you should manually delete the bolus entry from Treatments, even if you click \'Cancel bolus\' now!</b></string>
<string name="omnipod_error_bolus_failed_uncertain_smb">Unable to verify whether SMB bolus (%1$.2f U) succeeded. <b>If you are sure that the Bolus didn\'t succeed, you should manually delete the SMB entry from Treatments.</b></string>
<string name="omnipod_error_bolus_did_not_succeed">Bolus did not succeed.</string>
@ -153,28 +165,28 @@
<!-- Omnipod - Commands -->
<string name="omnipod_cmd_deactivate_pod">Deactivate Pod</string>
<string name="omnipod_cmd_discard_pod">Discard Pod</string>
<string name="omnipod_cmd_set_bolus">Set bolus</string>
<string name="omnipod_cmd_cancel_bolus">Cancel bolus</string>
<string name="omnipod_cmd_set_tbr">Set temporary basal</string>
<string name="omnipod_cmd_cancel_tbr_by_driver">Cancel temporary basal (internally by driver)</string>
<string name="omnipod_cmd_cancel_tbr">Cancel temporary basal</string>
<string name="omnipod_cmd_set_basal_schedule">Set basal schedule</string>
<string name="omnipod_cmd_get_pod_status">Get Pod status</string>
<string name="omnipod_cmd_get_pod_info">Get Pod info</string>
<string name="omnipod_cmd_set_time">Set time</string>
<string name="omnipod_cmd_configure_alerts">Configure alerts</string>
<string name="omnipod_cmd_acknowledge_alerts">Acknowledge alerts</string>
<string name="omnipod_cmd_suspend_delivery">Suspend delivery</string>
<string name="omnipod_cmd_resume_delivery">Resume delivery</string>
<string name="omnipod_cmd_unknown_entry">Unknown entry</string>
<string name="omnipod_cmd_set_bolus">Set Bolus</string>
<string name="omnipod_cmd_cancel_bolus">Cancel Bolus</string>
<string name="omnipod_cmd_set_tbr">Set Temporary Basal</string>
<string name="omnipod_cmd_cancel_tbr_by_driver">Cancel Temporary Basal (internally by driver)</string>
<string name="omnipod_cmd_cancel_tbr">Cancel Temporary Basal</string>
<string name="omnipod_cmd_set_basal_schedule">Set Basal Schedule</string>
<string name="omnipod_cmd_get_pod_status">Get Pod Status</string>
<string name="omnipod_cmd_get_pod_info">Get Pod Info</string>
<string name="omnipod_cmd_set_time">Set Time</string>
<string name="omnipod_cmd_configure_alerts">Configure Alerts</string>
<string name="omnipod_cmd_acknowledge_alerts">Acknowledge Alerts</string>
<string name="omnipod_cmd_suspend_delivery">Suspend Delivery</string>
<string name="omnipod_cmd_resume_delivery">Resume Delivery</string>
<string name="omnipod_cmd_unknown_entry">Unknown Entry</string>
<string name="omnipod_cmd_initialize_pod">Initialize Pod</string>
<string name="omnipod_cmd_insert_cannula">Insert cannula</string>
<string name="omnipod_cmd_read_pulse_log">Read pulse log</string>
<string name="omnipod_cmd_insert_cannula">Insert Cannula</string>
<string name="omnipod_cmd_read_pulse_log">Read Pulse Log</string>
<string name="omnipod_cmd_set_fake_suspended_tbr">Set fake temporary basal because the Pod is suspended</string>
<string name="omnipod_cmd_cancel_fake_suspended_tbr">Cancel fake temporary basal that was created because the Pod was suspended</string>
<string name="omnipod_cmd_split_tbr">Split temporary basal because of uncertain failure in cancellation</string>
<string name="omnipod_cmd_beep_config">Beep config</string>
<string name="omnipod_cmd_play_test_beep">Play test beep</string>
<string name="omnipod_cmd_beep_config">Beep Config</string>
<string name="omnipod_cmd_play_test_beep">Play Test Beep</string>
<!-- Omnipod - Pod Management -->
<string name="omnipod_pod_management_title">Pod management</string>
@ -232,21 +244,21 @@
<string name="omnipod_overview_button_set_time">Set time</string>
<string name="omnipod_overview_button_suspend_delivery">Suspend</string>
<string name="omnipod_overview_button_refresh">Refresh</string>
<string name="omnipod_overview_button_resume_delivery">Resume delivery</string>
<string name="omnipod_overview_button_pod_management">Pod mgmt</string>
<string name="omnipod_overview_button_acknowledge_active_alerts">Ack alerts</string>
<string name="omnipod_overview_pod_status">Pod status</string>
<string name="omnipod_overview_total_delivered">Total delivered</string>
<string name="omnipod_overview_button_resume_delivery">Resume Delivery</string>
<string name="omnipod_overview_button_pod_management">Pod Mgmt</string>
<string name="omnipod_overview_button_acknowledge_active_alerts">Ack Alerts</string>
<string name="omnipod_overview_pod_status">Pod Status</string>
<string name="omnipod_overview_total_delivered">Total Delivered</string>
<string name="omnipod_overview_total_delivered_value">%1$.2f U</string>
<string name="omnipod_overview_pod_address">Pod address</string>
<string name="omnipod_overview_pod_expiry_date">Pod expires</string>
<string name="omnipod_overview_last_connection">Last connection</string>
<string name="omnipod_overview_last_bolus">Last bolus</string>
<string name="omnipod_overview_temp_basal_rate">Temp basal rate</string>
<string name="omnipod_overview_base_basal_rate">Base basal rate</string>
<string name="omnipod_overview_pod_address">Pod Address</string>
<string name="omnipod_overview_pod_expiry_date">Pod Expires</string>
<string name="omnipod_overview_last_connection">Last Connection</string>
<string name="omnipod_overview_last_bolus">Last Bolus</string>
<string name="omnipod_overview_temp_basal_rate">Temp Basal Rate</string>
<string name="omnipod_overview_base_basal_rate">Base Basal Rate</string>
<string name="omnipod_overview_reservoir">Reservoir</string>
<string name="omnipod_overview_pod_active_alerts">Active Pod alerts</string>
<string name="omnipod_overview_firmware_version">Firmware version</string>
<string name="omnipod_overview_pod_active_alerts">Active Pod Alerts</string>
<string name="omnipod_overview_firmware_version">Firmware Version</string>
<string name="omnipod_overview_time_on_pod">Time on Pod</string>
<string name="omnipod_overview_temp_basal_value">%1$.2fU/h @%2$s (%3$d/%4$d minutes)</string>
<string name="omnipod_overview_reservoir_value">%1$.2f U left</string>

View file

@ -112,9 +112,15 @@
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_omnipod_rileylink_stats_button_enabled"
android:key="@string/key_omnipod_riley_link_stats_button_enabled"
android:title="@string/omnipod_config_rileylink_stats_button_enabled" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_omnipod_use_riley_link_battery_level"
android:summary="@string/omnipod_config_use_riley_link_battery_level_summary"
android:title="@string/omnipod_config_use_riley_link_battery_level" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_omnipod_time_change_event_enabled"

View file

@ -81,6 +81,8 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
RadioResponse radioResponse = rfSpyResponse.getRadioResponse(injector);
T response = createResponseMessage(radioResponse.getPayload());
updateBatteryLevel();
if (response.isValid()) {
// Mark this as the last time we heard from the pump.
rememberLastGoodDeviceCommunicationTime();
@ -116,6 +118,10 @@ public abstract class RileyLinkCommunicationManager<T extends RLMessage> {
return response;
}
private void updateBatteryLevel() {
rileyLinkServiceData.batteryLevel = rfspy.getBatteryLevel();
}
public abstract T createResponseMessage(byte[] payload);

View file

@ -57,6 +57,8 @@ public class RFSpy {
private final UUID radioServiceUUID = UUID.fromString(GattAttributes.SERVICE_RADIO);
private final UUID radioDataUUID = UUID.fromString(GattAttributes.CHARA_RADIO_DATA);
private final UUID radioVersionUUID = UUID.fromString(GattAttributes.CHARA_RADIO_VERSION);
private final UUID batteryServiceUUID = UUID.fromString(GattAttributes.SERVICE_BATTERY);
private final UUID batteryLevelUUID = UUID.fromString(GattAttributes.CHARA_BATTERY_UNK);
//private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT);
private RileyLinkFirmwareVersion firmwareVersion;
private String bleVersion; // We don't use it so no need of sofisticated logic
@ -111,6 +113,19 @@ public class RFSpy {
}
public Integer getBatteryLevel() {
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID);
if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) {
int value = result.value[0];
aapsLogger.debug(LTag.PUMPBTCOMM, "BLE battery level: {}", value);
return value;
} else {
aapsLogger.error(LTag.PUMPBTCOMM, "getBatteryLevel failed with code: " + result.resultCode);
return null;
}
}
// This gets the version from the BLE113, not from the CC1110.
// I.e., this gets the version from the BLE interface, not from the radio.
public String getVersion() {

View file

@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.plugins.pump.common.R;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpInfo;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
@ -52,7 +51,6 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
boolean first = false;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.rileylink_status_general, container, false);
@ -79,7 +77,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
if (!first) {
// 7-12
// 7-14
int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12, R.id.rls_t1_tv13};
@ -114,7 +112,6 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
"\nCC110: " + rileyLinkServiceData.versionCC110);
}
}
RileyLinkPumpDevice pumpPlugin = (RileyLinkPumpDevice) activePlugin.getActivePump();

View file

@ -43,6 +43,7 @@ public class RileyLinkServiceData {
// radio version
public String versionCC110;
public Integer batteryLevel;
public RileyLinkTargetDevice targetDevice;

View file

@ -26,7 +26,7 @@
<androidx.viewpager.widget.ViewPager
android:id="@+id/rileylink_settings_container"
android:layout_width="match_parent"
android:layout_height="512dp"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layout_editor_absoluteY="55dp" />

View file

@ -49,9 +49,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
@ -75,9 +75,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
@ -102,9 +102,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
@ -129,12 +129,11 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="16pt"
@ -156,9 +155,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
<!-- Group - Device -->
@ -197,9 +196,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
@ -224,9 +223,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
@ -251,9 +250,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
@ -278,9 +277,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
@ -304,9 +303,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
@ -331,9 +330,9 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:textAlignment="center"
android:gravity="center_vertical"
android:text=" " />
android:text=" "
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>

View file

@ -29,7 +29,7 @@
<string name="rileylink_device_model">Device Model</string>
<string name="rileylink_last_used_frequency">Last used frequency</string>
<string name="rileylink_last_device_contact">Last device contact</string>
<string name="rileylink_firmware_version">RL Firmware</string>
<string name="rileylink_firmware_version">Firmware</string>
<!-- RL State -->