From 9ddeb29b102e6498813e70ee6ec5914d199025b9 Mon Sep 17 00:00:00 2001 From: miyeongkim Date: Fri, 2 Sep 2022 14:10:56 +0900 Subject: [PATCH] cloud log upload bug fix --- .../java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt | 3 +++ .../androidaps/diaconn/packet/BigLogInquireResponsePacket.kt | 2 ++ .../androidaps/diaconn/service/BLECommonService.kt | 5 +++++ .../androidaps/diaconn/service/DiaconnG8Service.kt | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt index 897723f2ec..266184595c 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Pump.kt @@ -19,6 +19,9 @@ class DiaconnG8Pump @Inject constructor( private val aapsLogger: AAPSLogger, private val dateUtil: DateUtil ) { + + var isPumplogUploadFailed: Boolean = false + //var bleResultInfo: Pair = Pair(null, false) var bolusConfirmMessage: Byte = 0 var isReadyToBolus: Boolean = false diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt index fe347adbf0..2f638fbc3a 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/packet/BigLogInquireResponsePacket.kt @@ -846,6 +846,8 @@ class BigLogInquireResponsePacket( } } override fun onFailure(call: Call, t: Throwable) { + aapsLogger.error(LTag.PUMPCOMM, "api uploadPumplogs failed") + diaconnG8Pump.isPumplogUploadFailed = true t.printStackTrace() } } diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt index 723d50752b..44b53851e7 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/BLECommonService.kt @@ -270,6 +270,11 @@ class BLECommonService @Inject internal constructor( val bytes = message.encode(sequence) processedMessageByte = bytes + if (bluetoothGatt == null) { + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> IGNORING (NOT CONNECTED) " + message.friendlyName ) + return + } + aapsLogger.debug(LTag.PUMPBTCOMM, "sendMessage() before mSendQueue.size :: ${mSendQueue.size}") // 펌프에 요청 보내기. writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt index 71f45067d3..011b09ae0c 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/service/DiaconnG8Service.kt @@ -330,6 +330,9 @@ class DiaconnG8Service : DaggerService() { if(platformLoopSize > 0) { diaconnG8Pump.isPlatformUploadStarted = true for (i in 0 until platformLoopSize) { + if(diaconnG8Pump.isPumplogUploadFailed) { + break + } rxBus.send(EventPumpStatusChanged("클라우드동기화 진행 중 : $i / $platformLoopSize")) val startLogNo: Int = platformStart + i * pumpLogPageSize val endLogNo: Int = startLogNo + min(platformEnd - startLogNo, pumpLogPageSize) @@ -338,6 +341,7 @@ class DiaconnG8Service : DaggerService() { } SystemClock.sleep(1000) diaconnG8Pump.isPlatformUploadStarted = false + diaconnG8Pump.isPumplogUploadFailed = false } } } catch (e:Exception) {