Dana BLE error handling

This commit is contained in:
Milos Kozak 2021-05-27 13:36:46 +02:00
parent 867e205ab6
commit 30eb339a88

View file

@ -372,6 +372,7 @@ class BLEComm @Inject internal constructor(
aapsLogger.debug(LTag.PUMPBTCOMM, "Shifting the input buffer by $idxStartByte bytes") aapsLogger.debug(LTag.PUMPBTCOMM, "Shifting the input buffer by $idxStartByte bytes")
System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte) System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte)
bufferLength -= idxStartByte bufferLength -= idxStartByte
if (bufferLength < 0) bufferLength = 0
} }
startSignatureFound = true startSignatureFound = true
break break
@ -393,6 +394,9 @@ class BLEComm @Inject internal constructor(
packetIsValid = true packetIsValid = true
readBuffer[length + 5] = PACKET_END_BYTE readBuffer[length + 5] = PACKET_END_BYTE
readBuffer[length + 6] = PACKET_END_BYTE readBuffer[length + 6] = PACKET_END_BYTE
} else {
aapsLogger.error(LTag.PUMPBTCOMM, "Error in input data. Resetting buffer.")
bufferLength = 0
} }
} }
} }