Add CGM sensor error reporting customization (cgm_sensor_notes) - #84
Open
bjorkert wants to merge 2 commits into
Open
Add CGM sensor error reporting customization (cgm_sensor_notes)#84bjorkert wants to merge 2 commits into
bjorkert wants to merge 2 commits into
Conversation
Abnormal Dexcom sensor states are uploaded to Nightscout as Note treatments: sensor issue, sensor failure, session failure, expiry, excess noise, calibration errors and unrecognized states, for G7 and G5/G6. One note per episode. A problem is reported when it starts and stays quiet while it persists. A reading the sensor's own kit calls reliable closes the open episodes, so a problem that clears and returns is reported again. Warmup, a stopped or ended session and an uncalibrated sensor leave open episodes untouched. Episodes are keyed by kind, and are cleared when a sensor session starts. The notes ride the CGM event pipeline Loop already has, from the CGM manager delegate through CgmEventStore and RemoteDataServicesManager to NightscoutService, which owns persistence and upload retry. The Loop app and every .pbxproj are left alone. The patch adds no files and edits four Swift files in CGMBLEKit, G7SensorKit, LoopKit and NightscoutService, whose hook points are identical on main, dev and next-dev, so one patch file serves all three branches.
Both Dexcom kits re-derive the sensor session start from the phone's clock on every reading, so consecutive readings of one session differ by the transport delay. Comparing those dates for equality treated every reading as a new session and cleared the open episodes, so a persisting fault produced a note every five minutes. A session counts as new when its start differs from the tracked one by more than fifteen minutes, far above the jitter and far below the gap between two real sessions. The first date seen for a session is the one kept, so the jitter cannot accumulate. The G5/G6 event joins the array the manager already builds, so it passes through the same future-dated event filter and arrives in the same delegate call as a sensor start. Episodes are written back only when they change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a customization that reports abnormal Dexcom sensor states to Nightscout as Note treatments: sensor issue, sensor failure, session failure, expiry, excess noise, calibration errors and unrecognized states, for G7 and G5/G6. It mirrors what I did for Trio in bjorkert/Trio feat/cgm-sensor-status-notes, and uses the same note wording so records from both apps read alike.
One note per episode. A problem is reported when it starts and then stays quiet while it persists. A reading the sensor's own kit calls reliable closes the open episodes, so a problem that clears and comes back is reported again. Warmup, a stopped or ended session and an uncalibrated sensor are neither recovery nor fault, and leave open episodes untouched. Episodes are keyed by kind, so a sensor drifting between two flavours of one failure reports once, and they are cleared when a sensor session starts, so a replacement sensor that fails during warmup still reports.
The notes ride the CGM event pipeline Loop already has, from the CGM manager delegate through CgmEventStore and RemoteDataServicesManager to NightscoutService, which owns persistence and upload retry. That keeps the Loop app itself untouched, and no .pbxproj is edited either. The patch adds no files and changes four Swift files, in CGMBLEKit, G7SensorKit, LoopKit and NightscoutService. Those hook points are identical on main, dev and next-dev, so the single patch file covers all three branches. Nothing here changes dosing, glucose handling or what the app displays.
The LoopWorkspace scheme builds on next-dev and on main. The patch applies and reverses cleanly on both, and it coexists with profiles, basal_lock, negative_insulin, now_line and 2hlollipop in either order.