DiaconnG8: pump log sync bug fix

This commit is contained in:
Milos Kozak 2022-12-08 11:38:50 +01:00
parent 8b44a24fb7
commit 621d0f3057
2 changed files with 13 additions and 2 deletions

View file

@ -104,6 +104,14 @@ class BLECommonService @Inject internal constructor(
return false
}
bluetoothGatt?.let {
it.disconnect()
SystemClock.sleep(200)
it.close()
SystemClock.sleep(200)
bluetoothGatt = null
}
val device = bluetoothAdapter?.getRemoteDevice(address)
if (device == null) {
aapsLogger.error("Device not found. Unable to connect from: $from")

View file

@ -295,18 +295,21 @@ class DiaconnG8Service : DaggerService() {
if (apsWrappingCount == -1 && apsLastLogNum == 9999) {
apsWrappingCount = pumpWrappingCount
apsLastLogNum = if (pumpLastNum - 1 < 0) 0 else pumpLastNum - 2
aapsLogger.debug(LTag.PUMPCOMM, "first install app apsWrappingCount : $apsWrappingCount, apsLastLogNum : $apsLastLogNum")
}
// if another pump
if (pumpSerialNo != diaconnG8Pump.serialNo) {
apsWrappingCount = pumpWrappingCount
apsLastLogNum = if (pumpLastNum - 1 < 0) 0 else pumpLastNum - 2
sp.putInt(rh.gs(R.string.pumpserialno), diaconnG8Pump.serialNo)
aapsLogger.debug(LTag.PUMPCOMM, "Pump serialNo is different apsWrappingCount : $apsWrappingCount, apsLastLogNum : $apsLastLogNum")
}
// if pump reset
if (apsIncarnationNum != diaconnG8Pump.pumpIncarnationNum) {
apsWrappingCount = pumpWrappingCount
apsLastLogNum = if (pumpLastNum - 1 < 0) 0 else pumpLastNum - 2
sp.putInt(R.string.apsIncarnationNo, apsIncarnationNum)
sp.putInt(R.string.apsIncarnationNo, diaconnG8Pump.pumpIncarnationNum)
aapsLogger.debug(LTag.PUMPCOMM, "Pump incarnationNum is different apsWrappingCount : $apsWrappingCount, apsLastLogNum : $apsLastLogNum")
}
aapsLogger.debug(LTag.PUMPCOMM, "apsWrappingCount : $apsWrappingCount, apsLastLogNum : $apsLastLogNum")
@ -375,7 +378,7 @@ class DiaconnG8Service : DaggerService() {
val end: Int // log sync end number1311
aapsLogger.debug(LTag.PUMPCOMM, "lastLogNum : $lastLogNum, wrappingCount : $wrappingCount , pumpLastNum: $pumpLastNum, pumpWrappingCount : $pumpWrappingCount")
if (pumpWrappingCount > wrappingCount && lastLogNum < 9999) {
if (pumpWrappingCount > wrappingCount) {
start = (lastLogNum + 1)
end = 10000
} else {