Handle inactive CGM sensor sessions#211
Conversation
Treat Dexcom's no-active-session marker as an invalid sensor session instead of deriving a future session start date. Keep transmitter state consistent and add coverage for no-session transmitter time and glucose parsing.
Test✅ I tested that this built successfully but I'm a G7 user ConfigurationI started with branch, update_dev_to_3.13.2, commit 076f608
Test Narrative
Observe the Nightscout display for SAGE and CAGE. I see that CAGE resets to 0 days. restore CGMBLE to dev branch and build again |
|
Using a test G6 sensor harness with an Anubis (G6) transmitter and a fresh clone of Loop dev, I could see that Nightscout would reliably and repeatedly show a newly added "CGM Sensor Start" treatment with a future time of 9/20/2161, 9:47 AM every time I started a New Sensor session. After applying this PR, I found that no future treatments were being added to Nightscout when a New Sensor session was started. |
marionbarker
left a comment
There was a problem hiding this comment.
Approved by code review and test.
LTGM
This PR addresses the remaining part of #209 by handling Dexcom’s “no active sensor session” marker at the source.
CGMBLEKit currently receives
0xffffffffas the session start time when there is no active sensor session. Because that value was still being treated as a real elapsed-time offset, CGMBLEKit could derive a sensor start date far in the future. Downstream apps can then see that future date as a validsessionStartDate, which can lead to incorrect Nightscout CGM state uploads such as future-dated Sensor Start treatments.#191 added a useful safety check by filtering out future-dated sensor events before they are emitted. That helps one path, but it does not fully solve the issue because downstream consumers may still read
latestReading.sessionStartDatedirectly before or outside that event filtering path.This PR moves the handling earlier:
0xffffffffas an explicit “no active session” valuesessionStartDate/sessionExpDatewhen no session is activeThe intent is that CGMBLEKit should not manufacture a future sensor start date when the transmitter is actually reporting that no session is active. That should prevent the bad date from leaking into downstream apps, while #191 remains useful as an additional defensive filter for any future-dated events.