ktLintFormat
This commit is contained in:
parent
b630c4d21a
commit
6c9aa90679
15 changed files with 39 additions and 28 deletions
|
@ -166,7 +166,11 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
||||||
|
|
||||||
emitter.onNext(PodEvent.Pairing)
|
emitter.onNext(PodEvent.Pairing)
|
||||||
val ltkExchanger = LTKExchanger(
|
val ltkExchanger = LTKExchanger(
|
||||||
aapsLogger, conn.msgIO, myId, podId, Id.fromLong(
|
aapsLogger,
|
||||||
|
conn.msgIO,
|
||||||
|
myId,
|
||||||
|
podId,
|
||||||
|
Id.fromLong(
|
||||||
PodScanner
|
PodScanner
|
||||||
.POD_ID_NOT_ACTIVATED
|
.POD_ID_NOT_ACTIVATED
|
||||||
)
|
)
|
||||||
|
|
|
@ -63,7 +63,8 @@ class BleCommCallbacks(
|
||||||
null -> return WriteConfirmationError("Timeout waiting for writeConfirmation")
|
null -> return WriteConfirmationError("Timeout waiting for writeConfirmation")
|
||||||
is WriteConfirmationSuccess ->
|
is WriteConfirmationSuccess ->
|
||||||
if (expectedPayload.contentEquals(received.payload) &&
|
if (expectedPayload.contentEquals(received.payload) &&
|
||||||
expectedUUID == received.uuid) {
|
expectedUUID == received.uuid
|
||||||
|
) {
|
||||||
received
|
received
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.warn(
|
aapsLogger.warn(
|
||||||
|
|
|
@ -3,4 +3,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti
|
||||||
open class FailedToConnectException : Exception {
|
open class FailedToConnectException : Exception {
|
||||||
constructor(message: String? = null) : super("Failed to connect: ${message ?: ""}")
|
constructor(message: String? = null) : super("Failed to connect: ${message ?: ""}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,13 @@ abstract class BleIO(
|
||||||
return BleSendErrorSending("Could not writeCharacteristic on {$type.name}")
|
return BleSendErrorSending("Could not writeCharacteristic on {$type.name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (val confirmation = bleCommCallbacks.confirmWrite(
|
return when (
|
||||||
payload, type.value,
|
val confirmation = bleCommCallbacks.confirmWrite(
|
||||||
|
payload,
|
||||||
|
type.value,
|
||||||
DEFAULT_IO_TIMEOUT_MS
|
DEFAULT_IO_TIMEOUT_MS
|
||||||
)) {
|
)
|
||||||
|
) {
|
||||||
is WriteConfirmationError ->
|
is WriteConfirmationError ->
|
||||||
BleSendErrorConfirming(confirmation.msg)
|
BleSendErrorConfirming(confirmation.msg)
|
||||||
is WriteConfirmationSuccess ->
|
is WriteConfirmationSuccess ->
|
||||||
|
@ -127,5 +130,3 @@ abstract class BleIO(
|
||||||
const val DEFAULT_IO_TIMEOUT_MS = 1000.toLong()
|
const val DEFAULT_IO_TIMEOUT_MS = 1000.toLong()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,4 +51,3 @@ class CmdBleIO(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ class MessageIO(
|
||||||
|
|
||||||
when (val receivedCmd = BleCommand.parse(peekCmd)) {
|
when (val receivedCmd = BleCommand.parse(peekCmd)) {
|
||||||
is BleCommandNack -> {
|
is BleCommandNack -> {
|
||||||
//// Consume NACK
|
// // Consume NACK
|
||||||
val received = cmdBleIO.receivePacket()
|
val received = cmdBleIO.receivePacket()
|
||||||
if (received !is BleReceivePayload) {
|
if (received !is BleReceivePayload) {
|
||||||
return MessageSendErrorSending(received.toString())
|
return MessageSendErrorSending(received.toString())
|
||||||
|
|
|
@ -55,7 +55,7 @@ data class FirstBlePacket(
|
||||||
throw IncorrectPacketException(payload, 0)
|
throw IncorrectPacketException(payload, 0)
|
||||||
}
|
}
|
||||||
val fullFragments = payload[1].toInt()
|
val fullFragments = payload[1].toInt()
|
||||||
require(fullFragments < MAX_FRAGMENTS) { "Received more than ${MAX_FRAGMENTS} fragments" }
|
require(fullFragments < MAX_FRAGMENTS) { "Received more than $MAX_FRAGMENTS fragments" }
|
||||||
when {
|
when {
|
||||||
// Without middle packets
|
// Without middle packets
|
||||||
payload.size < HEADER_SIZE_WITHOUT_MIDDLE_PACKETS ->
|
payload.size < HEADER_SIZE_WITHOUT_MIDDLE_PACKETS ->
|
||||||
|
@ -196,7 +196,6 @@ data class LastOptionalPlusOneBlePacket(
|
||||||
),
|
),
|
||||||
size = size.toByte(),
|
size = size.toByte(),
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val HEADER_SIZE = 2
|
private const val HEADER_SIZE = 2
|
||||||
|
|
|
@ -48,7 +48,7 @@ internal class LTKExchanger(
|
||||||
val sps2 = sps2()
|
val sps2 = sps2()
|
||||||
val sp2Result = msgIO.sendMessage(sps2.messagePacket)
|
val sp2Result = msgIO.sendMessage(sps2.messagePacket)
|
||||||
if (sp1Result !is MessageSendSuccess) {
|
if (sp1Result !is MessageSendSuccess) {
|
||||||
throw PairingException("Could not send sps2: ${sp2Result}")
|
throw PairingException("Could not send sps2: $sp2Result")
|
||||||
}
|
}
|
||||||
|
|
||||||
val podSps2 = msgIO.receiveMessage()
|
val podSps2 = msgIO.receiveMessage()
|
||||||
|
|
|
@ -49,12 +49,20 @@ class Connection(val podDevice: BluetoothDevice, private val aapsLogger: AAPSLog
|
||||||
private val discoverer = ServiceDiscoverer(aapsLogger, gattConnection, bleCommCallbacks)
|
private val discoverer = ServiceDiscoverer(aapsLogger, gattConnection, bleCommCallbacks)
|
||||||
private val discoveredCharacteristics = discoverer.discoverServices()
|
private val discoveredCharacteristics = discoverer.discoverServices()
|
||||||
private val cmdBleIO = CmdBleIO(
|
private val cmdBleIO = CmdBleIO(
|
||||||
aapsLogger, discoveredCharacteristics[CharacteristicType.CMD]!!, incomingPackets
|
aapsLogger,
|
||||||
.cmdQueue, gattConnection, bleCommCallbacks
|
discoveredCharacteristics[CharacteristicType.CMD]!!,
|
||||||
|
incomingPackets
|
||||||
|
.cmdQueue,
|
||||||
|
gattConnection,
|
||||||
|
bleCommCallbacks
|
||||||
)
|
)
|
||||||
private val dataBleIO = DataBleIO(
|
private val dataBleIO = DataBleIO(
|
||||||
aapsLogger, discoveredCharacteristics[CharacteristicType.DATA]!!, incomingPackets
|
aapsLogger,
|
||||||
.dataQueue, gattConnection, bleCommCallbacks
|
discoveredCharacteristics[CharacteristicType.DATA]!!,
|
||||||
|
incomingPackets
|
||||||
|
.dataQueue,
|
||||||
|
gattConnection,
|
||||||
|
bleCommCallbacks
|
||||||
)
|
)
|
||||||
val msgIO = MessageIO(aapsLogger, cmdBleIO, dataBleIO)
|
val msgIO = MessageIO(aapsLogger, cmdBleIO, dataBleIO)
|
||||||
var session: Session? = null
|
var session: Session? = null
|
||||||
|
|
Loading…
Reference in a new issue