This commit is contained in:
Andrei Vereha 2021-07-11 18:05:06 +02:00
parent c4fc95768e
commit 4fc0a34785
4 changed files with 5 additions and 7 deletions

View file

@ -99,7 +99,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
statusChecker = Runnable {
refreshStatusOnUnacknowledgedCommands()
updatePodWarnings()
createFakeTBRWhenNoActivePod()
// createFakeTBRWhenNoActivePod()
// TODO: this is called from the main thread
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
}
}

View file

@ -186,7 +186,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
throw BusyException()
}
try {
if (podState.ltk != null) {
emitter.onNext(PodEvent.AlreadyPaired)
emitter.onComplete()
@ -222,7 +221,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
if (BuildConfig.DEBUG) {
aapsLogger.info(LTag.PUMPCOMM, "Got LTK: ${pairResult.ltk.toHex()}")
}
emitter.onNext(PodEvent.EstablishingSession)
establishSession(pairResult.msgSeq)
emitter.onNext(PodEvent.Connected)
@ -241,8 +239,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
}
companion object {
const val MAX_NUMBER_OF_CONNECTION_ATTEMPTS = 2
const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else.
private const val CONNECT_TIMEOUT_MULTIPLIER = 4
}
}

View file

@ -32,7 +32,7 @@ class ServiceDiscoverer(
bleCallbacks.waitForServiceDiscovery(it)
}
connectionWaitCond.stopConnection?.let {
while (!bleCallbacks.waitForConnection(STOP_CONNECTING_CHECK_INTERVAL_MS)) {
while (!bleCallbacks.waitForServiceDiscovery(STOP_CONNECTING_CHECK_INTERVAL_MS)) {
if (it.count == 0L) {
throw ConnectException("stopConnecting called")
}

View file

@ -66,12 +66,13 @@ class BleCommCallbacks(
serviceDiscoveryComplete = CountDownLatch(1)
}
fun waitForServiceDiscovery(timeoutMs: Long) {
fun waitForServiceDiscovery(timeoutMs: Long): Boolean {
try {
serviceDiscoveryComplete.await(timeoutMs, TimeUnit.MILLISECONDS)
} catch (e: InterruptedException) {
aapsLogger.warn(LTag.PUMPBTCOMM, "Interrupted while waiting for ServiceDiscovery")
}
return serviceDiscoveryComplete.count == 0L
}
fun confirmWrite(expectedPayload: ByteArray, expectedUUID: String, timeoutMs: Long): WriteConfirmation {