Merge pull request #76 from 0pen-dash/avereha/fix-problems
fix compiler warnings
This commit is contained in:
commit
415be541b7
13 changed files with 68 additions and 35 deletions
|
@ -147,13 +147,12 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
|
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED))
|
||||||
if (podStateManager.isSuspended) {
|
if (podStateManager.isSuspended) {
|
||||||
val notification =
|
showNotification(
|
||||||
Notification(
|
Notification.OMNIPOD_POD_SUSPENDED,
|
||||||
Notification.OMNIPOD_POD_SUSPENDED,
|
"Insulin delivery suspended",
|
||||||
"Insulin delivery suspended",
|
Notification.NORMAL,
|
||||||
Notification.NORMAL
|
R.raw.boluserror
|
||||||
)
|
)
|
||||||
rxBus.send(EventNewNotification(notification))
|
|
||||||
} else {
|
} else {
|
||||||
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED))
|
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED))
|
||||||
if (!podStateManager.sameTimeZone) {
|
if (!podStateManager.sameTimeZone) {
|
||||||
|
@ -246,13 +245,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun disconnect(reason: String) {
|
override fun disconnect(reason: String) {
|
||||||
aapsLogger.info(LTag.PUMP, "disconnect reason=$reason")
|
aapsLogger.info(LTag.PUMP, "disconnect reason=$reason")
|
||||||
stopConnecting?.let { it.countDown() }
|
stopConnecting?.countDown()
|
||||||
omnipodManager.disconnect(false)
|
omnipodManager.disconnect(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stopConnecting() {
|
override fun stopConnecting() {
|
||||||
aapsLogger.info(LTag.PUMP, "stopConnecting")
|
aapsLogger.info(LTag.PUMP, "stopConnecting")
|
||||||
stopConnecting?.let { it.countDown() }
|
stopConnecting?.countDown()
|
||||||
omnipodManager.disconnect(true)
|
omnipodManager.disconnect(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +327,15 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
Notification.URGENT,
|
Notification.URGENT,
|
||||||
R.raw.boluserror
|
R.raw.boluserror
|
||||||
)
|
)
|
||||||
|
if (!podStateManager.alarmSynced) {
|
||||||
|
pumpSync.insertAnnouncement(
|
||||||
|
error = podStateManager.alarmType?.toString() ?: "Unknown pod failure",
|
||||||
|
pumpId = Random.Default.nextLong(),
|
||||||
|
pumpType = PumpType.OMNIPOD_DASH,
|
||||||
|
pumpSerial = serialNumber()
|
||||||
|
)
|
||||||
|
podStateManager.alarmSynced = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Completable.complete()
|
Completable.complete()
|
||||||
}
|
}
|
||||||
|
@ -817,7 +825,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
val ret = pumpSync.syncTemporaryBasalWithPumpId(
|
val ret = pumpSync.syncTemporaryBasalWithPumpId(
|
||||||
timestamp = historyEntry.createdAt,
|
timestamp = historyEntry.createdAt,
|
||||||
rate = absoluteRate,
|
rate = absoluteRate,
|
||||||
duration = T.mins(durationInMinutes.toLong()).msecs(),
|
duration = T.mins(durationInMinutes).msecs(),
|
||||||
isAbsolute = true,
|
isAbsolute = true,
|
||||||
type = tbrType,
|
type = tbrType,
|
||||||
pumpId = historyEntry.pumpId(),
|
pumpId = historyEntry.pumpId(),
|
||||||
|
@ -833,7 +841,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
when {
|
when {
|
||||||
podStateManager.deliveryStatus !in
|
podStateManager.deliveryStatus !in
|
||||||
arrayOf(DeliveryStatus.TEMP_BASAL_ACTIVE, DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE) -> {
|
arrayOf(DeliveryStatus.TEMP_BASAL_ACTIVE, DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE) -> {
|
||||||
// TODO: what happens if we try to cancel inexistent temp basal?
|
// TODO: what happens if we try to cancel nonexistent temp basal?
|
||||||
aapsLogger.info(LTag.PUMP, "No temporary basal to cancel")
|
aapsLogger.info(LTag.PUMP, "No temporary basal to cancel")
|
||||||
Completable.complete()
|
Completable.complete()
|
||||||
}
|
}
|
||||||
|
@ -841,7 +849,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
!enforceNew ->
|
!enforceNew ->
|
||||||
Completable.error(
|
Completable.error(
|
||||||
IllegalStateException(
|
IllegalStateException(
|
||||||
"Temporary basal already active and enforeNew is not set."
|
"Temporary basal already active and enforceNew is not set."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -979,7 +987,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
aapsLogger.warn(LTag.PUMP, "Unsupported custom action: $customActionType")
|
aapsLogger.warn(LTag.PUMP, "Unsupported custom action: $customActionType")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun executeCustomCommand(customCommand: CustomCommand): PumpEnactResult? {
|
override fun executeCustomCommand(customCommand: CustomCommand): PumpEnactResult {
|
||||||
return when (customCommand) {
|
return when (customCommand) {
|
||||||
is CommandSilenceAlerts ->
|
is CommandSilenceAlerts ->
|
||||||
silenceAlerts()
|
silenceAlerts()
|
||||||
|
@ -1068,7 +1076,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
private fun deactivatePod(): PumpEnactResult {
|
private fun deactivatePod(): PumpEnactResult {
|
||||||
val ret = executeProgrammingCommand(
|
val ret = executeProgrammingCommand(
|
||||||
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
|
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
|
||||||
command = omnipodManager.deactivatePod().ignoreElements()
|
command = omnipodManager.deactivatePod().ignoreElements(),
|
||||||
|
checkNoActiveCommand = false,
|
||||||
).doOnComplete {
|
).doOnComplete {
|
||||||
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT))
|
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT))
|
||||||
}.toPumpEnactResult()
|
}.toPumpEnactResult()
|
||||||
|
@ -1381,11 +1390,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
sp.getBoolean(R.string.key_omnipod_common_notification_uncertain_tbr_sound_enabled, true)
|
sp.getBoolean(R.string.key_omnipod_common_notification_uncertain_tbr_sound_enabled, true)
|
||||||
Notification.OMNIPOD_UNCERTAIN_SMB ->
|
Notification.OMNIPOD_UNCERTAIN_SMB ->
|
||||||
sp.getBoolean(R.string.key_omnipod_common_notification_uncertain_smb_sound_enabled, true)
|
sp.getBoolean(R.string.key_omnipod_common_notification_uncertain_smb_sound_enabled, true)
|
||||||
|
Notification.OMNIPOD_POD_SUSPENDED ->
|
||||||
|
sp.getBoolean(R.string.key_omnipod_common_notification_delivery_suspended_sound_enabled, true)
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dismissNotification(id: Int) {
|
|
||||||
rxBus.send(EventDismissNotification(id))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,8 +211,8 @@ class BleCommCallbacks(
|
||||||
|
|
||||||
fun resetConnection() {
|
fun resetConnection() {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Reset connection")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Reset connection")
|
||||||
connected?.countDown()
|
connected.countDown()
|
||||||
serviceDiscoveryComplete?.countDown()
|
serviceDiscoveryComplete.countDown()
|
||||||
connected = CountDownLatch(1)
|
connected = CountDownLatch(1)
|
||||||
serviceDiscoveryComplete = CountDownLatch(1)
|
serviceDiscoveryComplete = CountDownLatch(1)
|
||||||
flushConfirmationQueue()
|
flushConfirmationQueue()
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
|
||||||
|
|
||||||
open class FailedToConnectException : Exception {
|
open class FailedToConnectException(message: String? = null) : Exception("Failed to connect: ${message ?: ""}")
|
||||||
constructor(message: String? = null) : super("Failed to connect: ${message ?: ""}")
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ class MessageIO(
|
||||||
fun sendMessage(msg: MessagePacket): MessageSendResult {
|
fun sendMessage(msg: MessagePacket): MessageSendResult {
|
||||||
val foundRTS = cmdBleIO.flushIncomingQueue()
|
val foundRTS = cmdBleIO.flushIncomingQueue()
|
||||||
if (foundRTS) {
|
if (foundRTS) {
|
||||||
val msg = receiveMessage(false)
|
val receivedMessage = receiveMessage(false)
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "sendMessage received message=$msg")
|
aapsLogger.warn(LTag.PUMPBTCOMM, "sendMessage received message=$receivedMessage")
|
||||||
throw IllegalStateException("Received message while trying to send")
|
throw IllegalStateException("Received message while trying to send")
|
||||||
}
|
}
|
||||||
dataBleIO.flushIncomingQueue()
|
dataBleIO.flushIncomingQueue()
|
||||||
|
|
|
@ -2,6 +2,5 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.scan
|
||||||
|
|
||||||
import android.os.ParcelUuid
|
import android.os.ParcelUuid
|
||||||
|
|
||||||
class DiscoveredInvalidPodException : Exception {
|
class DiscoveredInvalidPodException(message: String, serviceUUIds: List<ParcelUuid?>) :
|
||||||
constructor(message: String, serviceUUIds: List<ParcelUuid?>) : super("$message service UUIDs: $serviceUUIds")
|
Exception("$message service UUIDs: $serviceUUIds")
|
||||||
}
|
|
||||||
|
|
|
@ -15,8 +15,6 @@ class BasalProgram(
|
||||||
|
|
||||||
fun hasZeroUnitSegments() = segments.any { it.basalRateInHundredthUnitsPerHour == 0 }
|
fun hasZeroUnitSegments() = segments.any { it.basalRateInHundredthUnitsPerHour == 0 }
|
||||||
|
|
||||||
fun isZeroBasal() = segments.sumBy(Segment::basalRateInHundredthUnitsPerHour) == 0
|
|
||||||
|
|
||||||
fun rateAt(date: Date): Double {
|
fun rateAt(date: Date): Double {
|
||||||
val instance = Calendar.getInstance()
|
val instance = Calendar.getInstance()
|
||||||
instance.time = date
|
instance.time = date
|
||||||
|
|
|
@ -8,6 +8,6 @@ enum class BeepRepetitionType(
|
||||||
XXX(0x01.toByte()), // Used in lump of coal alert, LOW_RESERVOIR
|
XXX(0x01.toByte()), // Used in lump of coal alert, LOW_RESERVOIR
|
||||||
XXX2(0x03.toByte()), // Used in USER_SET_EXPIRATION
|
XXX2(0x03.toByte()), // Used in USER_SET_EXPIRATION
|
||||||
XXX3(0x05.toByte()), // published system expiration alert
|
XXX3(0x05.toByte()), // published system expiration alert
|
||||||
XXX4(0x06.toByte()), // Used in imminent pod expiration alert
|
XXX4(0x06.toByte()), // Used in imminent pod expiration alert, suspend in progress
|
||||||
XXX5(0x08.toByte()); // Lump of coal alert
|
XXX5(0x08.toByte()); // Lump of coal alert
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,6 @@ enum class BeepType(val value: Byte) {
|
||||||
|
|
||||||
SILENT(0x00.toByte()),
|
SILENT(0x00.toByte()),
|
||||||
FOUR_TIMES_BIP_BEEP(0x02.toByte()), // Used in low reservoir alert, user expiration alert, expiration alert, imminent expiration alert, lump of coal alert
|
FOUR_TIMES_BIP_BEEP(0x02.toByte()), // Used in low reservoir alert, user expiration alert, expiration alert, imminent expiration alert, lump of coal alert
|
||||||
|
XXX(0x04.toByte()), // Used during suspend
|
||||||
LONG_SINGLE_BEEP(0x06.toByte()); // Used in stop delivery command
|
LONG_SINGLE_BEEP(0x06.toByte()); // Used in stop delivery command
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,6 @@ import java.time.Duration
|
||||||
|
|
||||||
class PodConstants {
|
class PodConstants {
|
||||||
companion object {
|
companion object {
|
||||||
val MAX_POD_LIFETIME = Duration.ofMinutes(80)
|
val MAX_POD_LIFETIME = Duration.ofHours(80)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ interface OmnipodDashPodStateManager {
|
||||||
val time: ZonedDateTime?
|
val time: ZonedDateTime?
|
||||||
val timeDrift: java.time.Duration?
|
val timeDrift: java.time.Duration?
|
||||||
val expiry: ZonedDateTime?
|
val expiry: ZonedDateTime?
|
||||||
|
var alarmSynced: Boolean
|
||||||
|
|
||||||
val messageSequenceNumber: Short
|
val messageSequenceNumber: Short
|
||||||
val sequenceNumberOfLastProgrammingCommand: Short?
|
val sequenceNumberOfLastProgrammingCommand: Short?
|
||||||
|
|
|
@ -124,7 +124,19 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
override val sameTimeZone: Boolean
|
override val sameTimeZone: Boolean
|
||||||
get() {
|
get() {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
return TimeZone.getDefault().getOffset(now) == timeZone.getOffset(now)
|
val currentTimezone = TimeZone.getDefault()
|
||||||
|
val currentOffset = currentTimezone.getOffset(now)
|
||||||
|
val podOffset = timeZone.getOffset(now)
|
||||||
|
logger.debug(
|
||||||
|
LTag.PUMPCOMM,
|
||||||
|
"sameTimeZone currentTimezone=${currentTimezone.getDisplayName(
|
||||||
|
true,
|
||||||
|
TimeZone.SHORT
|
||||||
|
)} " +
|
||||||
|
"currentOffset=$currentOffset " +
|
||||||
|
"podOffset=$podOffset"
|
||||||
|
)
|
||||||
|
return currentOffset == podOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
override val bluetoothVersion: SoftwareVersion?
|
override val bluetoothVersion: SoftwareVersion?
|
||||||
|
@ -233,6 +245,13 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var alarmSynced: Boolean
|
||||||
|
get() = podState.alarmSynced
|
||||||
|
set(value) {
|
||||||
|
podState.alarmSynced = value
|
||||||
|
store()
|
||||||
|
}
|
||||||
|
|
||||||
override var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState
|
override var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState
|
||||||
@Synchronized
|
@Synchronized
|
||||||
get() = podState.bluetoothConnectionState
|
get() = podState.bluetoothConnectionState
|
||||||
|
@ -498,8 +517,10 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
podState.lastStatusResponseReceived = 0
|
podState.lastStatusResponseReceived = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandSendingFailure, NoActiveCommand ->
|
CommandSendingFailure, NoActiveCommand -> {
|
||||||
podState.activeCommand = null
|
podState.activeCommand = null
|
||||||
|
podState.lastStatusResponseReceived = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +597,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
override fun updateFromAlarmStatusResponse(response: AlarmStatusResponse) {
|
override fun updateFromAlarmStatusResponse(response: AlarmStatusResponse) {
|
||||||
logger.info(
|
logger.info(
|
||||||
LTag.PUMP,
|
LTag.PUMP,
|
||||||
"Received AlarmStatusReponse: $response"
|
"Received AlarmStatusResponse: $response"
|
||||||
)
|
)
|
||||||
podState.deliveryStatus = response.deliveryStatus
|
podState.deliveryStatus = response.deliveryStatus
|
||||||
podState.podStatus = response.podStatus
|
podState.podStatus = response.podStatus
|
||||||
|
@ -660,6 +681,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
var eapAkaSequenceNumber: Long = 1
|
var eapAkaSequenceNumber: Long = 1
|
||||||
var bolusPulsesRemaining: Short = 0
|
var bolusPulsesRemaining: Short = 0
|
||||||
var timeZone: String = "" // TimeZone ID (e.g. "Europe/Amsterdam")
|
var timeZone: String = "" // TimeZone ID (e.g. "Europe/Amsterdam")
|
||||||
|
var alarmSynced: Boolean = false
|
||||||
|
|
||||||
var bleVersion: SoftwareVersion? = null
|
var bleVersion: SoftwareVersion? = null
|
||||||
var firmwareVersion: SoftwareVersion? = null
|
var firmwareVersion: SoftwareVersion? = null
|
||||||
|
|
|
@ -21,4 +21,6 @@
|
||||||
|
|
||||||
<string name="key_omnipod_common_preferences_category_confirmation_beeps" translatable="false">omnipod_common_preferences_category_confirmation</string>
|
<string name="key_omnipod_common_preferences_category_confirmation_beeps" translatable="false">omnipod_common_preferences_category_confirmation</string>
|
||||||
<string name="key_common_preferences_category_other_settings" translatable="false">common_preferences_category_other</string>
|
<string name="key_common_preferences_category_other_settings" translatable="false">common_preferences_category_other</string>
|
||||||
|
<string name="key_omnipod_common_notification_delivery_suspended_sound_enabled">AAPS.Omnipod.notification_delivery_suspended_sound_enabled</string>
|
||||||
|
<string name="omnipod_common_preferences_notification_delivery_suspended_sound_enabled">Sound when delivery suspended notification enabled</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -93,6 +93,11 @@
|
||||||
android:key="@string/key_omnipod_common_notification_uncertain_bolus_sound_enabled"
|
android:key="@string/key_omnipod_common_notification_uncertain_bolus_sound_enabled"
|
||||||
android:title="@string/omnipod_common_preferences_notification_uncertain_bolus_sound_enabled" />
|
android:title="@string/omnipod_common_preferences_notification_uncertain_bolus_sound_enabled" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/key_omnipod_common_notification_delivery_suspended_sound_enabled"
|
||||||
|
android:title="@string/omnipod_common_preferences_notification_delivery_suspended_sound_enabled" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|
Loading…
Reference in a new issue