Add delay after packet response

This commit is contained in:
jbr7rr 2023-08-11 18:31:51 +02:00
parent 8bb95cbc6b
commit d72444bfc5

View file

@ -459,11 +459,9 @@ class MedtrumService : DaggerService(), BLECommCallback {
private fun syncRecords(): Boolean { private fun syncRecords(): Boolean {
aapsLogger.debug(LTag.PUMP, "syncRecords: called!, syncedSequenceNumber: ${medtrumPump.syncedSequenceNumber}, currentSequenceNumber: ${medtrumPump.currentSequenceNumber}") aapsLogger.debug(LTag.PUMP, "syncRecords: called!, syncedSequenceNumber: ${medtrumPump.syncedSequenceNumber}, currentSequenceNumber: ${medtrumPump.currentSequenceNumber}")
var result = true var result = true
// Note: medtrum app fetches all records when they sync?
if (medtrumPump.syncedSequenceNumber < medtrumPump.currentSequenceNumber) { if (medtrumPump.syncedSequenceNumber < medtrumPump.currentSequenceNumber) {
for (sequence in (medtrumPump.syncedSequenceNumber + 1)..medtrumPump.currentSequenceNumber) { for (sequence in (medtrumPump.syncedSequenceNumber + 1)..medtrumPump.currentSequenceNumber) {
result = sendPacketAndGetResponse(GetRecordPacket(injector, sequence), COMMAND_SYNC_TIMEOUT_SEC) result = sendPacketAndGetResponse(GetRecordPacket(injector, sequence), COMMAND_SYNC_TIMEOUT_SEC)
SystemClock.sleep(100)
if (result == false) break if (result == false) break
} }
} }
@ -644,6 +642,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
mPacket = packet mPacket = packet
mPacket?.getRequest()?.let { bleComm.sendMessage(it) } mPacket?.getRequest()?.let { bleComm.sendMessage(it) }
result = currentState.waitForResponse(timeout) result = currentState.waitForResponse(timeout)
SystemClock.sleep(100)
} else { } else {
aapsLogger.error(LTag.PUMPCOMM, "Send packet attempt when in non Ready state") aapsLogger.error(LTag.PUMPCOMM, "Send packet attempt when in non Ready state")
} }