format. do not log keys
This commit is contained in:
parent
7374ff2eb1
commit
4aa67dedb5
|
@ -80,13 +80,11 @@ class KeyExchange(
|
||||||
pdmNonce +
|
pdmNonce +
|
||||||
podNonce
|
podNonce
|
||||||
aesCmac(confKey, pdmConfData, pdmConf)
|
aesCmac(confKey, pdmConfData, pdmConf)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmConf: ${pdmConf.toHex()}")
|
|
||||||
|
|
||||||
val podConfData = POD_CONF_MAGIC_PREFIX +
|
val podConfData = POD_CONF_MAGIC_PREFIX +
|
||||||
podNonce +
|
podNonce +
|
||||||
pdmNonce
|
pdmNonce
|
||||||
aesCmac(confKey, podConfData, podConf)
|
aesCmac(confKey, podConfData, podConf)
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "podConf: ${podConf.toHex()}")
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmPrivate: ${pdmPrivate.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmPrivate: ${pdmPrivate.toHex()}")
|
||||||
|
@ -94,6 +92,8 @@ class KeyExchange(
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "podPublic: ${podPublic.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "podPublic: ${podPublic.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmNonce: ${pdmNonce.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmNonce: ${pdmNonce.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "podNonce: ${podNonce.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "podNonce: ${podNonce.toHex()}")
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "podConf: ${podConf.toHex()}")
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmConf: ${pdmConf.toHex()}")
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "LTK, donna key: ${curveLTK.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "LTK, donna key: ${curveLTK.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Intermediate key: ${intermediateKey.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Intermediate key: ${intermediateKey.toHex()}")
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
|
||||||
import info.nightscout.androidaps.extensions.toHex
|
import info.nightscout.androidaps.extensions.toHex
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
|
||||||
import org.spongycastle.util.encoders.Hex
|
import org.spongycastle.util.encoders.Hex
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
|
@ -102,21 +103,23 @@ class Milenage(
|
||||||
val receivedMacS = auts.copyOfRange(6, 14)
|
val receivedMacS = auts.copyOfRange(6, 14)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage K: ${k.toHex()}")
|
if (BuildConfig.DEBUG) {
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage RAND: ${rand.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage K: ${k.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage SQN: ${sqn.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage RAND: ${rand.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage CK: ${ck.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage SQN: ${sqn.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AUTN: ${autn.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage CK: ${ck.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage RES: ${res.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AUTN: ${autn.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AK: ${ak.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage RES: ${res.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AK STAR: ${akStar.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AK: ${ak.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage OPC: ${opc.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AK STAR: ${akStar.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage FullMAC: ${macAFull.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage OPC: ${opc.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage MacA: ${macA.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage FullMAC: ${macAFull.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage MacS: ${macS.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage MacA: ${macA.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AUTS: ${auts.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage MacS: ${macS.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage synchronizationSqn: ${synchronizationSqn.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage AUTS: ${auts.toHex()}")
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage receivedMacS: ${receivedMacS.toHex()}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage synchronizationSqn: ${synchronizationSqn.toHex()}")
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage receivedMacS: ${receivedMacS.toHex()}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -677,7 +677,8 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
|
|
||||||
private fun store() {
|
private fun store() {
|
||||||
try {
|
try {
|
||||||
val serialized = Gson().toJson(podState)
|
val cleanPodState = podState.copy(ltk = byteArrayOf()) // do not log ltk
|
||||||
|
val serialized = Gson().toJson(cleanPodState)
|
||||||
logger.debug(LTag.PUMP, "Storing Pod state: $serialized")
|
logger.debug(LTag.PUMP, "Storing Pod state: $serialized")
|
||||||
sharedPreferences.putString(R.string.key_omnipod_dash_pod_state, serialized)
|
sharedPreferences.putString(R.string.key_omnipod_dash_pod_state, serialized)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
|
@ -699,56 +700,55 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
return PodState()
|
return PodState()
|
||||||
}
|
}
|
||||||
|
|
||||||
class PodState : Serializable {
|
data class PodState(
|
||||||
|
var activationProgress: ActivationProgress = ActivationProgress.NOT_STARTED,
|
||||||
var activationProgress: ActivationProgress = ActivationProgress.NOT_STARTED
|
var lastUpdatedSystem: Long = 0,
|
||||||
var lastUpdatedSystem: Long = 0
|
var lastStatusResponseReceived: Long = 0,
|
||||||
var lastStatusResponseReceived: Long = 0
|
|
||||||
var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState =
|
var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState =
|
||||||
OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED
|
OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED,
|
||||||
var connectionAttempts = 0
|
var connectionAttempts: Int = 0,
|
||||||
var successfulConnections = 0
|
var successfulConnections: Int = 0,
|
||||||
var successfulConnectionAttemptsAfterRetries = 0
|
var successfulConnectionAttemptsAfterRetries: Int = 0,
|
||||||
var failedConnectionsAfterRetries = 0
|
var failedConnectionsAfterRetries: Int = 0,
|
||||||
var messageSequenceNumber: Short = 0
|
var messageSequenceNumber: Short = 0,
|
||||||
var sequenceNumberOfLastProgrammingCommand: Short? = null
|
var sequenceNumberOfLastProgrammingCommand: Short? = null,
|
||||||
var activationTime: Long? = null
|
var activationTime: Long? = null,
|
||||||
var uniqueId: Long? = null
|
var uniqueId: Long? = null,
|
||||||
var bluetoothAddress: String? = null
|
var bluetoothAddress: String? = null,
|
||||||
var ltk: ByteArray? = null
|
var ltk: ByteArray? = null,
|
||||||
var eapAkaSequenceNumber: Long = 1
|
var eapAkaSequenceNumber: Long = 1,
|
||||||
var timeZone: String? = null // TimeZone ID (e.g. "Europe/Amsterdam")
|
var timeZone: String? = null, // TimeZone ID (e.g. "Europe/Amsterdam")
|
||||||
var timeZoneOffset: Int? = null
|
var timeZoneOffset: Int? = null,
|
||||||
var timeZoneUpdated: Long? = null
|
var timeZoneUpdated: Long? = null,
|
||||||
var alarmSynced: Boolean = false
|
var alarmSynced: Boolean = false,
|
||||||
var suspendAlertsEnabled: Boolean = false
|
var suspendAlertsEnabled: Boolean = false,
|
||||||
|
|
||||||
var bleVersion: SoftwareVersion? = null
|
var bleVersion: SoftwareVersion? = null,
|
||||||
var firmwareVersion: SoftwareVersion? = null
|
var firmwareVersion: SoftwareVersion? = null,
|
||||||
var lotNumber: Long? = null
|
var lotNumber: Long? = null,
|
||||||
var podSequenceNumber: Long? = null
|
var podSequenceNumber: Long? = null,
|
||||||
var pulseRate: Short? = null
|
var pulseRate: Short? = null,
|
||||||
var primePulseRate: Short? = null
|
var primePulseRate: Short? = null,
|
||||||
var podLifeInHours: Short? = null
|
var podLifeInHours: Short? = null,
|
||||||
var firstPrimeBolusVolume: Short? = null
|
var firstPrimeBolusVolume: Short? = null,
|
||||||
var secondPrimeBolusVolume: Short? = null
|
var secondPrimeBolusVolume: Short? = null,
|
||||||
|
|
||||||
var expirationReminderEnabled: Boolean? = null
|
var expirationReminderEnabled: Boolean? = null,
|
||||||
var expirationHours: Int? = null
|
var expirationHours: Int? = null,
|
||||||
var lowReservoirAlertEnabled: Boolean? = null
|
var lowReservoirAlertEnabled: Boolean? = null,
|
||||||
var lowReservoirAlertUnits: Int? = null
|
var lowReservoirAlertUnits: Int? = null,
|
||||||
|
|
||||||
var pulsesDelivered: Short? = null
|
var pulsesDelivered: Short? = null,
|
||||||
var pulsesRemaining: Short? = null
|
var pulsesRemaining: Short? = null,
|
||||||
var podStatus: PodStatus? = null
|
var podStatus: PodStatus? = null,
|
||||||
var deliveryStatus: DeliveryStatus? = null
|
var deliveryStatus: DeliveryStatus? = null,
|
||||||
var minutesSinceActivation: Short? = null
|
var minutesSinceActivation: Short? = null,
|
||||||
var activeAlerts: EnumSet<AlertType>? = null
|
var activeAlerts: EnumSet<AlertType>? = null,
|
||||||
var alarmType: AlarmType? = null
|
var alarmType: AlarmType? = null,
|
||||||
|
|
||||||
var basalProgram: BasalProgram? = null
|
var basalProgram: BasalProgram? = null,
|
||||||
var tempBasal: OmnipodDashPodStateManager.TempBasal? = null
|
var tempBasal: OmnipodDashPodStateManager.TempBasal? = null,
|
||||||
var activeCommand: OmnipodDashPodStateManager.ActiveCommand? = null
|
var activeCommand: OmnipodDashPodStateManager.ActiveCommand? = null,
|
||||||
var lastBolus: OmnipodDashPodStateManager.LastBolus? = null
|
var lastBolus: OmnipodDashPodStateManager.LastBolus? = null
|
||||||
}
|
) : Serializable
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
Color.RED
|
Color.RED
|
||||||
connectionSuccessPercentage < 90 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 ->
|
connectionSuccessPercentage < 90 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 ->
|
||||||
Color.YELLOW
|
Color.YELLOW
|
||||||
else ->
|
else ->
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
}
|
}
|
||||||
bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.setTextColor(connectionStatsColor)
|
bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.setTextColor(connectionStatsColor)
|
||||||
|
@ -333,9 +333,9 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
when {
|
when {
|
||||||
!podStateManager.sameTimeZone ->
|
!podStateManager.sameTimeZone ->
|
||||||
Color.MAGENTA
|
Color.MAGENTA
|
||||||
timeDeviationTooBig ->
|
timeDeviationTooBig ->
|
||||||
Color.YELLOW
|
Color.YELLOW
|
||||||
else ->
|
else ->
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -348,11 +348,11 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
?: PLACEHOLDER
|
?: PLACEHOLDER
|
||||||
podInfoBinding.podExpiryDate.setTextColor(
|
podInfoBinding.podExpiryDate.setTextColor(
|
||||||
when {
|
when {
|
||||||
expiresAt != null && ZonedDateTime.now().isAfter(expiresAt) ->
|
expiresAt != null && ZonedDateTime.now().isAfter(expiresAt) ->
|
||||||
Color.RED
|
Color.RED
|
||||||
expiresAt != null && ZonedDateTime.now().isAfter(expiresAt.minusHours(4)) ->
|
expiresAt != null && ZonedDateTime.now().isAfter(expiresAt.minusHours(4)) ->
|
||||||
Color.YELLOW
|
Color.YELLOW
|
||||||
else ->
|
else ->
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -430,21 +430,21 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
|
|
||||||
private fun translatedActiveAlert(alert: AlertType): String {
|
private fun translatedActiveAlert(alert: AlertType): String {
|
||||||
val id = when (alert) {
|
val id = when (alert) {
|
||||||
AlertType.LOW_RESERVOIR ->
|
AlertType.LOW_RESERVOIR ->
|
||||||
R.string.omnipod_common_alert_low_reservoir
|
R.string.omnipod_common_alert_low_reservoir
|
||||||
AlertType.EXPIRATION ->
|
AlertType.EXPIRATION ->
|
||||||
R.string.omnipod_common_alert_expiration_advisory
|
R.string.omnipod_common_alert_expiration_advisory
|
||||||
AlertType.EXPIRATION_IMMINENT ->
|
AlertType.EXPIRATION_IMMINENT ->
|
||||||
R.string.omnipod_common_alert_expiration
|
R.string.omnipod_common_alert_expiration
|
||||||
AlertType.USER_SET_EXPIRATION ->
|
AlertType.USER_SET_EXPIRATION ->
|
||||||
R.string.omnipod_common_alert_expiration_advisory
|
R.string.omnipod_common_alert_expiration_advisory
|
||||||
AlertType.AUTO_OFF ->
|
AlertType.AUTO_OFF ->
|
||||||
R.string.omnipod_common_alert_shutdown_imminent
|
R.string.omnipod_common_alert_shutdown_imminent
|
||||||
AlertType.SUSPEND_IN_PROGRESS ->
|
AlertType.SUSPEND_IN_PROGRESS ->
|
||||||
R.string.omnipod_common_alert_delivery_suspended
|
R.string.omnipod_common_alert_delivery_suspended
|
||||||
AlertType.SUSPEND_ENDED ->
|
AlertType.SUSPEND_ENDED ->
|
||||||
R.string.omnipod_common_alert_delivery_suspended
|
R.string.omnipod_common_alert_delivery_suspended
|
||||||
else ->
|
else ->
|
||||||
R.string.omnipod_common_alert_unknown_alert
|
R.string.omnipod_common_alert_unknown_alert
|
||||||
}
|
}
|
||||||
return rh.gs(id)
|
return rh.gs(id)
|
||||||
|
@ -457,7 +457,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
System.currentTimeMillis() -
|
System.currentTimeMillis() -
|
||||||
podStateManager.lastUpdatedSystem,
|
podStateManager.lastUpdatedSystem,
|
||||||
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val lastConnectionColor =
|
val lastConnectionColor =
|
||||||
if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().toMillis())) {
|
if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().toMillis())) {
|
||||||
|
@ -506,9 +506,9 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
val podStatusColor = when {
|
val podStatusColor = when {
|
||||||
!podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended ->
|
!podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended ->
|
||||||
Color.RED
|
Color.RED
|
||||||
podStateManager.activeCommand != null ->
|
podStateManager.activeCommand != null ->
|
||||||
Color.YELLOW
|
Color.YELLOW
|
||||||
else ->
|
else ->
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
}
|
}
|
||||||
podInfoBinding.podStatus.setTextColor(podStatusColor)
|
podInfoBinding.podStatus.setTextColor(podStatusColor)
|
||||||
|
@ -603,7 +603,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
private fun updateRefreshStatusButton() {
|
private fun updateRefreshStatusButton() {
|
||||||
buttonBinding.buttonRefreshStatus.isEnabled =
|
buttonBinding.buttonRefreshStatus.isEnabled =
|
||||||
podStateManager.isUniqueIdSet &&
|
podStateManager.isUniqueIdSet &&
|
||||||
isQueueEmpty()
|
isQueueEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateResumeDeliveryButton() {
|
private fun updateResumeDeliveryButton() {
|
||||||
|
@ -670,15 +670,15 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
val minutes = duration.toMinutes().toInt()
|
val minutes = duration.toMinutes().toInt()
|
||||||
val seconds = duration.seconds
|
val seconds = duration.seconds
|
||||||
when {
|
when {
|
||||||
seconds < 10 -> {
|
seconds < 10 -> {
|
||||||
return rh.gs(R.string.omnipod_common_moments_ago)
|
return rh.gs(R.string.omnipod_common_moments_ago)
|
||||||
}
|
}
|
||||||
|
|
||||||
seconds < 60 -> {
|
seconds < 60 -> {
|
||||||
return rh.gs(R.string.omnipod_common_less_than_a_minute_ago)
|
return rh.gs(R.string.omnipod_common_less_than_a_minute_ago)
|
||||||
}
|
}
|
||||||
|
|
||||||
seconds < 60 * 60 -> { // < 1 hour
|
seconds < 60 * 60 -> { // < 1 hour
|
||||||
return rh.gs(
|
return rh.gs(
|
||||||
R.string.omnipod_common_time_ago,
|
R.string.omnipod_common_time_ago,
|
||||||
rh.gq(R.plurals.omnipod_common_minutes, minutes, minutes)
|
rh.gq(R.plurals.omnipod_common_minutes, minutes, minutes)
|
||||||
|
@ -702,7 +702,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val days = hours / 24
|
val days = hours / 24
|
||||||
val hoursLeft = hours % 24
|
val hoursLeft = hours % 24
|
||||||
if (hoursLeft > 0)
|
if (hoursLeft > 0)
|
||||||
|
|
Loading…
Reference in a new issue