From d72444bfc519eb4cf5103f9a25d7ef8d38a8e9f5 Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Fri, 11 Aug 2023 18:31:51 +0200 Subject: [PATCH] Add delay after packet response --- .../info/nightscout/pump/medtrum/services/MedtrumService.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt index c8d793c36c..9fc02a1625 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt @@ -459,11 +459,9 @@ class MedtrumService : DaggerService(), BLECommCallback { private fun syncRecords(): Boolean { aapsLogger.debug(LTag.PUMP, "syncRecords: called!, syncedSequenceNumber: ${medtrumPump.syncedSequenceNumber}, currentSequenceNumber: ${medtrumPump.currentSequenceNumber}") var result = true - // Note: medtrum app fetches all records when they sync? if (medtrumPump.syncedSequenceNumber < medtrumPump.currentSequenceNumber) { for (sequence in (medtrumPump.syncedSequenceNumber + 1)..medtrumPump.currentSequenceNumber) { result = sendPacketAndGetResponse(GetRecordPacket(injector, sequence), COMMAND_SYNC_TIMEOUT_SEC) - SystemClock.sleep(100) if (result == false) break } } @@ -644,6 +642,7 @@ class MedtrumService : DaggerService(), BLECommCallback { mPacket = packet mPacket?.getRequest()?.let { bleComm.sendMessage(it) } result = currentState.waitForResponse(timeout) + SystemClock.sleep(100) } else { aapsLogger.error(LTag.PUMPCOMM, "Send packet attempt when in non Ready state") }