DanaR: ignore history records with invalid date
This commit is contained in:
parent
2b7c082979
commit
c1fca211bf
1 changed files with 129 additions and 121 deletions
|
@ -7,6 +7,7 @@ import info.nightscout.rx.events.EventDanaRSyncStatus
|
|||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.utils.T
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
open class MsgHistoryAll(
|
||||
injector: HasAndroidInjector
|
||||
) : MessageBase(injector) {
|
||||
|
@ -17,6 +18,7 @@ open class MsgHistoryAll(
|
|||
}
|
||||
|
||||
override fun handleMessage(bytes: ByteArray) {
|
||||
try {
|
||||
val recordCode = intFromBuff(bytes, 0, 1).toByte()
|
||||
val date = dateFromBuff(bytes, 1) // 3 bytes
|
||||
val dailyBasal = intFromBuff(bytes, 4, 2) * 0.01
|
||||
|
@ -148,5 +150,11 @@ open class MsgHistoryAll(
|
|||
if (recordCode == RecordTypes.RECORD_TYPE_DAILY)
|
||||
pumpSync.createOrUpdateTotalDailyDose(date, dailyBolus, dailyBasal, dailyBolus + dailyBasal, date, activePlugin.activePump.model(), danaPump.serialNumber)
|
||||
rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaHistoryRecord.timestamp) + " " + messageType))
|
||||
} catch (e: Exception) {
|
||||
// DanaR id sometimes producing invalid date in history
|
||||
// ignore these records
|
||||
aapsLogger.error(e.stackTraceToString())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue