LoopKit / Loop

An automated insulin delivery app for iOS, built on LoopKit
https://loopdocs.org
Other
1.44k stars 1.27k forks source link

BS reading in future and NOT working #548

Closed Snowtoshi closed 5 years ago

Snowtoshi commented 6 years ago

BS seem to be reading in future and will not read the BS from the pump; however, it will pull the active insulin from the pump. The dates are correct but the time also seems to be off. Lost and desperate ; )


***problem solved by deleting data in the Apple Health App

ps2 commented 6 years ago

I'm guessing there is a small error in the enlite bg history parsing. Or maybe we aren't checking all the crc codes. @tmecklem, I'm guessing there are page CRCs as well as frame CRCs in the cgm history. Do you know if those are being validated?

tmecklem commented 6 years ago

It would be really helpful to have the binary page data. I suspect it's a timestamping issue, but it's really hard to tell without the data in the page. I doubt it's in the CRC since that works the same as the pump history pages but I suppose that's a possibility too.

Background information on glucose history parsing (feel free to skip this)

The glucose history pages work by writing some kind of event every 5 minutes during a running sensor session, whether that's an sgv, weak sensor, or some other kind of sensor event. If the code doesn't know how to process one of those events for some reason, then the sensor readings could be off by 5 minutes. Sometimes a weak sensor event is overwritten by an sgv if the signal is restored quickly enough.

Additionally, because of the quirky way that the glucose history pages work, the reference timestamps that tell Loop how to offset sgvs every 5 minutes only work on entries older than the timestamp itself. There's some speculative code that uses the latest timestamp to offset sgvs that occur after it in history, and it's fairly conservative and writes a new reference timestamp if there's anything other than sensor events after the last reference timestamp. That's another potential candidate to review in troubleshooting. All of these require a page of glucose history to understand what's happening with the cgm decoding.

Kdisimone commented 6 years ago

@ps2 looks like this one can be closed?