Merge pull request #21 from 0pen-dash/andrei/activateNewPod

dash ble: add a separate method for activating a new pod
This commit is contained in:
Andrei Vereha 2021-03-14 15:41:27 +01:00 committed by GitHub
commit 3c3132ad17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 121 additions and 85 deletions

View file

@ -50,8 +50,12 @@ class OmnipodDashManagerImpl @Inject constructor(
private val observeConnectToPod: Observable<PodEvent> private val observeConnectToPod: Observable<PodEvent>
get() = Observable.defer { get() = Observable.defer {
bleManager.connect() bleManager.connect()
} // TODO add retry
} // TODO are these reasonable values? private val observePairNewPod: Observable<PodEvent>
get() = Observable.defer {
bleManager.pairNewPod()
}
private fun observeSendProgramBolusCommand( private fun observeSendProgramBolusCommand(
units: Double, units: Double,
@ -172,7 +176,7 @@ class OmnipodDashManagerImpl @Inject constructor(
override fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable<PodEvent> { override fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable<PodEvent> {
return Observable.concat( return Observable.concat(
observePodReadyForActivationPart1, observePodReadyForActivationPart1,
observeConnectToPod, observePairNewPod,
observeActivationPart1Commands(lowReservoirAlertTrigger) observeActivationPart1Commands(lowReservoirAlertTrigger)
).doOnComplete(ActivationProgressUpdater(ActivationProgress.PHASE_1_COMPLETED)) ).doOnComplete(ActivationProgressUpdater(ActivationProgress.PHASE_1_COMPLETED))
// TODO these would be common for any observable returned in a public function in this class // TODO these would be common for any observable returned in a public function in this class
@ -407,15 +411,13 @@ class OmnipodDashManagerImpl @Inject constructor(
when (event) { when (event) {
is PodEvent.AlreadyConnected -> { is PodEvent.AlreadyConnected -> {
podStateManager.bluetoothAddress = event.bluetoothAddress podStateManager.bluetoothAddress = event.bluetoothAddress
podStateManager.uniqueId = event.uniqueId
} }
is PodEvent.BluetoothConnected -> { is PodEvent.BluetoothConnected -> {
podStateManager.bluetoothAddress = event.address podStateManager.bluetoothAddress = event.bluetoothAddress
} }
is PodEvent.Connected -> { is PodEvent.Connected -> {
podStateManager.uniqueId = event.uniqueId
} }
is PodEvent.CommandSent -> { is PodEvent.CommandSent -> {
@ -427,6 +429,10 @@ class OmnipodDashManagerImpl @Inject constructor(
handleResponse(event.response) handleResponse(event.response)
} }
is PodEvent.Paired -> {
podStateManager.uniqueId = event.uniqueId.toLong()
}
else -> { else -> {
// Do nothing // Do nothing
} }

View file

@ -31,7 +31,7 @@ data class Id(val address: ByteArray) {
companion object { companion object {
private val PERIPHERAL_NODE_INDEX = 1 // TODO: understand the meaning of this value. It comes from preferences private const val PERIPHERAL_NODE_INDEX = 1 // TODO: understand the meaning of this value. It comes from preferences
fun fromInt(v: Int): Id { fun fromInt(v: Int): Id {
return Id(ByteBuffer.allocate(4).putInt(v).array()) return Id(ByteBuffer.allocate(4).putInt(v).array())

View file

@ -13,5 +13,7 @@ interface OmnipodDashBleManager {
fun connect(): Observable<PodEvent> fun connect(): Observable<PodEvent>
fun pairNewPod(): Observable<PodEvent>
fun disconnect() fun disconnect()
} }

View file

@ -47,6 +47,10 @@ class OmnipodDashBleManagerImpl @Inject constructor(
private var msgIO: MessageIO? = null private var msgIO: MessageIO? = null
private var gatt: BluetoothGatt? = null private var gatt: BluetoothGatt? = null
private var status: ConnectionStatus = ConnectionStatus.IDLE private var status: ConnectionStatus = ConnectionStatus.IDLE
private val myId = Id.fromInt(CONTROLLER_ID)
private val uniqueId = podState.uniqueId
private val podId = uniqueId?.let(Id::fromLong)
?: myId.increment() // pod not activated
@Throws( @Throws(
FailedToConnectException::class, FailedToConnectException::class,
@ -59,6 +63,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
DescriptorNotFoundException::class, DescriptorNotFoundException::class,
CouldNotConfirmDescriptorWriteException::class CouldNotConfirmDescriptorWriteException::class
) )
private fun connect(podDevice: BluetoothDevice): BleIO { private fun connect(podDevice: BluetoothDevice): BleIO {
val incomingPackets: Map<CharacteristicType, BlockingQueue<ByteArray>> = val incomingPackets: Map<CharacteristicType, BlockingQueue<ByteArray>> =
mapOf( mapOf(
@ -90,7 +95,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
val keys = sessionKeys val keys = sessionKeys
val mIO = msgIO val mIO = msgIO
if (keys == null || mIO == null) { if (keys == null || mIO == null) {
// TODO handle reconnects
throw Exception("Not connected") throw Exception("Not connected")
} }
emitter.onNext(PodEvent.CommandSending(cmd)) emitter.onNext(PodEvent.CommandSending(cmd))
@ -106,8 +110,8 @@ class OmnipodDashBleManagerImpl @Inject constructor(
val session = Session( val session = Session(
aapsLogger = aapsLogger, aapsLogger = aapsLogger,
msgIO = mIO, msgIO = mIO,
myId = Id.fromInt(CONTROLLER_ID), myId = myId,
podId = Id.fromInt(CONTROLLER_ID).increment(), podId = podId,
sessionKeys = keys, sessionKeys = keys,
enDecrypt = enDecrypt enDecrypt = enDecrypt
) )
@ -142,61 +146,48 @@ class OmnipodDashBleManagerImpl @Inject constructor(
) )
override fun connect(): Observable<PodEvent> = Observable.create { emitter -> override fun connect(): Observable<PodEvent> = Observable.create { emitter ->
// TODO: when we are already connected,
// emit PodEvent.AlreadyConnected, complete the observable and return from this method
try { try {
if (podState.bluetoothAddress == null) {
aapsLogger.info(LTag.PUMPBTCOMM, "starting new pod activation")
val podScanner = PodScanner(aapsLogger, bluetoothAdapter) val podAddress =
emitter.onNext(PodEvent.Scanning) podState.bluetoothAddress
?: throw FailedToConnectException("Missing bluetoothAddress, activate the pod first")
val podAddress = podScanner.scanForPod(
PodScanner.SCAN_FOR_SERVICE_UUID,
PodScanner.POD_ID_NOT_ACTIVATED
).scanResult.device.address
// For tests: this.podAddress = "B8:27:EB:1D:7E:BB";
podState.bluetoothAddress = podAddress
}
emitter.onNext(PodEvent.BluetoothConnecting)
val podAddress = podState.bluetoothAddress ?: throw FailedToConnectException("Lost connection")
// check if already connected // check if already connected
val podDevice = bluetoothAdapter.getRemoteDevice(podAddress) val podDevice = bluetoothAdapter.getRemoteDevice(podAddress)
val connectionState = bluetoothManager.getConnectionState(podDevice, BluetoothProfile.GATT) val connectionState = bluetoothManager.getConnectionState(podDevice, BluetoothProfile.GATT)
aapsLogger.debug(LTag.PUMPBTCOMM, "GATT connection state: $connectionState") aapsLogger.debug(LTag.PUMPBTCOMM, "GATT connection state: $connectionState")
emitter.onNext(PodEvent.BluetoothConnected(podAddress))
if (connectionState == BluetoothProfile.STATE_CONNECTED) { if (connectionState == BluetoothProfile.STATE_CONNECTED) {
podState.uniqueId ?: throw FailedToConnectException("Already connection and uniqueId is missing") emitter.onNext(PodEvent.AlreadyConnected(podAddress))
emitter.onNext(PodEvent.AlreadyConnected(podAddress, podState.uniqueId ?: 0))
emitter.onComplete() emitter.onComplete()
return@create return@create
} }
emitter.onNext(PodEvent.BluetoothConnecting)
if (msgIO != null) { if (msgIO != null) {
disconnect() disconnect()
} }
val bleIO = connect(podDevice) val bleIO = connect(podDevice)
val mIO = MessageIO(aapsLogger, bleIO) val mIO = MessageIO(aapsLogger, bleIO)
val myId = Id.fromInt(CONTROLLER_ID) msgIO = mIO
val podId = myId.increment() emitter.onNext(PodEvent.BluetoothConnected(podAddress))
var msgSeq = 1.toByte()
val ltkExchanger = LTKExchanger(aapsLogger, mIO, myId, podId, Id.fromLong(PodScanner.POD_ID_NOT_ACTIVATED))
if (podState.ltk == null) {
emitter.onNext(PodEvent.Pairing)
val pairResult = ltkExchanger.negotiateLTK()
podState.ltk = pairResult.ltk
podState.uniqueId = podId.toLong()
msgSeq = pairResult.msgSeq
podState.eapAkaSequenceNumber = 1
if (BuildConfig.DEBUG) {
aapsLogger.info(LTag.PUMPCOMM, "Got LTK: ${pairResult.ltk.toHex()}")
}
}
val ltk: ByteArray = podState.ltk!!
emitter.onNext(PodEvent.EstablishingSession) emitter.onNext(PodEvent.EstablishingSession)
establishSession(1.toByte())
emitter.onNext(PodEvent.Connected)
emitter.onComplete()
} catch (ex: Exception) {
disconnect()
emitter.tryOnError(ex)
}
}
private fun establishSession(msgSeq: Byte) {
val mIO = msgIO ?: throw FailedToConnectException("connection lost")
val ltk: ByteArray = podState.ltk ?: throw FailedToConnectException("Missing LTK, activate the pod first")
val uniqueId = podState.uniqueId
val podId = uniqueId?.let { Id.fromLong(uniqueId) }
?: myId.increment() // pod not activated
val eapSqn = podState.increaseEapAkaSequenceNumber() val eapSqn = podState.increaseEapAkaSequenceNumber()
val eapAkaExchanger = SessionEstablisher(aapsLogger, mIO, ltk, eapSqn, myId, podId, msgSeq) val eapAkaExchanger = SessionEstablisher(aapsLogger, mIO, ltk, eapSqn, myId, podId, msgSeq)
val keys = eapAkaExchanger.negotiateSessionKeys() val keys = eapAkaExchanger.negotiateSessionKeys()
@ -208,10 +199,45 @@ class OmnipodDashBleManagerImpl @Inject constructor(
aapsLogger.info(LTag.PUMPCOMM, "Nonce: ${keys.nonce}") aapsLogger.info(LTag.PUMPCOMM, "Nonce: ${keys.nonce}")
} }
sessionKeys = keys sessionKeys = keys
}
override fun pairNewPod(): Observable<PodEvent> = Observable.create { emitter ->
try {
if (podState.ltk != null) {
emitter.onNext(PodEvent.AlreadyPaired)
emitter.onComplete()
return@create
}
aapsLogger.info(LTag.PUMPBTCOMM, "starting new pod activation")
emitter.onNext(PodEvent.Scanning)
val podScanner = PodScanner(aapsLogger, bluetoothAdapter)
val podAddress = podScanner.scanForPod(
PodScanner.SCAN_FOR_SERVICE_UUID,
PodScanner.POD_ID_NOT_ACTIVATED
).scanResult.device.address
podState.bluetoothAddress = podAddress
emitter.onNext(PodEvent.BluetoothConnecting)
val podDevice = bluetoothAdapter.getRemoteDevice(podAddress)
val bleIO = connect(podDevice)
val mIO = MessageIO(aapsLogger, bleIO)
msgIO = mIO msgIO = mIO
emitter.onNext(PodEvent.BluetoothConnected(podAddress))
emitter.onNext(PodEvent.Connected(podId.toLong())) emitter.onNext(PodEvent.Pairing)
val ltkExchanger = LTKExchanger(aapsLogger, mIO, myId, podId, Id.fromLong(PodScanner.POD_ID_NOT_ACTIVATED))
val pairResult = ltkExchanger.negotiateLTK()
emitter.onNext(PodEvent.Paired(podId))
podState.updateFromPairing(podId, pairResult)
if (BuildConfig.DEBUG) {
aapsLogger.info(LTag.PUMPCOMM, "Got LTK: ${pairResult.ltk.toHex()}")
}
emitter.onNext(PodEvent.EstablishingSession)
establishSession(pairResult.msgSeq)
emitter.onNext(PodEvent.Connected)
emitter.onComplete() emitter.onComplete()
} catch (ex: Exception) { } catch (ex: Exception) {
disconnect() disconnect()

View file

@ -36,5 +36,4 @@ open class BleCommand(val data: ByteArray) {
override fun hashCode(): Int { override fun hashCode(): Int {
return data.contentHashCode() return data.contentHashCode()
} }
} }

View file

@ -123,6 +123,6 @@ class BleIO(
companion object { companion object {
private const val DEFAULT_IO_TIMEOUT_MS = 10000 private const val DEFAULT_IO_TIMEOUT_MS = 60000
} }
} }

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptio
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.BleIO import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.BleIO
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.PayloadJoiner import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.PayloadJoiner
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.CommandType
import info.nightscout.androidaps.utils.extensions.toHex import info.nightscout.androidaps.utils.extensions.toHex
class MessageIO(private val aapsLogger: AAPSLogger, private val bleIO: BleIO) { class MessageIO(private val aapsLogger: AAPSLogger, private val bleIO: BleIO) {
@ -22,19 +21,12 @@ class MessageIO(private val aapsLogger: AAPSLogger, private val bleIO: BleIO) {
return return
} }
throw UnexpectedCommandException(actual) throw UnexpectedCommandException(actual)
} }
fun sendMessage(msg: MessagePacket):MessagePacket? { fun sendMessage(msg: MessagePacket) {
bleIO.flushIncomingQueues() bleIO.flushIncomingQueues()
bleIO.sendAndConfirmPacket(CharacteristicType.CMD, BleCommandRTS().data) bleIO.sendAndConfirmPacket(CharacteristicType.CMD, BleCommandRTS().data)
val expectCTS = bleIO.receivePacket(CharacteristicType.CMD) val expectCTS = bleIO.receivePacket(CharacteristicType.CMD)
if (expectCTS.isEmpty()) {
throw UnexpectedCommandException(BleCommand(expectCTS))
}
//if (expectCTS[0] == BleCommandType.RTS.value) {
//the pod is trying to send something, after we sent RTS, let's read it
//}
expectCommandType(BleCommand(expectCTS), BleCommandCTS()) expectCommandType(BleCommand(expectCTS), BleCommandCTS())
val payload = msg.asByteArray() val payload = msg.asByteArray()
aapsLogger.debug(LTag.PUMPBTCOMM, "Sending message: ${payload.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Sending message: ${payload.toHex()}")
@ -48,11 +40,10 @@ class MessageIO(private val aapsLogger: AAPSLogger, private val bleIO: BleIO) {
val expectSuccess = bleIO.receivePacket(CharacteristicType.CMD) val expectSuccess = bleIO.receivePacket(CharacteristicType.CMD)
expectCommandType(BleCommand(expectSuccess), BleCommandSuccess()) expectCommandType(BleCommand(expectSuccess), BleCommandSuccess())
// TODO: handle NACKS/FAILS/etc // TODO: handle NACKS/FAILS/etc
return null
} }
// TODO: use higher timeout when receiving the first packet in a message // TODO: use higher timeout when receiving the first packet in a message
fun receiveMessage( firstCmd: ByteArray? = null): MessagePacket { fun receiveMessage(firstCmd: ByteArray? = null): MessagePacket {
var expectRTS = firstCmd var expectRTS = firstCmd
if (expectRTS == null) { if (expectRTS == null) {
expectRTS = bleIO.receivePacket(CharacteristicType.CMD) expectRTS = bleIO.receivePacket(CharacteristicType.CMD)

View file

@ -11,7 +11,7 @@ class StringLengthPrefixEncoding {
companion object { companion object {
private val LENGTH_BYTES = 2 private const val LENGTH_BYTES = 2
fun parseKeys(keys: Array<String>, payload: ByteArray): Array<ByteArray> { fun parseKeys(keys: Array<String>, payload: ByteArray): Array<ByteArray> {
val ret = Array<ByteArray>(keys.size, { ByteArray(0) }) val ret = Array<ByteArray>(keys.size, { ByteArray(0) })

View file

@ -236,8 +236,9 @@ internal class LTKExchanger(private val aapsLogger: AAPSLogger, private val msgI
private val PDM_CONF_MAGIC_PREFIX = "KC_2_U".toByteArray() private val PDM_CONF_MAGIC_PREFIX = "KC_2_U".toByteArray()
private val POD_CONF_MAGIC_PREFIX = "KC_2_V".toByteArray() private val POD_CONF_MAGIC_PREFIX = "KC_2_V".toByteArray()
private const val GET_POD_STATUS_HEX_COMMAND = private const val GET_POD_STATUS_HEX_COMMAND = "ffc32dbd08030e0100008a"
"ffc32dbd08030e0100008a" // TODO for now we are assuming this command is build out of constant parameters, use a proper command builder for that. // TODO for now we are assuming this command is build out of constant parameters,
// use a proper command builder for that.
private const val SP1 = "SP1=" private const val SP1 = "SP1="
private const val SP2 = ",SP2=" private const val SP2 = ",SP2="

View file

@ -35,10 +35,8 @@ class Session(
val msg = getCmdMessage(cmd) val msg = getCmdMessage(cmd)
aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command(wrapped): ${msg.payload.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command(wrapped): ${msg.payload.toHex()}")
val reply = msgIO.sendMessage(msg) msgIO.sendMessage(msg)
if (reply != null) { // TODO : this means the last ACK was not received, send it again?
aapsLogger.debug(LTag.PUMPBTCOMM, "Received a message with payload instead of CTS: ${reply.payload.toHex()} in packet $reply")
}
val responseMsg = msgIO.receiveMessage() val responseMsg = msgIO.receiveMessage()
val decrypted = enDecrypt.decrypt(responseMsg) val decrypted = enDecrypt.decrypt(responseMsg)
aapsLogger.debug(LTag.PUMPBTCOMM, "Received response: $decrypted") aapsLogger.debug(LTag.PUMPBTCOMM, "Received response: $decrypted")
@ -67,7 +65,7 @@ class Session(
payload = ByteArray(0), payload = ByteArray(0),
eqos = 0, eqos = 0,
ack = true, ack = true,
ackNumber = (response.sequenceNumber.toInt()+1).toByte() ackNumber = response.sequenceNumber.inc()
) )
return enDecrypt.encrypt((msg)) return enDecrypt.encrypt((msg))
} }

View file

@ -1,19 +1,21 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response
sealed class PodEvent { sealed class PodEvent {
/* BT connection events */ /* BT connection events */
class AlreadyConnected(val bluetoothAddress: String, val uniqueId: Long) : PodEvent() class AlreadyConnected(val bluetoothAddress: String) : PodEvent()
object AlreadyPaired : PodEvent()
object Scanning : PodEvent() object Scanning : PodEvent()
object BluetoothConnecting : PodEvent() object BluetoothConnecting : PodEvent()
class BluetoothConnected(val address: String) : PodEvent() class BluetoothConnected(val bluetoothAddress: String) : PodEvent()
object Pairing : PodEvent() object Pairing : PodEvent()
object Paired : PodEvent() class Paired(val uniqueId: Id) : PodEvent()
object EstablishingSession : PodEvent() object EstablishingSession : PodEvent()
class Connected(val uniqueId: Long) : PodEvent() object Connected : PodEvent()
/* Message exchange events */ /* Message exchange events */
class CommandSending(val command: Command) : PodEvent() class CommandSending(val command: Command) : PodEvent()

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
@ -54,6 +56,7 @@ interface OmnipodDashPodStateManager {
fun updateFromVersionResponse(response: VersionResponse) fun updateFromVersionResponse(response: VersionResponse)
fun updateFromSetUniqueIdResponse(response: SetUniqueIdResponse) fun updateFromSetUniqueIdResponse(response: SetUniqueIdResponse)
fun updateFromAlarmStatusResponse(response: AlarmStatusResponse) fun updateFromAlarmStatusResponse(response: AlarmStatusResponse)
fun updateFromPairing(uniqueId: Id, pairResult: PairResult)
fun reset() fun reset()
data class TempBasal(val startTime: Long, val rate: Double, val durationInMinutes: Short) : Serializable data class TempBasal(val startTime: Long, val rate: Double, val durationInMinutes: Short) : Serializable

View file

@ -6,6 +6,8 @@ import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
@ -248,6 +250,12 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
rxBus.send(EventOmnipodDashPumpValuesChanged()) rxBus.send(EventOmnipodDashPumpValuesChanged())
} }
override fun updateFromPairing(uniqueId: Id, pairResult: PairResult) {
podState.eapAkaSequenceNumber = 1
podState.ltk = pairResult.ltk
podState.uniqueId = uniqueId.toLong()
}
override fun reset() { override fun reset() {
podState = PodState() podState = PodState()
store() store()

View file

@ -20,7 +20,7 @@ class EnDecryptTest {
Hex.decode("dda23c090a0a0a0a"), Hex.decode("dda23c090a0a0a0a"),
0 0
), ),
Hex.decode("ba1283744b6de9fab6d9b77d95a71d6e"), Hex.decode("ba1283744b6de9fab6d9b77d95a71d6e")
) )
val encryptedMessage = Hex.decode( val encryptedMessage = Hex.decode(
"54571101070003400242000002420001" + "54571101070003400242000002420001" +
@ -43,7 +43,7 @@ class EnDecryptTest {
Hex.decode("dda23c090a0a0a0a"), Hex.decode("dda23c090a0a0a0a"),
0 0
), ),
Hex.decode("ba1283744b6de9fab6d9b77d95a71d6e"), Hex.decode("ba1283744b6de9fab6d9b77d95a71d6e")
) )
val encryptedMessage = Hex.decode( val encryptedMessage = Hex.decode(
"54571101070003400242000002420001" + "54571101070003400242000002420001" +